编写java打码如下:
。。。
File proFile = new File(path);
。。。
使用fortify扫描,会报一个Path Manipulation的漏洞,怎么解决呢?看下面代码:
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"); map.put("k", "k"); map.put("l", "l"); map.put("m", "m"); map.put("n", "n"); map.put("o", "o"); map.put("p", "p"); map.put("q", "q"); map.put("r", "r"); map.put("s", "s"); map.put("t", "t"); map.put("u", "u"); map.put("v", "v"); map.put("w", "w"); map.put("x", "x"); map.put("y", "y"); map.put("z", "z"); 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"); map.put("K", "K"); map.put("L", "L"); map.put("M", "M"); map.put("N", "N"); map.put("O", "O"); map.put("P", "P"); map.put("Q", "Q"); map.put("R", "R"); map.put("S", "S"); map.put("T", "T"); map.put("U", "U"); map.put("V", "V"); map.put("W", "W"); map.put("X", "X"); map.put("Y", "Y"); map.put("Z", "Z");
map.put(":", ":"); map.put("/", "/"); map.put("\\", "\\"); String temp = ""; for (int i = 0; i < path.length(); i++) {
if (map.get(path.charAt(i)+"")!=null) { temp += map.get(path.charAt(i)+""); } } path = temp; File proFile = new File(path);
红色代码是新增代码,增加上述代码后,问题解决。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有