Python: Fix globals() == locals() FP

This commit is contained in:
Rasmus Wriedt Larsen
2021-09-13 20:02:54 +02:00
parent 69fe2a36e5
commit f402475dd3
2 changed files with 7 additions and 2 deletions

View File

@@ -30,5 +30,11 @@ predicate modification_of_locals(ControlFlowNode f) {
}
from AstNode a, ControlFlowNode f
where modification_of_locals(f) and a = f.getNode()
where
modification_of_locals(f) and
a = f.getNode() and
// in module level scope `locals() == globals()`
// see https://docs.python.org/3/library/functions.html#locals
// FP report in https://github.com/github/codeql/issues/6674
not a.getScope() instanceof ModuleScope
select a, "Modification of the locals() dictionary will have no effect on the local variables."