Python: broaden search for imports

This now finds vulnerabilities in
https://github.com/github/field-security-codeql/issues/100
This commit is contained in:
Rasmus Lerchedahl Petersen
2023-09-11 11:15:40 +02:00
committed by yoff
parent d9854eb409
commit 4f35a62583

View File

@@ -254,9 +254,10 @@ private predicate isNameSpacePackage(Folder f, string name) {
legalShortName(name) and
name = f.getStem() and
not isRegularPackage(f, name) and
// it has to be imported in this folder
// it has to be imported in a file
// either in this folder or next to this folder
name =
any(ImportExpr i | i.getLocation().getFile().getParent() = f)
any(ImportExpr i | i.getLocation().getFile().getParent() in [f, f.getParent()])
.getName()
.regexpReplaceAll("\\..*", "") and
name != "" and