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方法


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM