界: Code Quality

程式碼品質不佳,會導致無法預料的行為。從使用者的角度來看,這通常表現為可用性不佳。對於攻擊者而言,這提供了以意想不到的方式向系統施加壓力的機會。

Code Correctness: Misleading Method Signature

Abstract
看起來像是可代替一般的 .NET 方法,但實際上卻沒有達到想要的結果。
Explanation
此方法名稱與一般的 .NET 方法名稱相似,但它不是存在著拼寫錯誤,就是引數清單導致它無法取代預期的方法。

範例 1:以下方法用於取代 System.Object.Equals()


public boolean Equals(string obj) {
...
}


但是由於 System.Object.Equals() 需要一個 object 類型的引數,因此將永遠不會呼叫此方法。
References
[1] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[2] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2
[3] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[4] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[5] Standards Mapping - Common Weakness Enumeration CWE ID 398
desc.structural.dotnet.code_correctness_misleading_method_signature
Abstract
看起來像是可代替一般的 Java 方法,但實際上卻沒有達到想要的結果。
Explanation
此方法名稱與一般的 Java 方法名稱相似,但它不是存在著拼寫錯誤,就是引數清單導致它無法取代預期的方法。

範例 1:以下方法用於取代 Object.equals()


public boolean equals(Object obj1, Object obj2) {
...
}


但是由於 Object.equals() 只需要一個引數,因此將永遠不會呼叫 Example 1 中的方法。
References
[1] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[2] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2
[3] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[4] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[5] Standards Mapping - Common Weakness Enumeration CWE ID 398
desc.structural.java.code_correctness_misleading_method_signature