Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
CWE-681 (#14)
Browse files Browse the repository at this point in the history
* CWE-681

* CWE-681 Update README.md

* CWE-681 Update README.md - no spaces

* CWE-681 Update README.md
  • Loading branch information
s19110 authored May 9, 2024
1 parent a541d9e commit e066c4c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CWE-664/CWE-681/compliant01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
""" Compliant Code Example """
from decimal import Decimal

t = Decimal(str(4 / 2))
print(f"t: {t}")
# t still prints "2.0", but now it's a Decimal
if Decimal("2").compare(t) == 0:
print("t equals 2")
# prints "t equals 2"
7 changes: 7 additions & 0 deletions CWE-664/CWE-681/noncompliant01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
""" Non-compliant Code Example """
s = str(4 / 2)
print(f"s: {s}")
# s is "2.0", a string
if s == "2":
print("s equals 2")
# <no output>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ It is **not production code** and requires code-style or python best practices t
|[CWE-410: Insufficient Resource Pool](CWE-664/CWE-410/.)||
|[CWE-502: Deserialization of Untrusted Data)](CWE-664/CWE-502/.)||
|[CWE-665: Improper Initialization](CWE-664/CWE-665/.)||
|[CWE-681: Improper Control of a Resource Through its Lifetime](CWE-664/CWE-681/.)||
|[CWE-833: Deadlock](CWE-664/CWE-833/.)||
|[CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')](CWE-664/CWE-843/.)||
|[XXX-005: Consider hash-based integrity verification of byte code files against their source code files](CWE-664/XXX-005/.)||
Expand Down

0 comments on commit e066c4c

Please sign in to comment.