• SonarQube规则之漏洞类型


    漏洞类型:

    1、"@RequestMapping" methods should be "public"
    漏洞 阻断
    标注了RequestMapping是controller是处理web请求。既使方法修饰为private,同样也能被外部调用,因为spring通过反射调用方法,没有检查方法可视度,
    2、"enum" fields should not be publicly mutable
    漏洞 次要
    枚举类域不应该是public,也不应该进行set
    3、"File.createTempFile" should not be used to create a directory
    漏洞 严重
    File.createTempFile不应该被用来创建目录
    4、"HttpServletRequest.getRequestedSessionId()" should not be used
    漏洞 严重
    HttpServletRequest.getRequestedSessionId()返回客户端浏览器会话id不要用,用HttpServletRequest.getSession().getId()
    5、"javax.crypto.NullCipher" should not be used for anything other than testing
    漏洞 阻断
    NullCipher类提供了一种“身份密码”,不会以任何方式转换或加密明文。 因此,密文与明文相同。 所以这个类应该用于测试,从不在生产代码中。
    6、"public static" fields should be constant
    漏洞 次要
    public static 域应该 final
    7、Class variable fields should not have public accessibility
    漏洞 次要
    类变量域应该是private,通过set,get进行操作
    8、Classes should not be loaded dynamically
    漏洞 严重
    不应该动态加载类,动态加载的类可能包含由静态类初始化程序执行的恶意代码.
    Class clazz = Class.forName(className); // Noncompliant
    9、Cookies should be "secure"
    漏洞 次要
    Cookie c = new Cookie(SECRET, secret); // Noncompliant; cookie is not secure
    response.addCookie(c);
    正:
    Cookie c = new Cookie(SECRET, secret);
    c.setSecure(true);
    response.addCookie(c);
    10、Credentials should not be hard-coded
    漏洞 阻断
    凭证不应该硬编码
    11、Cryptographic RSA algorithms should always incorporate OAEP (Optimal Asymmetric Encryption Padding)
    漏洞 严重
    加密RSA算法应始终包含OAEP(最优非对称加密填充)
    12、Default EJB interceptors should be declared in "ejb-jar.xml"
    漏洞 阻断
    默认EJB拦截器应在“ejb-jar.xml”中声明
    13、Defined filters should be used
    漏洞 严重
    web.xml文件中定义的每个过滤器都应该在<filter-mapping>元素中使用。 否则不会调用此类过滤器。
    14、Exceptions should not be thrown from servlet methods
    漏洞 次要
    不应该从servlet方法抛出异常
    15、HTTP referers should not be relied on
    漏洞 严重
    不应依赖于http,将这些参数值中止后可能是安全的,但绝不应根据其内容作出决定。
    如:
    String referer = request.getHeader("referer"); // Noncompliant
    if(isTrustedReferer(referer)){
    //..
    }
    16、IP addresses should not be hardcoded
    漏洞 次要
    ip 地址不应该硬编码
    17、Member variable visibility should be specified
    漏洞 次要
    应指定成员变量的可见性
    18、Members of Spring components should be injected
    漏洞 严重
    spring组件的成员应注入,单例注入非静态成员共享会产生风险
    19、Mutable fields should not be "public static"
    漏洞 次要
    多变在域不应为 public static
    20、Neither DES (Data Encryption Standard) nor DESede (3DES) should be used
    漏洞 阻断
    不应使用DES(数据加密标准)和DESEDE(3DES)
    21、Only standard cryptographic algorithms should be used
    漏洞 严重
    标准的加密算法如 SHA-256, SHA-384, SHA-512等,非标准算法是危险的,可能被功能者攻破算法
    22、Pseudorandom number generators (PRNGs) should not be used in secure contexts
    漏洞 严重
    伪随机数生成器(PRNG)不应在安全上下文中使用
    23、Return values should not be ignored when they contain the operation status code
    漏洞 次要
    当函数调用的返回值包含操作状态代码时,应该测试此值以确保操作成功完成。
    24、Security constraints should be definedin
    漏洞 阻断
    应定义安全约束,当web.xml文件没有<security-constraint>元素时,此规则引发了一个问题
    25、SHA-1 and Message-Digest hash algorithms should not be used
    漏洞 严重
    不应该使用SHA-1和消息摘要散列算法,已证实不再安全
    26、SQL binding mechanisms should be used
    漏洞 阻断
    应该使用SQL绑定机制
    27、Struts validation forms should have unique names
    漏洞 阻断
    struts验证表单应有唯一名称
    28、Throwable.printStackTrace(...) should not be called
    漏洞 次要
    Throwable.printStackTrace(...)会打印异常信息,但会暴露敏感信息
    29、Untrusted data should not be stored in sessions
    漏洞 主要
    不受信任的数据不应存储在会话中。
    Web会话中的数据被认为在“信任边界”内。 也就是说,它被认为是值得信赖的。 但存储未经身份验证的用户未经验证的数据违反信任边界,并可能导致该数据被不当使用。
    30、Values passed to LDAP queries should be sanitized
    漏洞 严重
    传递到LDAP查询的值应该被清理
    31、Values passed to OS commands should be sanitized
    漏洞 严重
    传递给OS命令的值应该被清理
    32、Web applications should not have a "main" method
    漏洞 严重
    web 应用中不应有一个main方法

    成功最有效的方法就是向有经验的人学习!
  • 相关阅读:
    字符串型
    字符型
    实型(浮点型)
    sizeof
    数据类型
    标识符
    Win32汇编
    Win32汇编
    C# 语言程序设计笔记
    鬼泣4:寻找无限生命/剑气/暴怒
  • 原文地址:https://www.cnblogs.com/yanxinjiang/p/9875810.html
Copyright © 2020-2023  润新知