Fortify代码扫描 Java提供解决方案支撑

以下问题修复中使用到的工具类自行下载,不知道如何使用的或者有疑问的希望及时回复。
一、【已修复】Access Control: Database
如果项目使用的是Mybatis,按照Fortify给出的修复方案,给SQL中添加类似USER这样的查询条件来控制权限,扫描结果中依旧无法去除此漏洞。反射调用

二、【已修复】Cross-Site Scripting: Persistent
涉及到返回前端byte[]的地方用IO写回去

三、【已修复】Denial of Service: Regular Expression
将不可信赖的数据用作正则表达式 反射调用replaceAll、replaceFirst和split方法

四、Dynamic Code Evaluation: Unsafe Deserialization
在运行时对用户控制的对象流进行反序列化 new new RedisTemplate<>()时有问题
反序列化超出了开发人员的控制范围,反射调用

五、【已修复】HTML5: Missing Content Security Policy
未配置内容安全策略 (CSP)。
在springSecurity配置类中加入CSP策略

public static final String GET_CSP = "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; script-src-elem 'none'; script-src-attr 'none'";

http.headers().contentSecurityPolicy(GET_CSP);

六、【已修复】HTTP Parameter Pollution
如果你接受一个RequestBody为String类型,那么就有可能触发HTTP参数污染漏洞,从HttpServletReques中直接读body

七、【已修复】Header Manipulation
对响应头进行设置response.getHeaders().set(“Content-Disposition”, URLEncoder.encode(fileName + “.xlsx”, String.valueOf(StandardCharsets.UTF_8)));
反射调用

八、【已修复】Log Forging
%0d、\r、\n等特殊字符过滤,日志打印方法,反射调用

九、【可修复】Mass Assignment: Insecure Binder Configuration

    // Controller中加入这段代码即可清除此扫描告警 
    @InitBinder()
    public void initBinder(WebDataBinder binder) {
        binder.setDisallowedFields(new String[]{});
    }

十、【已修复】Mass Assignment: Sensitive Field Exposure
一个敏感字段已向模型绑定器公开,修改字段名称

十一、【已修复】Often Misused: File Upload
中风险: 不允许上传文件! 将文件对象封装到其他对象中

十二、【已修复】Password Management: Hardcoded Password
硬编码密码

十三、【已修复】Path Manipulation
用户输入一个文件名称,他的名称像目录一样,导致我们删除了本机用户信息
换一种删除方式例如: deleteIfExists()

十四、【已修复】Portability Flaw: Locale Dependent Comparison
使用equals的时候建议使用equalsIgnoreCase方法

十五、【已修复】Privacy Violation
隐私泄露,加解密前后的值不能打印日志

十六、【已修复】Privacy Violation: Heap Inspection
将敏感数据存储在 String 对象中使系统无法从内存中可靠地清除数据,删掉将密码存储在内存中的代码。

十七、【已修复】SQL Injection
Sql注入一定是$符号的问题

十八、【已修复】Server-Side Request Forgery

// get请求参数构建
UriComponentsBuilder builder = UriComponentsBuilder.fromUri(URI.create(url));
if (param != null){
    for (Map.Entry<String, Object> entry : param.entrySet()) {
        builder.queryParam(entry.getKey(), entry.getValue());
    }
}
UriComponents uriComponents = builder.build();
String uri = uriComponents.toUriString();

// restful占位符请求路径构建 buildAndExpand可以接受多个参数对应多个占位符
String taskId = "123123123"
String url = UriComponentsBuilder.fromUriString("http://localhost:8080/task/{taskId}").buildAndExpand(taskId).toUriString();
// 输出结果: url = "http://localhost:8080/task/123123123";

十九、【已修复】Unreleased Resource: Sockets
释放httpCLient

二十、【已修复】Unreleased Resource: Streams
程序可能无法成功释放某一项系统资源

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值