gpt4 book ai didi

java - 如何创建规则(HTTP 请求重定向不应受到伪造攻击 - RSPEC-5146)java 插件

转载 作者:行者123 更新时间:2023-12-02 01:12:34 26 4
gpt4 key购买 nike

该规则仅在商业中可用,我想创建一个关于 HTTP 请求方向的自定义规则

下面的代码是合规和不合规的

        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String location = req.getParameter("url");
resp.sendRedirect(location); // Noncompliant {{non- compliant}}
}

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String location = req.getParameter("url");

if (!urlWhiteList.contains(location))
throw new IOException();

resp.sendRedirect(location);
}

最佳答案

这些规则使用一些更高级的算法进行静态分析。本文https://wiki.mozilla.org/Abstract_Interpretation提供了良好的高层次介绍。那么您可能会对 https://en.wikipedia.org/wiki/Pointer_analysis 感兴趣

掌握基础知识后,您可以按照 https://github.com/SonarSource/sonar-java/blob/master/docs/CUSTOM_RULES_101.md 开始实现

关于java - 如何创建规则(HTTP 请求重定向不应受到伪造攻击 - RSPEC-5146)java 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59150987/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com