Skip to content

Commit 3669307

Browse files
committed
Python: update test with implicit read example
1 parent 20dc6a6 commit 3669307

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Diff for: python/ql/test/experimental/meta/inline-taint-test-demo/InlineTaintTest.expected

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ argumentToEnsureNotTaintedNotMarkedAsSpurious
33
untaintedArgumentToEnsureTaintedNotMarkedAsMissing
44
| taint_test.py:32:9:32:25 | taint_test.py:32 | ERROR, you should add `# $ MISSING: tainted` annotation | should_be_tainted |
55
| taint_test.py:37:24:37:40 | taint_test.py:37 | ERROR, you should add `# $ MISSING: tainted` annotation | should_be_tainted |
6+
argumentToEnsureNotTaintedWithReadsNotMarkedAsSpurious
7+
untaintedArgumentToEnsureTaintedWithReadsNotMarkedAsMissing
8+
spuriousReadStepsPossible
9+
| taint_test.py:68:9:68:10 | ControlFlowNode for tt | taint_test.py:76:9:76:13 | ControlFlowNode for Subscript |
610
testFailures
711
| taint_test.py:41:20:41:21 | ts | Fixed missing result:tainted= |
812
failures

Diff for: python/ql/test/experimental/meta/inline-taint-test-demo/taint_test.py

+29
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,32 @@ def bad_usage():
4747
ensure_not_tainted(
4848
should_not_be_tainted # $ tainted
4949
)
50+
51+
52+
def implicit_reads():
53+
tt = (TAINTED_STRING,)
54+
55+
# Normal use
56+
ensure_tainted(
57+
tt[0], # $ tainted
58+
)
59+
60+
# We have precise content, so the tuple itself is not tainted
61+
ensure_not_tainted(
62+
tt,
63+
tt[1],
64+
)
65+
66+
# We can see the tuple tainted at sinks due to implicit reads
67+
ensure_tainted_with_reads(
68+
tt, # $ tainted
69+
)
70+
71+
# We should not see other elements of the tuple being tainted
72+
# but the implicit reads of the previous test allows the taint
73+
# to flow to the tuple and then to the subscript.
74+
# We can see a warning about this in the expected output under
75+
# `spuriousReadStepsPossible`.
76+
ensure_not_tainted(
77+
tt[1], # $ SPURIOUS:tainted
78+
)

0 commit comments

Comments
 (0)