Skip to content

Commit 624b794

Browse files
committed
Python: separate taint sources in with
1 parent 05aa314 commit 624b794

File tree

1 file changed

+30
-1
lines changed
  • python/ql/test/experimental/dataflow/tainttracking/defaultAdditionalTaintStep

1 file changed

+30
-1
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class Context:
1414
def __enter__(self):
15-
return TAINTED_STRING
15+
return ""
1616

1717
def __exit__(self, exc_type, exc, tb):
1818
pass
@@ -23,6 +23,33 @@ def test_with():
2323
with ctx as tainted:
2424
ensure_tainted(tainted) # $ tainted
2525

26+
class Context_taint:
27+
def __enter__(self):
28+
return TAINTED_STRING
29+
30+
def __exit__(self, exc_type, exc, tb):
31+
pass
32+
33+
def test_with_taint():
34+
ctx = Context_taint()
35+
with ctx as tainted:
36+
ensure_tainted(tainted) # $ MISSING: tainted
37+
38+
39+
class Context_arg:
40+
def __init__(self, arg):
41+
self.arg = arg
42+
43+
def __enter__(self):
44+
return self.arg
45+
46+
def __exit__(self, exc_type, exc, tb):
47+
pass
48+
49+
def test_with_arg():
50+
ctx = Context_arg(TAINTED_STRING)
51+
with ctx as tainted:
52+
ensure_tainted(tainted) # $ tainted
2653

2754
class Iter:
2855
def __iter__(self):
@@ -42,4 +69,6 @@ def test_for():
4269
# Make tests runable
4370

4471
test_with()
72+
test_with_taint()
73+
test_with_arg()
4574
test_for()

0 commit comments

Comments
 (0)