File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed
python/ql/test/experimental/dataflow/tainttracking/defaultSanitizer Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ | test.py:16 | fail | const_eq_clears_taint | ts |
2+ | test.py:18 | ok | const_eq_clears_taint | ts |
3+ | test.py:24 | fail | const_eq_clears_taint2 | ts |
4+ | test.py:29 | ok | non_const_eq_preserves_taint | ts |
5+ | test.py:31 | ok | non_const_eq_preserves_taint | ts |
Original file line number Diff line number Diff line change 1+ import experimental.dataflow.tainttracking.TestTaintLib
Original file line number Diff line number Diff line change 1+ # Add taintlib to PATH so it can be imported during runtime without any hassle
2+ import sys ; import os ; sys .path .append (os .path .dirname (os .path .dirname ((__file__ ))))
3+ from taintlib import *
4+
5+ # This has no runtime impact, but allows autocomplete to work
6+ from typing import TYPE_CHECKING
7+ if TYPE_CHECKING :
8+ from ..taintlib import *
9+
10+
11+ # Actual tests
12+
13+ def const_eq_clears_taint ():
14+ ts = TAINTED_STRING
15+ if ts == "safe" :
16+ ensure_not_tainted (ts )
17+ # ts should still be tainted after exiting the if block
18+ ensure_tainted (ts )
19+
20+ def const_eq_clears_taint2 ():
21+ ts = TAINTED_STRING
22+ if ts != "safe" :
23+ return
24+ ensure_not_tainted (ts )
25+
26+ def non_const_eq_preserves_taint (x = "foo" ):
27+ ts = TAINTED_STRING
28+ if ts == ts :
29+ ensure_tainted (ts )
30+ if ts == x :
31+ ensure_tainted (ts )
32+
33+
34+ # Make tests runable
35+
36+ const_eq_clears_taint ()
37+ const_eq_clears_taint2 ()
38+ non_const_eq_preserves_taint ()
You can’t perform that action at this time.
0 commit comments