结构: Simple
Abstraction: Base
状态: Incomplete
被利用可能性: Low
Duplicate keys in associative lists can lead to non-unique keys being mistaken for an error.
A duplicate key entry -- if the alist is designed properly -- could be used as a constant time replace function. However, duplicate key entries could be inserted by mistake. Because of this ambiguity, duplicate key entries in an association list are not recommended and should not be allowed.
Language: [{'cwe_Name': 'C', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'C++', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'Java', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'C#', 'cwe_Prevalence': 'Undetermined'}]
范围 | 影响 | 注释 |
---|---|---|
Other | ['Quality Degradation', 'Varies by Context'] |
策略:
Use a hash table instead of an alist.
策略:
Use an alist which checks the uniqueness of hash keys with each entry before inserting the entry.
The following code adds data to a list and then attempts to sort the data.
bad Python
Since basename is not necessarily unique, this may not sort how one would like it to be.
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
CLASP | Duplicate key in associative list (alist) | ||
CERT C Secure Coding | ENV02-C | Beware of multiple environment variables with the same effective name |