1. 关于Log的问题(Log Forging),整个系统中,对于Log的问题最多,可以采用以下方式进行解决。
解决方案如下:
1) 只输出必要的日志,功能上线前屏蔽大多数的调试日志。
2) 过滤掉非法字符:
2. 关于创建File(Path Manipulation)的问题。
Fortify扫描遇到了Path Manipulation问题,定位代码如下:
1. File publisFile = null;
2. File publisFileDir = new File(OSSFileUtils.getDeploy()+"/"+corpPK);
涉及到安全性问题,在文件目录下,没有限制文件目录,可能存在的问题是:可以退回上一级目录,继而访问上一级内容,
解决办法:
step1增加工具方法对文件目录的特殊字符进行处理
public class FileSwitch {
public static String validFilePath(String filepath) throws Exception {
HashMap<String, String> map = new HashMap<String, String>();
map.put("a", "a");
map.put("b", "b");
map.put("c", "c");
map.put("d", "d");
map.put("e", "e");
map.put("f", "f");
map.put("g", "g");
map.put("h", "h");
map.put("i", "i");
map.put("j", "j"