界: Code Quality

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

Code Correctness: Erroneous Null Comparison

Abstract
表示式 x = NULLx != NULL 將永遠為 false。
Explanation
在 PL/SQL 中,NULL 的值不確定。此值沒有任何對等的值,甚至也不等於另一個 NULL 值。另外,null 值絕對不會與其他值相等。

範例 1:下列陳述將永遠為 false。


checkNull BOOLEAN := x = NULL;
範例 2:下列陳述將永遠為 false。


checkNotNull BOOLEAN := x != NULL;
References
[1] Steven Feuerstein Oracle PL/SQL Best Practices O'Reilly
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1.0
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 3.0
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[6] Standards Mapping - Common Weakness Enumeration CWE ID 480
desc.structural.sql.code_correctness_erroneous_null_comparison_plsql