@@ -110,7 +110,7 @@ public SQLExecutor createSQLExecutor() {
110110
111111
112112 // UnitAuto 单元测试配置 https://github.com/TommyLemon/UnitAuto <<<<<<<<<<<<<<<<<<<<<<<<<<<
113-
113+ // FIXME 不要开放给项目组后端之外的任何人使用 UnitAuto(强制登录鉴权)!!!如果不需要单元测试则移除相关代码或 unitauto.Log.DEBUG = false;
114114 UnitAutoApp .init ();
115115
116116 // 适配 Spring 注入的类及 Context 等环境相关的类
@@ -177,6 +177,21 @@ public boolean apply(Object object, String name, Object value) {
177177 return false ;
178178 }
179179
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+
180195 return Modifier .isPublic (value .getClass ().getModifiers ());
181196 }
182197 }));
@@ -229,7 +244,8 @@ public boolean apply(Object object, String name, Object value) {
229244 public static void main (String [] args ) throws Exception {
230245 SpringApplication .run (DemoApplication .class , args );
231246
232- Log .DEBUG = true ; // 上线生产环境前改为 false,可不输出 APIJSONORM 的日志 以及 SQLException 的原始(敏感)信息
247+ // FIXME 不要开放给项目组后端之外的任何人使用 UnitAuto(强制登录鉴权)!!!如果不需要单元测试则移除相关代码或 unitauto.Log.DEBUG = false;
248+ unitauto .Log .DEBUG = Log .DEBUG = true ; // 上线生产环境前改为 false,可不输出 APIJSONORM 的日志 以及 SQLException 的原始(敏感)信息
233249 APIJSONApplication .init ();
234250 }
235251
0 commit comments