Path Manipulation Fortify
来源:互联网 发布:js 单选按钮改变事件 编辑:程序博客网 时间:2024/06/02 06:51
Fortify扫描遇到了Path Manipulation问题,定位代码如下:
File publisFile = null;File publisFileDir = new File(OSSFileUtils.getDeploy()+"/"+corpPK);涉及到安全性问题,在文件目录下,没有限制文件目录,可能存在的问题是:可以退回上一级目录,继而访问上一级内容,
解决办法:step1增加工具方法对文件目录的特殊字符进行处理
public static String validFilePath(String filepath) throws Exception{List<String> allowedExtensions = new ArrayList<>();boolean result = false;allowedExtensions.add(".xml");allowedExtensions.add(".jar");allowedExtensions.add(".api");allowedExtensions.add(".properties");allowedExtensions.add(".xsd");allowedExtensions.add(".flw");allowedExtensions.add(".schema");allowedExtensions.add(".MF");allowedExtensions.add(".log");for(String suf:allowedExtensions){if(filepath.endsWith(suf)){result = true;break;}}if(!result){ // 按指定模式在字符串查找 String pattern1 = "(.*)(\\.log\\.{0,1}\\d{0,})$"; // 创建 Pattern 对象 Pattern r1 = Pattern.compile(pattern1); // 现在创建 matcher 对象 Matcher m1 = r1.matcher(filepath); if(!m1.matches()){Exception Exception = new Exception("file name is Illage") ;throw Exception ; }}filepath.replaceAll("../", "");filepath.replaceAll("..\\\\", "");return filepath;}
step2.引用工具方法
String temp;temp = ESAPIUtil.validFilePath(OSSFileUtils.getProduct_package());File f = new File(temp, p.getFileName());问题解决!
0 1
- Path Manipulation Fortify
- 解决fortify扫描出的Path Manipulation问题(java语言)
- fortify中Path Manipulation issues in Java 问题解决
- Path Manipulation Routines
- fortify
- Fortify使用手册
- fortify vulncat
- Fortify&Coverity
- Fortify&Coverity
- Fortify配置
- Fortify Manager介绍
- Fortify分析翻译10
- Fortify分析翻译9
- Fortify分析翻译8
- Fortify分析翻译7
- Fortify分析翻译6
- Fortify分析翻译5
- Fortify分析翻译4
- 在centos7的无外网环境下编译安装caffe
- gulp自动化打包(下)
- Oracle编程之使用其他表的字段类型作为变量的类型
- ApplicationId与PackageName的区别
- 基于qt和opencv3实现机器学习之:利用正态贝叶斯分类
- Path Manipulation Fortify
- Storm使用非java语言构建Bolt,Spout
- Intent中显示意图和隐式意图的用法
- 统计和分析访问量工具集锦
- MFC编辑框自动滚动到最后一行
- 51nod_1011 最大公约数GCD
- Android Monkey测试
- 第三届蓝桥杯 第二题 福尔摩斯
- eclipse *.vm 文件 coding设置