Skip to content

Commit

Permalink
python: model string property of resultof finditer
Browse files Browse the repository at this point in the history
  • Loading branch information
yoff committed Oct 9, 2024
1 parent 073189e commit 494b8bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions python/ql/lib/semmle/python/frameworks/Stdlib.qll
Original file line number Diff line number Diff line change
Expand Up @@ -3463,6 +3463,14 @@ module StdlibPrivate {
) and
preservesValue = false
)
or
// flow from input string to attribute on match object
exists(int arg | arg = methodName.(RegexExecutionMethod).getStringArgIndex() - offset |
input in ["Argument[" + arg + "]", "Argument[string:]"] and
methodName = "finditer" and
output = "ReturnValue.ListElement.Attribute[string]" and
preservesValue = true
)
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions python/ql/test/library-tests/frameworks/stdlib/test_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
compiled_pat.match(ts).string, # $ tainted
re.compile(ts).match("safe").re.pattern, # $ tainted

list(re.finditer(pat, ts))[0].string, # $ MISSING: tainted
[m.string for m in re.finditer(pat, ts)], # $ MISSING: tainted
list(re.finditer(pat, ts))[0].string, # $ tainted
[m.string for m in re.finditer(pat, ts)], # $ tainted

list(re.finditer(pat, ts))[0].groups()[0], # $ MISSING: tainted
[m.groups()[0] for m in re.finditer(pat, ts)], # $ MISSING: tainted
Expand Down

0 comments on commit 494b8bd

Please sign in to comment.