Skip to content

Commit

Permalink
Remove invalid checking on hashlib (#914)
Browse files Browse the repository at this point in the history
* hashlib does not support name as the kwargs argument 
* 'string' is not a keyword of kwargs

Fixes #865

Signed-off-by: Eric Brown <eric_wade_brown@yahoo.com>
  • Loading branch information
ericwb committed Jun 27, 2022
1 parent e15fe9b commit 0b56c57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
14 changes: 6 additions & 8 deletions examples/hashlib_new_insecure_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@

hashlib.new('md5')

hashlib.new('md4', 'test')
hashlib.new('md4', b'test')

hashlib.new(name='md5', string='test')
hashlib.new(name='md5', data=b'test')

hashlib.new('MD4', string='test')

hashlib.new(string='test', name='MD5')
hashlib.new('MD4', data=b'test')

hashlib.new('sha1')

hashlib.new(string='test', name='SHA1')
hashlib.new('sha1', data=b'test')

hashlib.new('sha', string='test')
hashlib.new('sha', data=b'test')

hashlib.new(name='SHA', string='test')
hashlib.new(name='SHA', data=b'test')

# usedforsecurity arg only availabe in Python 3.9+
hashlib.new('sha1', usedforsecurity=True)
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,28 +828,28 @@ def test_hashlib_new_insecure_functions(self):
"UNDEFINED": 0,
"LOW": 0,
"MEDIUM": 0,
"HIGH": 10,
"HIGH": 9,
},
"CONFIDENCE": {
"UNDEFINED": 0,
"LOW": 0,
"MEDIUM": 0,
"HIGH": 10,
"HIGH": 9,
},
}
else:
expect = {
"SEVERITY": {
"UNDEFINED": 0,
"LOW": 0,
"MEDIUM": 11,
"MEDIUM": 10,
"HIGH": 0,
},
"CONFIDENCE": {
"UNDEFINED": 0,
"LOW": 0,
"MEDIUM": 0,
"HIGH": 11,
"HIGH": 10,
},
}
self.check_example("hashlib_new_insecure_functions.py", expect)
Expand Down

0 comments on commit 0b56c57

Please sign in to comment.