Python: Ignore weak key-sizes from test-code in weak-crypto-key

From looking at old results on LGTM.com, this was quite common (and those alerts
doesn't really provide value).
This commit is contained in:
Rasmus Wriedt Larsen
2021-02-19 14:37:10 +01:00
parent bfc8ead667
commit d084261a79
2 changed files with 3 additions and 3 deletions

View File

@@ -12,11 +12,13 @@
import python
import semmle.python.Concepts
import semmle.python.dataflow.new.DataFlow
import semmle.python.filters.Tests
from Cryptography::PublicKey::KeyGeneration keyGen, int keySize, DataFlow::Node origin
where
keySize = keyGen.getKeySizeWithOrigin(origin) and
keySize < keyGen.minimumSecureKeySize()
keySize < keyGen.minimumSecureKeySize() and
not origin.getScope().getScope*() instanceof TestScope
select keyGen,
"Creation of an " + keyGen.getName() + " key uses $@ bits, which is below " +
keyGen.minimumSecureKeySize() + " and considered breakable.", origin, keySize.toString()