File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
python/ql/test/experimental/dataflow/tainttracking/defaultAdditionalTaintStep Expand file tree Collapse file tree 1 file changed +45
-0
lines changed 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
+ class Context :
14
+ def __enter__ (self ):
15
+ return TAINTED_STRING
16
+
17
+ def __exit__ (self , exc_type , exc , tb ):
18
+ pass
19
+
20
+ def test_with ():
21
+ ctx = Context ()
22
+ taint (ctx )
23
+ with ctx as tainted :
24
+ ensure_tainted (tainted ) # $ tainted
25
+
26
+
27
+ class Iter :
28
+ def __iter__ (self ):
29
+ return self
30
+
31
+ def __next__ (self ):
32
+ raise StopIteration
33
+
34
+ def test_for ():
35
+ iter = Iter ()
36
+ taint (iter )
37
+ for tainted in iter :
38
+ ensure_tainted (tainted ) # $ tainted
39
+
40
+
41
+
42
+ # Make tests runable
43
+
44
+ test_with ()
45
+ test_for ()
You can’t perform that action at this time.
0 commit comments