@@ -110,7 +110,7 @@ public SQLExecutor createSQLExecutor() {
110
110
111
111
112
112
// UnitAuto 单元测试配置 https://github.com/TommyLemon/UnitAuto <<<<<<<<<<<<<<<<<<<<<<<<<<<
113
-
113
+ // FIXME 不要开放给项目组后端之外的任何人使用 UnitAuto(强制登录鉴权)!!!如果不需要单元测试则移除相关代码或 unitauto.Log.DEBUG = false;
114
114
UnitAutoApp .init ();
115
115
116
116
// 适配 Spring 注入的类及 Context 等环境相关的类
@@ -177,6 +177,21 @@ public boolean apply(Object object, String name, Object value) {
177
177
return false ;
178
178
}
179
179
180
+ // 防止通过 UnitAuto 远程执行 getDBPassword 等方法来查到敏感信息,但如果直接调用 public String getDBUri 这里没法拦截,仍然会返回敏感信息
181
+ // if (object instanceof SQLConfig) {
182
+ // // 这个类部分方法不序列化返回
183
+ // if ("dBUri".equalsIgnoreCase(name) || "dBPassword".equalsIgnoreCase(name) || "dBAccount".equalsIgnoreCase(name)) {
184
+ // return false;
185
+ // }
186
+ // return false; // 这个类所有方法都不序列化返回
187
+ // }
188
+
189
+ // 所有类中的方法只要包含关键词就不序列化返回
190
+ String n = StringUtil .toLowerCase (name );
191
+ if (n .contains ("database" ) || n .contains ("schema" ) || n .contains ("dburi" ) || n .contains ("password" ) || n .contains ("account" )) {
192
+ return false ;
193
+ }
194
+
180
195
return Modifier .isPublic (value .getClass ().getModifiers ());
181
196
}
182
197
}));
@@ -229,7 +244,8 @@ public boolean apply(Object object, String name, Object value) {
229
244
public static void main (String [] args ) throws Exception {
230
245
SpringApplication .run (DemoApplication .class , args );
231
246
232
- Log .DEBUG = true ; // 上线生产环境前改为 false,可不输出 APIJSONORM 的日志 以及 SQLException 的原始(敏感)信息
247
+ // FIXME 不要开放给项目组后端之外的任何人使用 UnitAuto(强制登录鉴权)!!!如果不需要单元测试则移除相关代码或 unitauto.Log.DEBUG = false;
248
+ unitauto .Log .DEBUG = Log .DEBUG = true ; // 上线生产环境前改为 false,可不输出 APIJSONORM 的日志 以及 SQLException 的原始(敏感)信息
233
249
APIJSONApplication .init ();
234
250
}
235
251
0 commit comments