mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Python: supress non-useful results (w/ tests) for iter str/seq query
Fixes https://github.com/Semmle/ql/issues/3207
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
import python
|
||||
import semmle.python.filters.Tests
|
||||
|
||||
predicate has_string_type(Value v) {
|
||||
v.getClass() = ClassValue::str()
|
||||
@@ -28,7 +29,10 @@ where
|
||||
iter.pointsTo(seq, seq_origin) and
|
||||
has_string_type(str) and
|
||||
seq.getClass().isIterable() and
|
||||
not has_string_type(seq)
|
||||
not has_string_type(seq) and
|
||||
// suppress occurrences from tests
|
||||
not seq_origin.getScope().getScope*() instanceof TestScope and
|
||||
not str_origin.getScope().getScope*() instanceof TestScope
|
||||
select loop,
|
||||
"Iteration over $@, of class " + seq.getClass().getName() + ", may also iterate over $@.",
|
||||
seq_origin, "sequence", str_origin, "string"
|
||||
|
||||
Reference in New Issue
Block a user