Skip to content

Commit b2cb284

Browse files
committed
Python: Add more examples of what is ok with new taint tests
1 parent 3e7dc12 commit b2cb284

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
argumentToEnsureNotTaintedNotMarkedAsSpurious
2-
| ERROR, you should add `SPURIOUS:` to this annotation | taint_test.py:36:9:36:29 | taint_test.py:36 | should_not_be_tainted |
2+
| ERROR, you should add `SPURIOUS:` to this annotation | taint_test.py:48:9:48:29 | taint_test.py:48 | should_not_be_tainted |
33
untaintedArgumentToEnsureTaintedNotMarkedAsMissing
4-
| ERROR, you should add `# $ MISSING: tainted` annotation | taint_test.py:28:9:28:25 | taint_test.py:28 |
4+
| ERROR, you should add `# $ MISSING: tainted` annotation | taint_test.py:32:9:32:25 | taint_test.py:32 |
5+
| ERROR, you should add `# $ MISSING: tainted` annotation | taint_test.py:37:24:37:40 | taint_test.py:37 |
56
failures
7+
| taint_test.py:41:20:41:21 | ts | Fixed missing result:tainted= |

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ def expected_usage():
99
should_be_tainted, # $ MISSING: tainted
1010
)
1111

12+
# having one annotation for multiple arguments is OK, as long as all arguments
13+
# fulfil the same annotation
14+
ensure_tainted(ts, ts) # $ tainted
15+
1216
# simulating handling something we _want_ to treat at untainted, but we currently treat as tainted
1317
should_not_be_tainted = "pretend this is now safe" + ts
1418
ensure_not_tainted(
@@ -28,6 +32,14 @@ def bad_usage():
2832
should_be_tainted,
2933
)
3034

35+
# using one annotation for multiple arguments i not OK when it's mixed whether our
36+
# taint-tracking works as expected
37+
ensure_tainted(ts, should_be_tainted) # $ tainted
38+
39+
# if you try to get around it by adding BOTH annotations, that results in a problem
40+
# from the default set of inline-test-expectation rules
41+
ensure_tainted(ts, should_be_tainted) # $ tainted MISSING: tainted
42+
3143
# simulating handling something we _want_ to treat at untainted, but we currently treat as tainted
3244
should_not_be_tainted = "pretend this is now safe" + ts
3345

0 commit comments

Comments
 (0)