Python: Highlight shortcomings of hashlib.new modeling

This commit is contained in:
Rasmus Wriedt Larsen
2021-11-04 15:28:42 +01:00
parent 58f6058a63
commit 9e91f3a341

View File

@@ -27,3 +27,12 @@ hasher = hashlib.new('md5')
hasher.update(b"secret") # $ CryptographicOperation CryptographicOperationInput=b"secret" CryptographicOperationAlgorithm=MD5
hasher.update(b" message") # $ CryptographicOperation CryptographicOperationInput=b" message" CryptographicOperationAlgorithm=MD5
print(hasher.hexdigest())
def foo(arg):
hasher = hashlib.new(arg)
hasher.update(b"secret") # $ MISSING: CryptographicOperation CryptographicOperationInput=b"secret" CryptographicOperationAlgorithm=MD5
hasher.update(b" message") # $ MISSING: CryptographicOperation CryptographicOperationInput=b" message" CryptographicOperationAlgorithm=MD5
print(hasher.hexdigest())
foo("md5")