diff --git a/python/ql/src/Imports/UnintentionalImport.ql b/python/ql/src/Imports/UnintentionalImport.ql index dfd751fd5270..2a3c2b6460b8 100644 --- a/python/ql/src/Imports/UnintentionalImport.ql +++ b/python/ql/src/Imports/UnintentionalImport.ql @@ -26,7 +26,7 @@ predicate all_defined(ModuleValue exporter) { } from ImportStar imp, ModuleValue exporter -where import_star(imp, exporter) and not all_defined(exporter) +where import_star(imp, exporter) and not all_defined(exporter) and not exporter.isAbsent() select imp, "Import pollutes the enclosing namespace, as the imported module $@ does not define '__all__'.", exporter, exporter.getName() diff --git a/python/ql/test/query-tests/Imports/general/ImportStarUsed.expected b/python/ql/test/query-tests/Imports/general/ImportStarUsed.expected index 9aa101edbca6..d29bc2b9b5ff 100644 --- a/python/ql/test/query-tests/Imports/general/ImportStarUsed.expected +++ b/python/ql/test/query-tests/Imports/general/ImportStarUsed.expected @@ -1,2 +1,3 @@ | imports_test.py:21:1:21:20 | from module import * | Using 'from ... import *' pollutes the namespace | | imports_test.py:22:1:22:32 | from module_without_all import * | Using 'from ... import *' pollutes the namespace | +| imports_test.py:65:1:65:40 | from module_that_does_not_exist import * | Using 'from ... import *' pollutes the namespace | diff --git a/python/ql/test/query-tests/Imports/general/imports_test.py b/python/ql/test/query-tests/Imports/general/imports_test.py index 5e5184b78c7e..4b51f8254fc4 100644 --- a/python/ql/test/query-tests/Imports/general/imports_test.py +++ b/python/ql/test/query-tests/Imports/general/imports_test.py @@ -61,3 +61,5 @@ def __init__(self): #Use it different +# FP reported in https://github.com/github/codeql/issues/4003 +from module_that_does_not_exist import *