Skip to content

Commit 4bfd55f

Browse files
committed
Python: Show problem with os.path modeling
This is not a very good test for showing that we don't handle direct imports, but it was the best I had available without inventing something new. It's very fragile, since any of these would propagate taint (due to handling all `join` calls as if the qualifier was a string): ospath_alias.join(ts) ospath_alias.join(ts, "foo", "bar") But this test DOES serve the purpose of illustrating that my fix works :D
1 parent 83d6d60 commit 4bfd55f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

python/ql/test/experimental/dataflow/tainttracking/defaultAdditionalTaintStep/TestTaint.expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,10 @@
137137
| test_string.py:143 | fail | binary_decode_encode | base64.decodestring(..) |
138138
| test_string.py:148 | fail | binary_decode_encode | quopri.encodestring(..) |
139139
| test_string.py:149 | fail | binary_decode_encode | quopri.decodestring(..) |
140-
| test_string.py:158 | ok | test_os_path_join | os.path.join(..) |
141140
| test_string.py:159 | ok | test_os_path_join | os.path.join(..) |
142141
| test_string.py:160 | ok | test_os_path_join | os.path.join(..) |
142+
| test_string.py:161 | ok | test_os_path_join | os.path.join(..) |
143+
| test_string.py:162 | fail | test_os_path_join | ospath_alias.join(..) |
143144
| test_unpacking.py:16 | ok | unpacking | a |
144145
| test_unpacking.py:16 | ok | unpacking | b |
145146
| test_unpacking.py:16 | ok | unpacking | c |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ def binary_decode_encode():
152152

153153
def test_os_path_join():
154154
import os
155+
import os.path as ospath_alias
155156
print("\n# test_os_path_join")
156157
ts = TAINTED_STRING
157158
ensure_tainted(
158159
os.path.join(ts, "foo", "bar"),
159160
os.path.join(ts),
160161
os.path.join("foo", "bar", ts),
162+
ospath_alias.join("foo", "bar", ts),
161163
)
162164

163165

0 commit comments

Comments
 (0)