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

标签 java security plugins sonarqube rules

该规则仅在商业中可用,我想创建一个关于 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/

相关文章:

java - Spring - 强制 bean 属性来自 post 变量

Android Gradle 插件(警告)API 'variant.getMergeResources()' 已过时并已替换为 'variant.getMergeResourcesProvider()'

java - 在 Spring Security 中处理自定义异常

Java - 将 BigDecimal 值舍入到 2 个级别,保留 2 位小数

java - 识别列表中已存在于数据库中的项目并将其删除

plugins - 客户关系管理 2011 : How to Update record in a Create Plugin?

javascript - 避免 jsPlumb 中的连接和元素重叠

java - ksoap2 org.xmlpull.v1.xmlpullparserexception 预期 start_tag 错误

security - Swift 的私有(private)访问修饰符是否会阻止在运行时访问属性/方法?

PHP mkdir : 0777 becomes 0755?