Skip to content

Commit aa8b730

Browse files
committed
Python: Use more API graphs in TaintTrackingPrivate
But now we suddenly don't handle the call to `unicode` :O -- at least not when I run the test locally (using Python 3).
1 parent a2e8417 commit aa8b730

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

python/ql/src/semmle/python/dataflow/new/internal/TaintTrackingPrivate.qll

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,9 @@ predicate subscriptStep(DataFlow::CfgNode nodeFrom, DataFlow::CfgNode nodeTo) {
7676
*/
7777
predicate stringManipulation(DataFlow::CfgNode nodeFrom, DataFlow::CfgNode nodeTo) {
7878
// transforming something tainted into a string will make the string tainted
79-
exists(CallNode call | call = nodeTo.getNode() |
80-
call.getFunction().(NameNode).getId() in ["str", "bytes", "unicode"] and
81-
(
82-
nodeFrom.getNode() = call.getArg(0)
83-
or
84-
nodeFrom.getNode() = call.getArgByName("object")
85-
)
79+
exists(DataFlow::CallCfgNode call | call = nodeTo |
80+
call = API::builtin(["str", "bytes", "unicode"]).getACall() and
81+
nodeFrom in [call.getArg(0), call.getArgByName("object")]
8682
)
8783
or
8884
// String methods. Note that this doesn't recognize `meth = "foo".upper; meth()`

python/ql/test/experimental/dataflow/tainttracking/defaultAdditionalTaintStep/test_string.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def str_operations():
3232
ts[0], # $ tainted
3333
str(ts), # $ tainted
3434
bytes(tb), # $ tainted
35-
unicode(ts), # $ tainted
35+
unicode(ts), # $ MISSING: tainted
3636
)
3737

3838
aug_assignment = "safe"
@@ -104,7 +104,7 @@ def non_syntactic():
104104
_str = str
105105
ensure_tainted(
106106
meth(), # $ MISSING: tainted
107-
_str(ts), # $ MISSING: tainted
107+
_str(ts), # $ tainted
108108
)
109109

110110

0 commit comments

Comments
 (0)