diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-501/README.md b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0040/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-501/README.md rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0040/README.md index aa1c5d29..a34bf1b0 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-501/README.md +++ b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0040/README.md @@ -1,4 +1,4 @@ -# CWE-501: Trust Boundary Violation +# pyscg-0040: Trust Boundary Violation Python's trust boundaries rely on explicit process isolation, rather than in-process access control within a single interpreter. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-501/compliant01.png b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0040/compliant01.png similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-501/compliant01.png rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0040/compliant01.png diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-501/noncompliant01.png b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0040/noncompliant01.png similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-501/noncompliant01.png rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0040/noncompliant01.png diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-798/README.md b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0041/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-798/README.md rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0041/README.md index 04e9a5f6..113c09ee 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-798/README.md +++ b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0041/README.md @@ -1,4 +1,4 @@ -# CWE-798: Use of hardcoded credentials +# pyscg-0041: Use of hardcoded credentials Ensure that unique keys or secrets can be replaced or rejected at runtime and never hard-code sensitive information, such as passwords, and encryption keys in a component. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-798/compliant01.py b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0041/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-798/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0041/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-798/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0041/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-798/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0041/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-783/README.md b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0042/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-783/README.md rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0042/README.md index 0e6b0bc4..03462cef 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-783/README.md +++ b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0042/README.md @@ -1,4 +1,4 @@ -# CWE-783: Operator Precedence Logic Error +# pyscg-0042: Operator Precedence Logic Error Failing to understand the order of precedence in expressions that read and write to the same object can lead to unintended side effects. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-783/compliant01.py b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0042/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-783/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0042/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-783/example01.py b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0042/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-783/example01.py rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0042/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-783/example02.py b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0042/example02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-783/example02.py rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0042/example02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-783/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0042/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-783/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0042/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-472/README.md b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0055/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-472/README.md rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0055/README.md index 1d834e55..c500bd6c 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-472/README.md +++ b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0055/README.md @@ -1,4 +1,4 @@ -# CWE-472: External Control of Assumed-Immutable Web Parameter +# pyscg-0055: External Control of Assumed-Immutable Web Parameter Ensuring user roles are determined on the server side prevents attackers from manipulating permissions through client-side data. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-472/example01.py b/docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0055/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-472/example01.py rename to docs/Secure-Coding-Guide-for-Python/01_introduction/pyscg-0055/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/README.md b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/README.md rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/README.md index 72efefb7..f70f768d 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/README.md +++ b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/README.md @@ -1,4 +1,4 @@ -# CWE-175: Improper Handling of Mixed Encoding +# pyscg-0043: Improper Handling of Mixed Encoding Locale-dependent programs may produce unexpected behavior or security bypasses in an environment whose locale is unset, or not set to an appropriate value. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/compliant01.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/compliant02.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/example01.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/example01.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/example02.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/example02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/example02.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/example02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/example03.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/example03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/example03.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/example03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-175/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0043/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-180/README.md b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0044/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-180/README.md rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0044/README.md index 9e62ed0f..03cbf425 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-180/README.md +++ b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0044/README.md @@ -1,4 +1,4 @@ -# CWE-180: Incorrect Behavior Order: Validate Before Canonicalize +# pyscg-0044: Incorrect Behavior Order: Validate Before Canonicalize Normalize/canonicalize strings before validating them to prevent risky strings such as `../../../../passwd` allowing directory traversal attacks, and to reduce `XSS` attacks. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-180/compliant01.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0044/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-180/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0044/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-180/example01.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0044/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-180/example01.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0044/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-180/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0044/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-180/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0044/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-182/README.md b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0045/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-182/README.md rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0045/README.md index c729c4c2..04fb732d 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-182/README.md +++ b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0045/README.md @@ -1,4 +1,4 @@ -# CWE-182: Collapse of Data into Unsafe Value +# pyscg-0045: Collapse of Data into Unsafe Value Handling data between different encodings or while filtering out untrusted characters and strings can cause malicious content to slip through input sanitation. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-182/example01.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0045/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-182/example01.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0045/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-838/README.md b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0046/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-838/README.md rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0046/README.md index 7e5dce56..440d0647 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-838/README.md +++ b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0046/README.md @@ -1,4 +1,4 @@ -# CWE-838: Inappropriate Encoding for Output Context +# pyscg-0046: Inappropriate Encoding for Output Context Inappropriate handling of an encoding from untrusted sources or unexpected encoding can lead to unexpected values, data loss, or become the root cause of an attack. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-838/compliant01.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0046/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-838/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0046/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-838/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0046/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-838/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/02_encoding_and_strings/pyscg-0046/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1339/README.md b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0001/README.md similarity index 96% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1339/README.md rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0001/README.md index 3586a513..1bb4c8bb 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1339/README.md +++ b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0001/README.md @@ -1,4 +1,4 @@ -# CWE-1339: Insufficient Precision or Accuracy of a Real Number +# pyscg-0001: Insufficient Precision or Accuracy of a Real Number Avoid floating-point and use integers or the `decimal` module to ensure precision in applications that require high accuracy, such as in financial or banking computations. @@ -110,4 +110,5 @@ print( |:---|:---| |[Bloch 2008]|Item 48, "Avoid `float` and `double` If Exact Answers Are Required"| |[Bloch 2005]|Puzzle 2, "Time for a Change"| + |[IEEE 754]|| diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1339/compliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0001/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1339/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0001/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1339/compliant02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0001/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1339/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0001/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1339/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0001/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1339/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0001/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/README.md b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/README.md rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/README.md index 9f6aa517..e6e60b34 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/README.md +++ b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/README.md @@ -1,4 +1,4 @@ -# CWE-191, Integer Underflow (Wrap or Wraparound) +# pyscg-0002, Integer Underflow (Wrap or Wraparound) Ensure that integer overflow is properly handled in order to avoid unexpected behavior. Python data types can be divided into two categories: diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/compliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/compliant02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/compliant03.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/compliant03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/compliant03.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/compliant03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/noncompliant03.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/noncompliant03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-191/noncompliant03.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0002/noncompliant03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/README.md b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/README.md similarity index 97% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/README.md rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/README.md index 488aa95b..6cb1dd3e 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/README.md +++ b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/README.md @@ -1,4 +1,4 @@ -# CWE-1335: Promote readability and compatibility by using mathematical written code with arithmetic operations instead of bit-wise operations +# pyscg-0003: Promote readability and compatibility by using mathematical written code with arithmetic operations instead of bit-wise operations Avoid using bitwise operations for calculations, write math as math instead to ensure code clarity, compatibility and maintainability. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/compliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/compliant02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/example01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/example01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/example02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/example02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/example02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/example02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/01/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0003/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/README.md b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/README.md rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/README.md index 968a63b1..5ba894f7 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/README.md +++ b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/README.md @@ -1,4 +1,4 @@ -# CWE-197: Numeric Truncation Error +# pyscg-0004: Numeric Truncation Error Ensure to have predictable outcomes in loops by using int instead of `float` variables as a counter. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/compliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/compliant02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/example01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/example01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/example02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/example02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/example02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/example02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0004/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/README.md b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/README.md rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/README.md index bb06fc46..e1979645 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/README.md +++ b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/README.md @@ -1,4 +1,4 @@ -# CWE-197: Control rounding when converting to less precise numbers +# pyscg-0005: Control rounding when converting to less precise numbers While defensive coding requires enforcing types, it is important to make conscious design decisions on how conversions are rounded. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/compliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/compliant02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/example01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/example01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/example02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/example02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/example02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/example02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0005/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/README.md b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0006/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/README.md rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0006/README.md index dc86d489..9230bd72 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/README.md +++ b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0006/README.md @@ -1,4 +1,4 @@ -# CWE-681: Incorrect Conversion between Numeric Types +# pyscg-0006: Incorrect Conversion between Numeric Types String representations of floating-point numbers must not be compared or inspected outside of specialized modules such as `decimal` or `math`. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/compliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0006/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0006/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0006/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0006/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/01/README.md b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0007/README.md similarity index 94% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/01/README.md rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0007/README.md index 503acef0..05f8067e 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/01/README.md +++ b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0007/README.md @@ -1,4 +1,4 @@ -# CWE-681: Avoid an uncontrolled loss of precision when passing floating-point literals to a Decimal constructor +# pyscg-0007: Avoid an uncontrolled loss of precision when passing floating-point literals to a Decimal constructor When working with decimal numbers in Python, using floating-point literals as input to the `Decimal` constructor can lead to unintended imprecision due to the limitations of `IEEE 754` [Wikipedia 2025](https://en.wikipedia.org/wiki/IEEE_754) floating-point representation; therefore, to ensure accurate decimal representation, it is advisable to avoid using floating-point literals. @@ -50,4 +50,5 @@ print(Decimal("0.45")) ||| |:---|:---| |[Wikipedia 2025](https://en.wikipedia.org)|IEEE 754 [online]. Available from: [https://en.wikipedia.org/wiki/IEEE_754](https://en.wikipedia.org/wiki/IEEE_754)| + |[Python docs](https://docs.python.org/3/)|decimal — Decimal fixed-point and floating-point arithmetic [online]. Available from: [https://docs.python.org/3/library/decimal.html](https://docs.python.org/3/library/decimal.html) [accessed 2 February 2025]| diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/01/compliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0007/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/01/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0007/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/01/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0007/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-681/01/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0007/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/README.md b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0053/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/README.md rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0053/README.md index d35a4839..7a2894d1 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/README.md +++ b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0053/README.md @@ -1,4 +1,4 @@ -# CWE-1335: Incorrect Bitwise Shift of Integer +# pyscg-0053: Incorrect Bitwise Shift of Integer Avoid mixing bitwise shifts with arithmetic operations, instead, use clear mathematical expressions instead to maintain predictable behavior, readability, and compatibility. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/example01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0053/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/example01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0053/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/example02.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0053/example02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/example02.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0053/example02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/example03.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0053/example03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/example03.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0053/example03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0053/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-682/CWE-1335/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/03_numbers/pyscg-0053/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-134/README.md b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0008/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-134/README.md rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0008/README.md index 79454c64..1bee193e 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-134/README.md +++ b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0008/README.md @@ -1,4 +1,4 @@ -# CWE-134: Use of Externally-Controlled Format String +# pyscg-0008: Use of Externally-Controlled Format String Ensure that all format string functions are passed a static string which cannot be controlled by the user [[MITRE 2023]](https://cwe.mitre.org/data/definitions/134.html) diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-134/compliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0008/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-134/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0008/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-134/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0008/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-134/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0008/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-78/README.md b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0009/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-78/README.md rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0009/README.md index bd2ccf8c..0f168e19 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-78/README.md +++ b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0009/README.md @@ -1,4 +1,4 @@ -# CWE-78: Improper Neutralization of Special Elements Used in an OS Command ("OS Command Injection") +# pyscg-0009: Improper Neutralization of Special Elements Used in an OS Command ("OS Command Injection") Avoid input from untrusted sources to be used directly as part of an OS command and use specialized Python modules where possible instead. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-78/compliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0009/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-78/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0009/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-78/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0009/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-78/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0009/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-78/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0009/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-78/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0009/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-89/README.md b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0010/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-89/README.md rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0010/README.md index da69d878..eb39c8c5 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-89/README.md +++ b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0010/README.md @@ -1,4 +1,4 @@ -# CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') +# pyscg-0010: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') To prevent SQL injections, use input sanitization and parameterized queries instead of `executescript()`. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-89/compliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0010/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-89/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0010/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-89/image01.webp b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0010/image01.webp similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-89/image01.webp rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0010/image01.webp diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-89/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0010/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-89/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0010/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-843/README.md b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0011/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-843/README.md rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0011/README.md index e5e3f2ad..6367194b 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-843/README.md +++ b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0011/README.md @@ -1,4 +1,4 @@ -# CWE-843: Access of Resource Using Incompatible Type ('Type Confusion') +# pyscg-0011: Access of Resource Using Incompatible Type ('Type Confusion') When operating on unsigned values coming from external sources, such as `C` or `C++` applications, they should be unpacked using variable types that can represent their entire value range. This rule is related to [CWE-197: Control rounding when converting to less precise numbers](https://github.com/ossf/wg-best-practices-os-developers/blob/main/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-197/01/README.md). diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-843/compliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0011/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-843/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0011/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-843/example01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0011/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-843/example01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0011/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-843/image01.png b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0011/image01.png similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-843/image01.png rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0011/image01.png diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-843/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0011/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-843/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0011/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-409/README.md b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0012/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-409/README.md rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0012/README.md index 446e7f5a..eddef7fa 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-409/README.md +++ b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0012/README.md @@ -1,4 +1,4 @@ -# CWE-409: Improper Handling of Highly Compressed Data (Data Amplification) +# pyscg-0012: Improper Handling of Highly Compressed Data (Data Amplification) Prevent slip and bomb attacks when decompressing and unpacking compressed data such as `ZIP`, `TAR.GZ`, `JAR`, `WAR`, `RPM` or `DOCX`. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-409/compliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0012/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-409/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0012/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-409/example01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0012/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-409/example01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0012/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-409/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0012/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-409/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0012/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-409/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0012/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-409/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0012/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-426/README.md b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0013/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-426/README.md rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0013/README.md index b4e67387..d485a263 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-426/README.md +++ b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0013/README.md @@ -1,4 +1,4 @@ -# CWE-426: Untrusted Search Path +# pyscg-0013: Untrusted Search Path In an environment where an untrusted or less trusted entity can modify the environment variables, consider validating hash-based byte code [Python 2023 Command line and environment]. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-426/compliant01.bash b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0013/compliant01.bash similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-426/compliant01.bash rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0013/compliant01.bash diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-426/example01.bash b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0013/example01.bash similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-426/example01.bash rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0013/example01.bash diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-426/noncompliant01.bash b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0013/noncompliant01.bash similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-426/noncompliant01.bash rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0013/noncompliant01.bash diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-184/README.md b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0184/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-184/README.md rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0184/README.md index 33aa7879..f1dbd67d 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-184/README.md +++ b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0184/README.md @@ -1,4 +1,4 @@ -# CWE-184: Incomplete List of Disallowed Input +# pyscg-0184: Incomplete List of Disallowed Input Avoid Incomplete 'deny lists' that can lead to security vulnerabilities such as cross-site scripting (XSS) by using 'allow lists' instead. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-184/compliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0184/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-184/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0184/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-184/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0184/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-184/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/04_neutralization/pyscg-0184/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-397/README.md b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0014/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-397/README.md rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0014/README.md index 2cbc1896..f9c58b9e 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-397/README.md +++ b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0014/README.md @@ -1,4 +1,4 @@ -# CWE-397: Declaration of Throws for Generic Exception +# pyscg-0014: Declaration of Throws for Generic Exception Avoid raising exceptions that aren't informative on specific errors. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-397/compliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0014/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-397/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0014/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-397/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0014/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-397/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0014/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/README.md b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/README.md rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/README.md index 194a7bfe..c03df0a2 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/README.md +++ b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/README.md @@ -1,4 +1,4 @@ -# CWE-755: Improper Handling of Exceptional Conditions +# pyscg-0015: Improper Handling of Exceptional Conditions Always catch and explicitly handle exceptions, then respond, log or recover appropriately instead of letting operations fail silently. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/compliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/compliant02.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/noncompliant03.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/noncompliant03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-755/noncompliant03.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0015/noncompliant03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-390/README.md b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0016/README.md similarity index 97% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-390/README.md rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0016/README.md index c93bea7a..6cf2bb33 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-390/README.md +++ b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0016/README.md @@ -1,4 +1,4 @@ -# CWE-390: Detection of Error Condition without Action +# pyscg-0016: Detection of Error Condition without Action Allow exceptions to bubble up and handle exceptions at the right level in the stack. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-390/compliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0016/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-390/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0016/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-390/example01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0016/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-390/example01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0016/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-390/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0016/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-390/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0016/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-230/README.md b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0017/README.md similarity index 96% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-230/README.md rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0017/README.md index 29b70a87..73d320f9 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-230/README.md +++ b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0017/README.md @@ -1,4 +1,4 @@ -# CWE-230: Improper Handling of Missing Values +# pyscg-0017: Improper Handling of Missing Values Detect and handle missing numberic values explicitly, either by removing, validating or converting them, before performing comparisons, sorting, or statistics, in order to avoid surprising or undefined behaviour. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-230/compliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0017/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-230/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0017/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-230/compliants02.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0017/compliants02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-230/compliants02.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0017/compliants02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-230/example01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0017/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-230/example01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0017/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-230/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0017/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-230/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0017/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-754/README.md b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0018/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-754/README.md rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0018/README.md index 6b04df50..cb1c27f7 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-754/README.md +++ b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0018/README.md @@ -1,4 +1,4 @@ -# CWE-754: Improper Check for Unusual or Exceptional Conditions - Float +# pyscg-0018: Improper Check for Unusual or Exceptional Conditions - Float Ensure to have handling for exceptional floating-point values. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-754/compliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0018/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-754/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0018/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-754/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0018/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-754/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0018/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-460/README.md b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0052/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-460/README.md rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0052/README.md index 634ce098..e5faf301 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-460/README.md +++ b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0052/README.md @@ -1,5 +1,4 @@ - -# CWE-460: Improper Cleanup on Thrown Exception +# pyscg-0052: Improper Cleanup on Thrown Exception Make sure that your code fully and correctly cleans up its state whenever an exception occurs to avoid unexpected state or control flow. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-460/compliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0052/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-460/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0052/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-460/example01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0052/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-460/example01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0052/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-460/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0052/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-460/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/05_exception_handling/pyscg-0052/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/README.md b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/README.md rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/README.md index 41319551..c78b54c1 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/README.md +++ b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/README.md @@ -1,4 +1,4 @@ -# CWE-532: Insertion of Sensitive Information into Log File +# pyscg-0019: Insertion of Sensitive Information into Log File Do not log any sensitive information such as passwords or credit card numbers. Encrypt or anonymize personal information such as user names, and date of birth in plain text. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/compliant01.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/compliant02.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/example01.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/example01.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-532/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0019/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-778/README.md b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0020/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-778/README.md rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0020/README.md index 882455d9..c11460e9 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-778/README.md +++ b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0020/README.md @@ -1,4 +1,4 @@ -# CWE-778: Insufficient Logging +# pyscg-0020: Insufficient Logging Ensure you have sufficient logging in order to adequately record important events within an application and/or system. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-778/compliant01.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0020/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-778/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0020/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-778/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0020/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-778/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0020/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-489/README.md b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0021/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-489/README.md rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0021/README.md index 6b63543a..790c117d 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-489/README.md +++ b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0021/README.md @@ -1,4 +1,4 @@ -# CWE-489: Active Debug Code +# pyscg-0021: Active Debug Code Keep design tooling in separate packages from the actual product and supply useful logging. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-117/README.md b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0022/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-117/README.md rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0022/README.md index 974f3dcc..c7526034 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-117/README.md +++ b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0022/README.md @@ -1,4 +1,4 @@ -# CWE-117: Improper Output Neutralization for Logs +# pyscg-0022: Improper Output Neutralization for Logs Ensure all untrusted data is properly neutralized or sanitized before writing to application logs. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-117/compliant01.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0022/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-117/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0022/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-117/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0022/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-707/CWE-117/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0022/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-209/README.md b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0050/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-209/README.md rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0050/README.md index 9b722db6..ecede0f7 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-209/README.md +++ b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0050/README.md @@ -1,4 +1,4 @@ -# CWE-209: Generation of Error Message Containing Sensitive Information +# pyscg-0050: Generation of Error Message Containing Sensitive Information Prevent an attacker from discovering internal or sensitive system information by filtering, splitting and applying brute force prevention tactics when displaying error messages to a user. This rule is closely related to [CWE-532: Insertion of Sensitive Information into Log File](../CWE-532/README.md). diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-209/compliant01.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0050/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-209/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0050/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-209/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0050/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-209/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0050/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-209/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0050/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-209/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0050/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-209/noncompliant03.py b/docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0050/noncompliant03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-209/noncompliant03.py rename to docs/Secure-Coding-Guide-for-Python/06_logging/pyscg-0050/noncompliant03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-502/README.md b/docs/Secure-Coding-Guide-for-Python/07_serialization_deserialization/pyscg-0023/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-502/README.md rename to docs/Secure-Coding-Guide-for-Python/07_serialization_deserialization/pyscg-0023/README.md index fb2e50bc..e239fc7b 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-502/README.md +++ b/docs/Secure-Coding-Guide-for-Python/07_serialization_deserialization/pyscg-0023/README.md @@ -1,4 +1,4 @@ -# CWE-502: Deserialization of Untrusted Data +# pyscg-0023: Deserialization of Untrusted Data Even if data has been created from a trusted source, we need to verify that it has not been tampered with during transport. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-502/compliant01.py b/docs/Secure-Coding-Guide-for-Python/07_serialization_deserialization/pyscg-0023/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-502/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/07_serialization_deserialization/pyscg-0023/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-502/example01.py b/docs/Secure-Coding-Guide-for-Python/07_serialization_deserialization/pyscg-0023/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-502/example01.py rename to docs/Secure-Coding-Guide-for-Python/07_serialization_deserialization/pyscg-0023/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-502/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/07_serialization_deserialization/pyscg-0023/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-502/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/07_serialization_deserialization/pyscg-0023/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/compliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/compliant02.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/example01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/example01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/image01.png b/docs/Secure-Coding-Guide-for-Python/08_concurrency/image01.png similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/image01.png rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/image01.png diff --git a/docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/image02.png b/docs/Secure-Coding-Guide-for-Python/08_concurrency/image02.png similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/image02.png rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/image02.png diff --git a/docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/noncompliant03.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/noncompliant03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/noncompliant03.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/noncompliant03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-400/README.md b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0024/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-400/README.md rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0024/README.md index 2ca8035a..f2548e4e 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-400/README.md +++ b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0024/README.md @@ -1,4 +1,4 @@ -# CWE-400: Uncontrolled Resource Consumption +# pyscg-0024: Uncontrolled Resource Consumption Canceling the task in a thread pool only prevents it from being executed if it has not started yet. For the task to be interruptible, it must handle the `threading.Event` flag. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-400/compliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0024/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-400/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0024/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-400/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0024/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-400/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0024/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-410/README.md b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0025/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-410/README.md rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0025/README.md index b773f2a2..dff0fff6 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-410/README.md +++ b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0025/README.md @@ -1,4 +1,4 @@ -# CWE-410: Insufficient Resource Pool +# pyscg-0025: Insufficient Resource Pool Ensure load control during traffic bursts or Denial of Service (DoS) by using a limited amount of threads in a pool. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-410/compliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0025/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-410/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0025/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-410/compliant02.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0025/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-410/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0025/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-410/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0025/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-410/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0025/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-410/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0025/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-410/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0025/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-833/README.md b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0026/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-833/README.md rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0026/README.md index 8039d989..79f2a8ff 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-833/README.md +++ b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0026/README.md @@ -1,4 +1,4 @@ -# CWE-833: Deadlock +# pyscg-0026: Deadlock Submitting tasks whose execution is dependent on other tasks submitted to the same `ThreadPoolExecutor` may result in a *thread-starvation* deadlock. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-833/compliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0026/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-833/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0026/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-833/compliant02.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0026/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-833/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0026/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-833/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0026/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-833/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0026/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-833/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0026/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-833/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0026/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-362/README.md b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0027/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-362/README.md rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0027/README.md index 2f24c6df..403b70ac 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-362/README.md +++ b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0027/README.md @@ -1,4 +1,4 @@ -# CWE-362: Concurrent Execution Using Shared Resource with Improper Synchronization ("Race Condition") +# pyscg-0027: Concurrent Execution Using Shared Resource with Improper Synchronization ("Race Condition") Ensure to implement locking mechanisms when chaining methods in a multithreaded environment to prevent unexpected results. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-362/compliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0027/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-362/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0027/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-362/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0027/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-362/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0027/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-584/README.md b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0028/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-584/README.md rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0028/README.md index 064fdb91..e5deb072 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-584/README.md +++ b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0028/README.md @@ -1,4 +1,4 @@ -# CWE-584: Return Inside Finally Block +# pyscg-0028: Return Inside Finally Block Do not use `return`, `break` or `continue` statements in a try-finally block, as the exception will not be processed. The Python documentation [[Python 3.9]](https://docs.python.org/3.9/reference/compound_stmts.html#finally) notes, "If the `finally` clause executes a [`return`](https://docs.python.org/3.9/reference/simple_stmts.html#return), [`break`](https://docs.python.org/3.9/reference/simple_stmts.html#break) or [`continue`](https://docs.python.org/3.9/reference/simple_stmts.html#continue) statement, the saved exception is discarded." diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-584/compliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0028/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-584/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0028/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-584/compliant02.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0028/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-584/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0028/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-584/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0028/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-584/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0028/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-665/README.md b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0029/README.md similarity index 97% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-665/README.md rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0029/README.md index 98fcde07..890d4970 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-665/README.md +++ b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0029/README.md @@ -1,4 +1,4 @@ -# CWE-665: Improper Initialization +# pyscg-0029: Improper Initialization Prevent unexpected states by applying correct initialized of local objects as they remain available when a thread's resources are re-used in a thread-pool. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-665/compliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0029/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-665/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0029/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-665/compliant02.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0029/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-665/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0029/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-665/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0029/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-665/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0029/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-665/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0029/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-665/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0029/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/README.md b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/README.md rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/README.md index 6f686b29..18266072 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/README.md +++ b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/README.md @@ -1,4 +1,4 @@ -# CWE-392: Missing Report of Error Condition +# pyscg-0030: Missing Report of Error Condition Failure to provide a mechanism for reporting that tasks in a thread pool failed as a result of an exceptional condition can make it difficult or impossible to diagnose the problem. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/compliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/compliant02.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/compliant03.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/compliant03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/compliant03.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/compliant03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/compliant04.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/compliant04.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/compliant04.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/compliant04.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-392/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0030/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-404/README.md b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0051/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-404/README.md rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0051/README.md index 9810a30d..d2d56d6c 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-404/README.md +++ b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0051/README.md @@ -1,4 +1,4 @@ -# CWE-404: Improper Resource Shutdown or Release +# pyscg-0051: Improper Resource Shutdown or Release Always close resources explicitly and ensure proper cleanup even if an error occurs. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-404/compliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0051/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-404/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0051/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-404/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0051/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-404/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0051/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-366/README.md b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0054/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-366/README.md rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0054/README.md index aae493f7..6fc91b97 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-366/README.md +++ b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0054/README.md @@ -1,4 +1,4 @@ -# CWE-366: Race Condition within a Thread +# pyscg-0054: Race Condition within a Thread In multithreaded programming, use synchronization mechanisms, such as locks, to avoid race conditions, which occur when multiple threads access shared resources simultaneously and lead to unpredictable results. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-366/compliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0054/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-366/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0054/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-366/example01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0054/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-366/example01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0054/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-366/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0054/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-366/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/pyscg-0054/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/readme.md b/docs/Secure-Coding-Guide-for-Python/08_concurrency/readme.md similarity index 94% rename from docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/readme.md rename to docs/Secure-Coding-Guide-for-Python/08_concurrency/readme.md index 87aba963..66e72a82 100644 --- a/docs/Secure-Coding-Guide-for-Python/Intro_to_multiprocessing_and_multithreading/readme.md +++ b/docs/Secure-Coding-Guide-for-Python/08_concurrency/readme.md @@ -2,12 +2,15 @@ This page aims to explain the concepts that could be found in the following rules: -- [CWE-410: Insufficient Resource Pool](../CWE-664/CWE-410/README.md) -- [CWE-833: Deadlock](../CWE-664/CWE-833/README.md) -- [CWE-400: Uncontrolled Resource Consumption](../CWE-664/CWE-400/README.md) -- [CWE-392: Missing Report of Error Condition](../CWE-703/CWE-392/README.md) -- [CWE-665: Improper Initialization](../CWE-664/CWE-665/README.md) -- [CWE-366: Race Condition within a Thread](../CWE-691/CWE-366/README.md) +- [pyscg-0025: Insufficient Resource Pool](pyscg-0025/README.md) +- [pyscg-0026: Deadlock](pyscg-0026/README.md) +- [pyscg-0024: Uncontrolled Resource Consumption](pyscg-0024/README.md) +- [pyscg-0027: Concurrent Execution Using Shared Resource with Improper Synchronization (Race Condition)](pyscg-0027/README.md) +- [pyscg-0028: Return Inside Finally Block](pyscg-0028/README.md) +- [pyscg-0030: Missing Report of Error Condition](pyscg-0030/README.md) +- [pyscg-0029: Improper Initialization](pyscg-0029/README.md) +- [pyscg-0051: Improper Resource Shutdown or Release](pyscg-0051/README.md) +- [pyscg-0054: Race Condition within a Thread](pyscg-0054/README.md) ## What is Multithreading in Python - Multithreading vs Multiprocessing diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/README.md b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/README.md similarity index 96% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/README.md rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/README.md index 6c23351f..ddd53a3a 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/README.md +++ b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/README.md @@ -1,4 +1,4 @@ -# CWE-1095: Loop Condition Value Update within the Loop +# pyscg-0031: Loop Condition Value Update within the Loop Promote predictable and secure `for` loops by iterating over a copy or new collection item as described in 4.2 `for` Statements [Python 3.9 2024](https://docs.python.org/3.9/tutorial/controlflow.html#for-statements). diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/compliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/compliant02.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/compliant03.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/compliant03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/compliant03.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/compliant03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/noncompliant03.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/noncompliant03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1095/noncompliant03.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0031/noncompliant03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1109/README.md b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0032/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1109/README.md rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0032/README.md index e121eaf8..04d99f94 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1109/README.md +++ b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0032/README.md @@ -1,4 +1,4 @@ -# CWE-1109: Use of Same Variable for Multiple Purposes +# pyscg-0032: Use of Same Variable for Multiple Purposes Avoid reusing names of variables, functions, classes, built-in functions, packages, or standard Python modules diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1109/compliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0032/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1109/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0032/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1109/compliant02.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0032/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1109/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0032/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1109/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0032/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1109/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0032/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1109/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0032/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-710/CWE-1109/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0032/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-697/CWE-595/README.md b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0033/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-697/CWE-595/README.md rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0033/README.md index af5c7fa8..19b24b97 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-697/CWE-595/README.md +++ b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0033/README.md @@ -1,4 +1,4 @@ -# CWE-595: Comparison of Object References Instead of Object Contents +# pyscg-0033: Comparison of Object References Instead of Object Contents Prevent unexpected results by knowing the differences between comparison operators such as `==` and `is`. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-697/CWE-595/compliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0033/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-697/CWE-595/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0033/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-697/CWE-595/example01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0033/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-697/CWE-595/example01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0033/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-697/CWE-595/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0033/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-697/CWE-595/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0033/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/README.md b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/README.md rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/README.md index dc6339b9..26280d40 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/README.md +++ b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/README.md @@ -1,4 +1,4 @@ -# CWE-476: NULL Pointer Dereference +# pyscg-0034: NULL Pointer Dereference Avoiding NULL Pointer Dereference is crucial for preventing runtime errors, and ensuring that your code executes successfully. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/compliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/compliant02.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/compliant03.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/compliant03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/compliant03.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/compliant03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/noncompliant03.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/noncompliant03.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-476/noncompliant03.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0034/noncompliant03.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-459/README.md b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0035/README.md similarity index 97% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-459/README.md rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0035/README.md index 21ac6a8a..c6ecfcba 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-459/README.md +++ b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0035/README.md @@ -1,4 +1,4 @@ -# CWE-459: Incomplete Cleanup +# pyscg-0035: Incomplete Cleanup Leftover temporary files not properly cleaned up after the completion of any script, can lead to resource exhaustion and disable a service. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-459/compliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0035/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-459/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0035/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-459/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0035/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-459/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0035/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-459/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0035/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-664/CWE-459/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0035/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-252/README.md b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0036/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-252/README.md rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0036/README.md index 1ee26926..731bf344 100755 --- a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-252/README.md +++ b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0036/README.md @@ -1,4 +1,4 @@ -# CWE-252: Unchecked Return Value +# pyscg-0036: Unchecked Return Value Return values of methods and functions should always be checked to ensure operations have been performed correctly. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-252/compliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0036/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-252/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0036/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-252/compliant02.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0036/compliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-252/compliant02.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0036/compliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-252/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0036/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-252/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0036/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-252/noncompliant02.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0036/noncompliant02.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-252/noncompliant02.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0036/noncompliant02.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-617/README.md b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0037/README.md similarity index 99% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-617/README.md rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0037/README.md index 0b1cbbca..530d781a 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-617/README.md +++ b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0037/README.md @@ -1,4 +1,4 @@ -# CWE-617: Reachable Assertion +# pyscg-0037: Reachable Assertion Assertions are a useful developer tool, but they cannot be relied upon to be present in a production environment. Incorrect function arguments should be handled by an appropriate exception. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-617/compliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0037/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-617/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0037/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-617/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0037/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-691/CWE-617/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/09_coding_standards/pyscg-0037/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-330/README.md b/docs/Secure-Coding-Guide-for-Python/10_cryptography/pyscg-0038/README.md similarity index 98% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-330/README.md rename to docs/Secure-Coding-Guide-for-Python/10_cryptography/pyscg-0038/README.md index 1ee5dcb6..041af68e 100644 --- a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-330/README.md +++ b/docs/Secure-Coding-Guide-for-Python/10_cryptography/pyscg-0038/README.md @@ -1,4 +1,4 @@ -# CWE-330: Use of Insufficiently Random Values +# pyscg-0038: Use of Insufficiently Random Values When programming cryptographic functions ensure to use a Pseudo-Random Number Generator (PRNG) source that is random enough to be suitable for encryption. diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-330/compliant01.py b/docs/Secure-Coding-Guide-for-Python/10_cryptography/pyscg-0038/compliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-330/compliant01.py rename to docs/Secure-Coding-Guide-for-Python/10_cryptography/pyscg-0038/compliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-330/example01.py b/docs/Secure-Coding-Guide-for-Python/10_cryptography/pyscg-0038/example01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-330/example01.py rename to docs/Secure-Coding-Guide-for-Python/10_cryptography/pyscg-0038/example01.py diff --git a/docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-330/noncompliant01.py b/docs/Secure-Coding-Guide-for-Python/10_cryptography/pyscg-0038/noncompliant01.py similarity index 100% rename from docs/Secure-Coding-Guide-for-Python/CWE-693/CWE-330/noncompliant01.py rename to docs/Secure-Coding-Guide-for-Python/10_cryptography/pyscg-0038/noncompliant01.py diff --git a/docs/Secure-Coding-Guide-for-Python/readme.md b/docs/Secure-Coding-Guide-for-Python/readme.md index 3b18f4c6..0b93d439 100644 --- a/docs/Secure-Coding-Guide-for-Python/readme.md +++ b/docs/Secure-Coding-Guide-for-Python/readme.md @@ -9,7 +9,6 @@ An initiative by the OpenSSF to provide new Python programmers a resource to stu Documentation is written in academic style to support security researchers while using plain English to cater for an international audience. Python modules outside of the _Python Module Index_ [[Python 2023](https://docs.python.org/3.9/py-modindex.html)] are specifically not covered by this document. -The structure is based on Common Weakness Enumeration (CWE) _Pillar Weakness_ [[MITRE Pillar 2024](https://cwe.mitre.org/documents/glossary/#Pillar%20Weakness)]. Please join us, see [contributing](CONTRIBUTING.md) @@ -24,7 +23,7 @@ Code examples are NOT to be used to cause harm of any kind to anyone or anything Every person writing code shall study the following: * _OWASP Developer Guide_ [[OWASP dev 2024](https://owasp.org/www-project-developer-guide/release/)] -* _OWASP Top 10 Report_ [[OWASP 2021](https://owasp.org/www-project-top-ten/)] +* _OWASP Top 10 Report_ [[OWASP 2021](https://owasp.org/Top10/A00_2021_Introduction/)] * _CWE Top 25_ [[MITRE 2024](https://cwe.mitre.org/top25/index.html)] ## Secure Coding Standard for Python @@ -46,81 +45,170 @@ It is __not production code__ and requires code-style or python best practices t * Proper logging instead of printing to `stdout` * Secure coding compliance outside of described issue -|[CWE-664: Improper Control of a Resource Through its Lifetime](https://cwe.mitre.org/data/definitions/664.html)|Prominent CVE| -|:-----------------------------------------------------------------------------------------------------------------------------------------------|:----| -|[CWE-134: Use of Externally-Controlled Format String](CWE-664/CWE-134/README.md)|[CVE-2022-27177](https://www.cvedetails.com/cve/CVE-2022-27177/),
CVSSv3.1: __9.8__,
EPSS: __00.37__ (01.12.2023)| -|[CWE-197: Numeric Truncation Error](CWE-664/CWE-197/README.md)|| -|[CWE-197: Control rounding when converting to less precise numbers](CWE-664/CWE-197/01/README.md)|| -|[CWE-209: Generation of Error Message Containing Sensitive Information](CWE-664/CWE-209/README.md)|[CVE-2013-0773](https://www.cvedetails.com/cve/CVE-2013-0773/),
CVSSv3.1:__3.3__,
EPSS: __00.95__ (23.11.2023)| -|[CWE-400: Uncontrolled Resource Consumption](CWE-664/CWE-400/README.md)|| -|[CWE-404: Improper Resource Shutdown or Release](CWE-664/CWE-404/README.md)|| -|[CWE-409: Improper Handling of Highly Compressed Data (Data Amplification)](CWE-664/CWE-409/README.md)|| -|[CWE-410: Insufficient Resource Pool](CWE-664/CWE-410/README.md)|| -|[CWE-426: Untrusted Search Path](CWE-664/CWE-426/README.md)|[CVE-2015-1326](https://www.cvedetails.com/cve/CVE-2015-1326),
CVSSv3.0: __8.8__,
EPSS: __00.20__ (23.11.2023)| -|[CWE-459: Incomplete Cleanup](CWE-664/CWE-459/README.md)|| -|[CWE-460: Improper Cleanup on Thrown Exception](CWE-664/CWE-460/README.md)|[CVE-2008-0002](https://www.cvedetails.com/cve/CVE-2008-0002),
CVSSv3.1: __5.8__,
EPSS: __04.10__ (04.09.2025)| -|[CWE-501: Trust Boundary Violation)](CWE-664/CWE-501/README.md)|[CVE-2023-28597](https://www.cvedetails.com/cve/CVE-2023-28597),
CVSSv3.0: __7.5__,
EPSS: __00.11__ (05.11.2024)| -|[CWE-502: Deserialization of Untrusted Data)](CWE-664/CWE-502/.)|[CVE-2018-8021](https://www.cvedetails.com/cve/CVE-2018-8021),
CVSSv3.0: __9.8__,
EPSS: __93.54__ (05.11.2024)| -|[CWE-532: Insertion of Sensitive Information into Log File](CWE-664/CWE-532/README.md)|[CVE-2023-45585](https://www.cvedetails.com/cve/CVE-2023-45585),
CVSSv3.1: __9.8__,
EPSS: __0.04__ (01.11.2024)| -|[CWE-584: Return Inside Finally Block](CWE-664/CWE-584/README.md)|| -|[CWE-665: Improper Initialization](CWE-664/CWE-665/README.md)|| -|[CWE-681: Incorrect Conversion between Numeric Types](CWE-664/CWE-681/README.md)|| -|[CWE-681: Avoid an uncontrolled loss of precision when passing floating-point literals to a Decimal constructor.](CWE-664/CWE-681/01/README.md)|| -|[CWE-833: Deadlock](CWE-664/CWE-833/README.md)|| -|[CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')](CWE-664/CWE-843/README.md)|[CVE-2021-29513](https://www.cvedetails.com/cve/CVE-2021-29513),
CVSSv3.1: __7.8__,
EPSS: __00.02__ (13.05.2025)| - -|[CWE-682: Incorrect Calculation](https://cwe.mitre.org/data/definitions/682.html)|Prominent CVE| -|:---------------------------------------------------------------------------------------------------------------|:----| -|[CWE-191: Integer Underflow (Wrap or Wraparound)](CWE-682/CWE-191/README.md)|| -|[CWE-1335: Incorrect Bitwise Shift of Integer](CWE-682/CWE-1335/README.md)|| -|[CWE-1335: Promote readability and compatibility by using mathematical written code with arithmetic operations instead of bit-wise operations](CWE-682/CWE-1335/01/README.md)|| -|[CWE-1339: Insufficient Precision or Accuracy of a Real Number](CWE-682/CWE-1339/.) || - -|[CWE-691: Insufficient Control Flow Management](https://cwe.mitre.org/data/definitions/691.html)|Prominent CVE| -|:---------------------------------------------------------------------------------------------------------------|:----| -|[CWE-366: Race Condition within a Thread](CWE-691/CWE-366/README.md)|| -|[CWE-362: Concurrent Execution Using Shared Resource with Improper Synchronization ("Race Condition")](CWE-691/CWE-362/README.md)|| -|[CWE-617: Reachable Assertion](CWE-691/CWE-617/README.md)|| -|[CWE-783: Operator Precedence Logic Error](CWE-691/CWE-783/README.md)|| - -|[CWE-693: Protection Mechanism Failure](https://cwe.mitre.org/data/definitions/693.html)|Prominent CVE| -|:---------------------------------------------------------------------------------------------------------------|:----| -|[CWE-182: Collapse of Data into Unsafe Value](CWE-693/CWE-182/README.md)|| -|[CWE-184: Incomplete List of Disallowed Input](CWE-693/CWE-184/README.md)|| -|[CWE-330: Use of Insufficiently Random Values](CWE-693/CWE-330/README.md)|[CVE-2020-7548](https://www.cvedetails.com/cve/CVE-2020-7548),
CVSSv3.1: __9.8__,
EPSS: __0.22__ (12.12.2024)| -|[CWE-472: External Control of Assumed-Immutable Web Parameter](CWE-693/CWE-472/README.md)|| -|[CWE-778: Insufficient Logging](CWE-693/CWE-778/README.md)|| -|[CWE-798: Use of hardcoded credentials](CWE-693/CWE-798/README.md)|| - -|[CWE-697: Incorrect Comparison](https://cwe.mitre.org/data/definitions/697.html)|Prominent CVE| -|:----------------------------------------------------------------|:----| -|[CWE-595: Comparison of Object References Instead of Object Contents](CWE-697/CWE-595/README.md)|| - -|[CWE-703: Improper Check or Handling of Exceptional Conditions](https://cwe.mitre.org/data/definitions/703.html)|Prominent CVE| -|:----------------------------------------------------------------|:----| -|[CWE-230: Improper Handling of Missing Values](CWE-703/CWE-230/.)|| -|[CWE-252: Unchecked Return Value](CWE-703/CWE-252/README.md)|| -|[CWE-390: Detection of Error Condition without Action](CWE-703/CWE-390/README.md)|| -|[CWE-392: Missing Report of Error Condition](CWE-703/CWE-392/README.md)|| -|[CWE-397: Declaration of Throws for Generic Exception](CWE-703/CWE-397/README.md)|| -|[CWE-476: NULL Pointer Dereference](CWE-703/CWE-476/README.md)|| -|[CWE-754: Improper Check for Unusual or Exceptional Conditions - float](CWE-703/CWE-754/README.md)|| -|[CWE-755: Improper Handling of Exceptional Conditions](CWE-703/CWE-755/README.md)|[CVE-2024-39560](https://www.cvedetails.com/cve/CVE-2024-39560),
CVSSv3.1: __6.5__,
EPSS: __0.04__ (01.11.2024)| - -|[CWE-707: Improper Neutralization](https://cwe.mitre.org/data/definitions/707.html)|Prominent CVE| -|:----------------------------------------------------------------|:----| -|[CWE-78: Improper Neutralization of Special Elements Used in an OS Command ("OS Command Injection")](CWE-707/CWE-78/README.md)|[CVE-2024-43804](https://www.cvedetails.com/cve/CVE-2024-43804/),
CVSSv3.1: __8.8__,
EPSS: __00.06__ (08.11.2024)| -|[CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')](CWE-707/CWE-89/README.md)|[CVE-2019-8600](https://www.cvedetails.com/cve/CVE-2019-8600/),
CVSSv3.1: __9.8__,
EPSS: __01.43__ (18.02.2024)| -|[CWE-117: Improper Output Neutralization for Logs](CWE-707/CWE-117/README.md)|| -|[CWE-175: Improper Handling of Mixed Encoding](CWE-707/CWE-175/README.md)|| -|[CWE-180: Incorrect behavior order: Validate before Canonicalize](CWE-707/CWE-180/README.md)|[CVE-2022-26136](https://www.cvedetails.com/cve/CVE-2022-26136/),
CVSSv3.1: __9.8__,
EPSS: __00.18__ (24.04.2025)| -|[CWE-838: Inappropriate Encoding for Output Context](CWE-707/CWE-838/README.md)|| - -|[CWE-710: Improper Adherence to Coding Standards](https://cwe.mitre.org/data/definitions/710.html)|Prominent CVE| -|:----------------------------------------------------------------|:----| -|[CWE-1095: Loop Condition Value Update within the Loop](CWE-710/CWE-1095/README.md)|| -|[CWE-1109: Use of Same Variable for Multiple Purposes](CWE-710/CWE-1109/README.md)|| -|[CWE-489: Active Debug Code](CWE-710/CWE-489/README.md)|[CVE-2018-14649](https://www.cvedetails.com/cve/CVE-2018-14649),
CVSSv3.1: __9.8__,
EPSS: __69.64__ (12.12.2023)| + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MITRE01 IntroductionProminent CVEs
CWE-501pyscg-0040: Trust Boundary ViolationCVE-2023-28597, CVSSv3.0: 7.5,
EPSS: 00.11 (05.11.2024)
CWE-798pyscg-0041: Use of hardcoded credentials
CWE-783pyscg-0042: Operator Precedence Logic Error
CWE-472pyscg-0055: External Control of Assumed-Immutable Web Parameter
MITRE02 Encoding and StringsProminent CVEs
CWE-175pyscg-0043: Improper Handling of Mixed Encoding
CWE-180pyscg-0044: Incorrect behavior order: Validate before CanonicalizeCVE-2022-26136,
CVSSv3.1: 9.8,
EPSS: 00.28 (31.12.20255)
CWE-182pyscg-0045: Enforce control over encoding such as UTF-8
CWE-838pyscg-0046: Inappropriate Encoding for Output Context
MITRE03 NumbersProminent CVEs
CWE-1339pyscg-0001: Avoid floating-point and use integers or the decimal module to ensure precision in applications that require high accuracy, such as in financial or banking computations
CWE-191pyscg-0002: Ensure that integer overflow is properly handled in order to avoid unexpected behavior.
CWE-1335pyscg-0053: Incorrect Bitwise Shift of Intege
CWE-1335pyscg-0003: Promote readability and compatibility by using mathematical written code with arithmetic operations instead of bit-wise operations
CWE-197pyscg-0004: Ensure to have predictable outcomes in loops by using int instead of float variables as a counter
CWE-197pyscg-0005: Make conscious design decisions on how conversions are rounded
CWE-681pyscg-0006: String representations of floating-point numbers must not be compared or inspected outside of specialized modules such as decimal or math
CWE-681pyscg-0007: Avoid using floating-point literals.
MITRE04 NeutralizationProminent CVEs
CWE-184pyscg-0184: Use 'allow lists' to avoid continuesly updates to 'deny lists'.
CWE-134pyscg-0008: Use of Externally-Controlled Format StringCVE-2022-27177,
CVSSv3.1: >9.8,
EPSS: 00.37 (01.12.2023)
CWE-78pyscg-0009: Improper Neutralization of Special Elements Used in an OS Command (OS Command Injection)CVE-2024-43804,
CVSSv3.1: 8.8,
EPSS: 00.06 (08.11.2024)
CWE-89pyscg-0010: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')CVE-2019-8600, CVSSv3.1: 9.8,
EPSS: 01.43 (18.02.2024)
CWE-843pyscg-0011: Access of Resource Using Incompatible Type ('Type Confusion')CVE-2021-29513, CVSSv3.1: 7.8,
EPSS: 00.02 (13.05.2025) +
CWE-409pyscg-0012: Improper Handling of Highly Compressed Data (Data Amplification)CVE-2019-9674, CVSSv3.1: 7.5, EPSS 1.2%(10.09.2025)
CWE-426pyscg-0013: Untrusted Search PathCVE-2015-1326,
CVSSv3.0: 8.8,
EPSS: 00.20 (23.11.2023)
MITRE05 Exception handlingProminent CVEs
CWE-397pyscg-0014: Declaration of Throws for Generic Exception
CWE-755pyscg-0015: Improper Handling of Exceptional ConditionsCVE-2024-39560,CVSSv3.1: 6.5,
EPSS: 0.04 (01.11.2024)
CWE-390pyscg-0016: Detection of Error Condition without Action
CWE-230pyscg-0017: Improper Handling of Missing Values
CWE-754pyscg-0018: Improper Check for Unusual or Exceptional Conditions - float
CWE-460pyscg-0052: Improper Cleanup on Thrown Exception
MITRE06 LoggingProminent CVEs
CWE-532pyscg-0019: Insertion of Sensitive Information into Log FileCVE-2023-45585,
CVSSv3.1: 9.8,
EPSS: 0.04 (01.11.2024)
CWE-778pyscg-0020: Insufficient Logging
CWE-489pyscg-0021: Active Debug CodeCVE-2018-14649, CVSSv3.1: 9.8, EPSS: 69.64 (12.12.2023)
CWE-117pyscg-0022: Improper Output Neutralization for Logs
CWE-209pyscg-0050: Generation of Error Message Containing Sensitive Information
MITRE07 Serialization DeserializationProminent CVEs
CWE-502pyscg-0023: Deserialization of Untrusted DataCVE-2018-8021, CVSSv3.0: 9.8,
EPSS: 93.54 (05.11.2024)
08 ConcurrencyProminent CVE
CWE-400pyscg-0024: Uncontrolled Resource Consumption
CWE-410pyscg-0025: Insufficient Resource Pool
CWE-833pyscg-0026: Deadlock
CWE-362pyscg-0027: Concurrent Execution Using Shared Resource with Improper Synchronization (Race Condition)
CWE-584pyscg-0028: Return Inside Finally Block
CWE-665pyscg-0029: Improper Initialization
CWE-392pyscg-0030: Missing Report of Error Condition in a Threadpool
CWE-404pyscg-0051: Improper Resource Shutdown or Release
CWE-366pyscg-0054: Race Condition within a Thread
MITRE09 Coding StandardsProminent CVE
CWE-1095pyscg-0031: Loop Condition Value Update within the Loop
CWE-1109pyscg-0032: Use of Same Variable for Multiple Purposes
CWE-595pyscg-0033: Comparison of Object References Instead of Object Contents
CWE-476pyscg-0034: NULL Pointer Dereference
CWE-459pyscg-0035: Incomplete Cleanup
CWE-252pyscg-0036: Unchecked Return Value
CWE-617pyscg-0037: Reachable Assertion
MITRE10 CryptographyProminent CVE
CWE-330pyscg-0038: Use of Insufficiently Random ValuesCVE-2020-7548, CVSSv3.1: 9.8
EPSS: 0.22 (12.12.2024)
## Biblography