You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CWE-1095: show that list modification is dangerous (#940)
Before this commit the wording was that modifying list works but
is not recommended.
But it works as long as no two consecutive elements are deleted,
otherwise part of elements is not checked at all without any
exceptions raised.
Changed README.md, compliant01.py and noncompliant01.py to
demonstrate that.
Signed-off-by: Kyrylo Yatsenko <[email protected]>
Signed-off-by: Helge Wehder <[email protected]>
Copy file name to clipboardExpand all lines: docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/README.md
+13-6Lines changed: 13 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,22 +6,29 @@ In-place modification of mutable types such as `list`, `dict`, or `set` that are
6
6
7
7
## Non-Compliant Code Example (List)
8
8
9
-
This `noncompliant01.py` example will successfully remove the Bob from `userlist` but this modifies the original list `userlist` and is not recommended.
9
+
This `noncompliant01.py` example will remove only one name that starts with `B` despite trying to remove them all without any exception raised:
This `noncompliant02.py` example attempts to delete a dictionary entry, which will result in a `RuntimeError: Dictionary changed size during iteration error` being thrown.
@@ -63,12 +70,12 @@ The `compliant01.py` solution demonstrates both strategies. The first example cr
0 commit comments