Skip to content

Commit 9e91f3a

Browse files
committed
Python: Highlight shortcomings of hashlib.new modeling
1 parent 58f6058 commit 9e91f3a

File tree

1 file changed

+9
-0
lines changed
  • python/ql/test/library-tests/frameworks/stdlib

1 file changed

+9
-0
lines changed

python/ql/test/library-tests/frameworks/stdlib/test_md5.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@
2727
hasher.update(b"secret") # $ CryptographicOperation CryptographicOperationInput=b"secret" CryptographicOperationAlgorithm=MD5
2828
hasher.update(b" message") # $ CryptographicOperation CryptographicOperationInput=b" message" CryptographicOperationAlgorithm=MD5
2929
print(hasher.hexdigest())
30+
31+
32+
def foo(arg):
33+
hasher = hashlib.new(arg)
34+
hasher.update(b"secret") # $ MISSING: CryptographicOperation CryptographicOperationInput=b"secret" CryptographicOperationAlgorithm=MD5
35+
hasher.update(b" message") # $ MISSING: CryptographicOperation CryptographicOperationInput=b" message" CryptographicOperationAlgorithm=MD5
36+
print(hasher.hexdigest())
37+
38+
foo("md5")

0 commit comments

Comments
 (0)