Repository navigation
Expand file tree
/
Copy pathtest.py
More file actions
56 lines (46 loc) · 1.34 KB
/
Copy pathtest.py
File metadata and controls
56 lines (46 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import json
from copy import copy
def test_json():
tainted_string = TAINTED
tainted_json = json.loads(tainted_string)
a = tainted_json["x"]
b = a.get("y")
c = b["z"]
def test_str():
tainted_string = TAINTED
a = tainted_string.ljust(8)
b = tainted_string.copy()
c = tainted_string[:]
d = tainted_string[::2]
e = reversed(tainted_string)
f = copy(tainted_string)
h = tainted_string.strip()
def test_const_sanitizer1():
tainted_string = TAINTED
if tainted_string == "OK":
not_tainted(tainted_string)
else:
still_tainted(tainted_string)
def test_const_sanitizer2():
tainted_string = TAINTED
if tainted_string == "OK" or tainted_string == "ALSO_OK":
not_tainted(tainted_string)
else:
still_tainted(tainted_string)
def test_str2():
tainted_string = TAINTED
a = str(tainted_string)
b = bytes(tainted_string) # This is an error in Python 3
c = bytes(tainted_string, encoding="utf8") # This is an error in Python 2
def cross_over(func, taint):
return func(taint)
def test_exc_info():
info = TAINTED_EXCEPTION_INFO
res = cross_over(exc_info_call, info)
def exc_info_call(arg):
return arg
def test_untrusted():
ext = TAINTED_EXTERNAL_STRING
res = cross_over(untrusted_call, ext)
def exc_untrusted_call(arg):
return arg