Skip to content

Commit c4987e9

Browse files
committed
Python: Re-introduce syntactic handling of str/bytes/unicode
I don't want to loose results on this, so until type-tracking/API graphs can handle this, I want to keep our syntactic handling.
1 parent aa8b730 commit c4987e9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ predicate subscriptStep(DataFlow::CfgNode nodeFrom, DataFlow::CfgNode nodeTo) {
7777
predicate stringManipulation(DataFlow::CfgNode nodeFrom, DataFlow::CfgNode nodeTo) {
7878
// transforming something tainted into a string will make the string tainted
7979
exists(DataFlow::CallCfgNode call | call = nodeTo |
80-
call = API::builtin(["str", "bytes", "unicode"]).getACall() and
80+
(
81+
call = API::builtin(["str", "bytes", "unicode"]).getACall()
82+
or
83+
call.getFunction().asCfgNode().(NameNode).getId() in ["str", "bytes", "unicode"]
84+
) and
8185
nodeFrom in [call.getArg(0), call.getArgByName("object")]
8286
)
8387
or

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

Lines changed: 1 addition & 1 deletion
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), # $ MISSING: tainted
35+
unicode(ts), # $ tainted
3636
)
3737

3838
aug_assignment = "safe"

0 commit comments

Comments
 (0)