File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
python/ql/src/semmle/python/frameworks Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -1207,6 +1207,13 @@ private module Stdlib {
1207
1207
override DataFlow:: Node getAnInput ( ) { result = this .getArg ( 0 ) }
1208
1208
}
1209
1209
1210
+ /** Helper predicate for the `HashLibGenericHashOperation` charpred, to prevent a bad join order. */
1211
+ pragma [ nomagic]
1212
+ private API:: Node hashlibMember ( string hashName ) {
1213
+ result = API:: moduleImport ( "hashlib" ) .getMember ( hashName ) and
1214
+ hashName != "new"
1215
+ }
1216
+
1210
1217
/**
1211
1218
* A hashing operation from the `hashlib` package using one of the predefined classes
1212
1219
* (such as `hashlib.md5`). `hashlib.new` is not included, since it is handled by
@@ -1218,10 +1225,7 @@ private module Stdlib {
1218
1225
API:: Node hashClass ;
1219
1226
1220
1227
bindingset [ this ]
1221
- HashlibGenericHashOperation ( ) {
1222
- not hashName = "new" and
1223
- hashClass = API:: moduleImport ( "hashlib" ) .getMember ( hashName )
1224
- }
1228
+ HashlibGenericHashOperation ( ) { hashClass = hashlibMember ( hashName ) }
1225
1229
1226
1230
override Cryptography:: CryptographicAlgorithm getAlgorithm ( ) { result .matchesName ( hashName ) }
1227
1231
}
You can’t perform that action at this time.
0 commit comments