Python: Make new taint tracking tests runnable again

since the files was called `collection`, that conflicted with import system :|
This commit is contained in:
Rasmus Wriedt Larsen
2020-08-27 10:44:14 +02:00
parent bd21fc5601
commit af20c3e082
9 changed files with 191 additions and 199 deletions

View File

@@ -1,20 +1,22 @@
| collections.py:16 | ok | test_access | tainted_list.copy() |
| string.py:17 | ok | str_methods | ts.casefold() |
| string.py:19 | ok | str_methods | ts.format_map(..) |
| string.py:20 | ok | str_methods | "{unsafe}".format_map(..) |
| string.py:31 | fail | binary_decode_encode | base64.a85encode(..) |
| string.py:32 | fail | binary_decode_encode | base64.a85decode(..) |
| string.py:35 | fail | binary_decode_encode | base64.b85encode(..) |
| string.py:36 | fail | binary_decode_encode | base64.b85decode(..) |
| string.py:39 | fail | binary_decode_encode | base64.encodebytes(..) |
| string.py:40 | fail | binary_decode_encode | base64.decodebytes(..) |
| string.py:48 | ok | f_strings | Fstring |
| unpacking.py:18 | ok | extended_unpacking | first |
| unpacking.py:18 | ok | extended_unpacking | last |
| unpacking.py:18 | ok | extended_unpacking | rest |
| unpacking.py:23 | ok | also_allowed | a |
| unpacking.py:31 | ok | also_allowed | b |
| unpacking.py:31 | ok | also_allowed | c |
| unpacking.py:39 | ok | nested | x |
| unpacking.py:39 | ok | nested | xs |
| unpacking.py:39 | ok | nested | ys |
| collections_.py:16 | ok | test_access | tainted_list.copy() |
| collections_.py:24 | ok | list_clear | tainted_list |
| collections_.py:27 | fail | list_clear | tainted_list |
| string_.py:17 | ok | str_methods | ts.casefold() |
| string_.py:19 | ok | str_methods | ts.format_map(..) |
| string_.py:20 | ok | str_methods | "{unsafe}".format_map(..) |
| string_.py:31 | fail | binary_decode_encode | base64.a85encode(..) |
| string_.py:32 | fail | binary_decode_encode | base64.a85decode(..) |
| string_.py:35 | fail | binary_decode_encode | base64.b85encode(..) |
| string_.py:36 | fail | binary_decode_encode | base64.b85decode(..) |
| string_.py:39 | fail | binary_decode_encode | base64.encodebytes(..) |
| string_.py:40 | fail | binary_decode_encode | base64.decodebytes(..) |
| string_.py:48 | ok | f_strings | Fstring |
| unpacking_.py:18 | ok | extended_unpacking | first |
| unpacking_.py:18 | ok | extended_unpacking | last |
| unpacking_.py:18 | ok | extended_unpacking | rest |
| unpacking_.py:23 | ok | also_allowed | a |
| unpacking_.py:31 | ok | also_allowed | b |
| unpacking_.py:31 | ok | also_allowed | c |
| unpacking_.py:39 | ok | nested | x |
| unpacking_.py:39 | ok | nested | xs |
| unpacking_.py:39 | ok | nested | ys |

View File

@@ -17,6 +17,16 @@ def test_access():
)
def list_clear():
tainted_string = TAINTED_STRING
tainted_list = [tainted_string]
ensure_tainted(tainted_list)
tainted_list.clear()
ensure_not_tainted(tainted_list)
# Make tests runable
test_access()
list_clear()

View File

@@ -1,157 +1,155 @@
| collections.py:24 | ok | test_construction | tainted_string |
| collections.py:25 | ok | test_construction | tainted_list |
| collections.py:26 | ok | test_construction | tainted_tuple |
| collections.py:27 | ok | test_construction | tainted_set |
| collections.py:28 | ok | test_construction | tainted_dict |
| collections.py:32 | ok | test_construction | list(..) |
| collections.py:33 | ok | test_construction | list(..) |
| collections.py:34 | ok | test_construction | list(..) |
| collections.py:35 | ok | test_construction | list(..) |
| collections.py:36 | ok | test_construction | list(..) |
| collections.py:38 | ok | test_construction | tuple(..) |
| collections.py:39 | ok | test_construction | set(..) |
| collections.py:40 | ok | test_construction | frozenset(..) |
| collections.py:48 | ok | test_access | tainted_list[0] |
| collections.py:49 | ok | test_access | tainted_list[x] |
| collections.py:50 | ok | test_access | tainted_list[Slice] |
| collections.py:52 | ok | test_access | sorted(..) |
| collections.py:53 | ok | test_access | reversed(..) |
| collections.py:54 | ok | test_access | iter(..) |
| collections.py:55 | ok | test_access | next(..) |
| collections.py:56 | ok | test_access | copy(..) |
| collections.py:57 | ok | test_access | deepcopy(..) |
| collections.py:61 | ok | test_access | a |
| collections.py:61 | ok | test_access | b |
| collections.py:61 | ok | test_access | c |
| collections.py:64 | ok | test_access | h |
| collections.py:66 | ok | test_access | i |
| collections.py:73 | ok | test_dict_access | tainted_dict["name"] |
| collections.py:74 | ok | test_dict_access | tainted_dict.get(..) |
| collections.py:75 | ok | test_dict_access | tainted_dict[x] |
| collections.py:76 | ok | test_dict_access | tainted_dict.copy() |
| collections.py:80 | ok | test_dict_access | v |
| collections.py:82 | ok | test_dict_access | v |
| collections.py:90 | fail | test_named_tuple | point[0] |
| collections.py:91 | fail | test_named_tuple | point.x |
| collections.py:95 | ok | test_named_tuple | point[1] |
| collections.py:96 | ok | test_named_tuple | point.y |
| collections.py:100 | fail | test_named_tuple | a |
| collections.py:101 | ok | test_named_tuple | b |
| collections.py:109 | fail | test_defaultdict | tainted_default_dict["name"] |
| collections.py:110 | fail | test_defaultdict | tainted_default_dict.get(..) |
| collections.py:111 | fail | test_defaultdict | tainted_default_dict[x] |
| collections.py:112 | fail | test_defaultdict | tainted_default_dict.copy() |
| collections.py:115 | fail | test_defaultdict | v |
| collections.py:117 | fail | test_defaultdict | v |
| collections.py:124 | ok | list_clear | tainted_list |
| collections.py:127 | fail | list_clear | tainted_list |
| collections.py:134 | ok | list_index_assign | my_list |
| collections.py:137 | fail | list_index_assign | my_list |
| collections.py:144 | ok | list_index_aug_assign | my_list |
| collections.py:147 | fail | list_index_aug_assign | my_list |
| collections.py:154 | ok | list_append | my_list |
| collections.py:157 | fail | list_append | my_list |
| json.py:26 | ok | test | json.dumps(..) |
| json.py:27 | ok | test | json.loads(..) |
| json.py:34 | fail | test | tainted_filelike |
| json.py:35 | fail | test | json.load(..) |
| json.py:48 | fail | non_syntacical | dumps(..) |
| json.py:49 | fail | non_syntacical | dumps_alias(..) |
| json.py:50 | fail | non_syntacical | loads(..) |
| json.py:57 | fail | non_syntacical | tainted_filelike |
| json.py:58 | fail | non_syntacical | load(..) |
| string.py:25 | ok | str_operations | ts |
| string.py:26 | ok | str_operations | BinaryExpr |
| string.py:27 | ok | str_operations | BinaryExpr |
| string.py:28 | ok | str_operations | BinaryExpr |
| string.py:29 | ok | str_operations | ts[Slice] |
| string.py:30 | ok | str_operations | ts[Slice] |
| string.py:31 | ok | str_operations | ts[Slice] |
| string.py:32 | ok | str_operations | ts[0] |
| string.py:33 | ok | str_operations | str(..) |
| string.py:34 | ok | str_operations | bytes(..) |
| string.py:35 | ok | str_operations | unicode(..) |
| string.py:44 | ok | str_methods | ts.capitalize() |
| string.py:45 | ok | str_methods | ts.center(..) |
| string.py:46 | ok | str_methods | ts.expandtabs() |
| string.py:48 | ok | str_methods | ts.format() |
| string.py:49 | ok | str_methods | "{}".format(..) |
| string.py:50 | ok | str_methods | "{unsafe}".format(..) |
| string.py:52 | ok | str_methods | ts.join(..) |
| string.py:53 | ok | str_methods | "".join(..) |
| string.py:55 | ok | str_methods | ts.ljust(..) |
| string.py:56 | ok | str_methods | ts.lstrip() |
| string.py:57 | ok | str_methods | ts.lower() |
| string.py:59 | ok | str_methods | ts.replace(..) |
| string.py:60 | ok | str_methods | "safe".replace(..) |
| string.py:62 | ok | str_methods | ts.rjust(..) |
| string.py:63 | ok | str_methods | ts.rstrip() |
| string.py:64 | ok | str_methods | ts.strip() |
| string.py:65 | ok | str_methods | ts.swapcase() |
| string.py:66 | ok | str_methods | ts.title() |
| string.py:67 | ok | str_methods | ts.upper() |
| string.py:68 | ok | str_methods | ts.zfill(..) |
| string.py:70 | ok | str_methods | ts.encode(..) |
| string.py:71 | ok | str_methods | ts.encode(..).decode(..) |
| string.py:73 | ok | str_methods | tb.decode(..) |
| string.py:74 | ok | str_methods | tb.decode(..).encode(..) |
| string.py:77 | ok | str_methods | ts.partition(..) |
| string.py:78 | ok | str_methods | ts.rpartition(..) |
| string.py:79 | ok | str_methods | ts.rsplit(..) |
| string.py:80 | ok | str_methods | ts.split(..) |
| string.py:81 | ok | str_methods | ts.splitlines() |
| string.py:86 | ok | str_methods | "safe".replace(..) |
| string.py:88 | fail | str_methods | ts.join(..) |
| string.py:89 | fail | str_methods | ts.join(..) |
| string.py:99 | fail | non_syntactic | meth() |
| string.py:100 | fail | non_syntactic | _str(..) |
| string.py:109 | ok | percent_fmt | BinaryExpr |
| string.py:110 | ok | percent_fmt | BinaryExpr |
| string.py:111 | ok | percent_fmt | BinaryExpr |
| string.py:121 | fail | binary_decode_encode | base64.b64encode(..) |
| string.py:122 | fail | binary_decode_encode | base64.b64decode(..) |
| string.py:124 | fail | binary_decode_encode | base64.standard_b64encode(..) |
| string.py:125 | fail | binary_decode_encode | base64.standard_b64decode(..) |
| string.py:127 | fail | binary_decode_encode | base64.urlsafe_b64encode(..) |
| string.py:128 | fail | binary_decode_encode | base64.urlsafe_b64decode(..) |
| string.py:130 | fail | binary_decode_encode | base64.b32encode(..) |
| string.py:131 | fail | binary_decode_encode | base64.b32decode(..) |
| string.py:133 | fail | binary_decode_encode | base64.b16encode(..) |
| string.py:134 | fail | binary_decode_encode | base64.b16decode(..) |
| string.py:149 | fail | binary_decode_encode | base64.encodestring(..) |
| string.py:150 | fail | binary_decode_encode | base64.decodestring(..) |
| string.py:155 | fail | binary_decode_encode | quopri.encodestring(..) |
| string.py:156 | fail | binary_decode_encode | quopri.decodestring(..) |
| unpacking.py:16 | ok | unpacking | a |
| unpacking.py:16 | ok | unpacking | b |
| unpacking.py:16 | ok | unpacking | c |
| unpacking.py:22 | ok | unpacking_to_list | a |
| unpacking.py:22 | ok | unpacking_to_list | b |
| unpacking.py:22 | ok | unpacking_to_list | c |
| unpacking.py:31 | ok | nested | a1 |
| unpacking.py:31 | ok | nested | a2 |
| unpacking.py:31 | ok | nested | a3 |
| unpacking.py:31 | ok | nested | b |
| unpacking.py:31 | ok | nested | c |
| unpacking.py:35 | ok | nested | a1 |
| unpacking.py:35 | ok | nested | a2 |
| unpacking.py:35 | ok | nested | a3 |
| unpacking.py:35 | ok | nested | b |
| unpacking.py:35 | ok | nested | c |
| unpacking.py:39 | ok | nested | a1 |
| unpacking.py:39 | ok | nested | a2 |
| unpacking.py:39 | ok | nested | a3 |
| unpacking.py:39 | ok | nested | b |
| unpacking.py:39 | ok | nested | c |
| unpacking.py:46 | ok | unpack_from_set | a |
| unpacking.py:46 | ok | unpack_from_set | b |
| unpacking.py:46 | ok | unpack_from_set | c |
| unpacking.py:56 | ok | contrived_1 | a |
| unpacking.py:56 | ok | contrived_1 | b |
| unpacking.py:56 | ok | contrived_1 | c |
| unpacking.py:57 | fail | contrived_1 | d |
| unpacking.py:57 | fail | contrived_1 | e |
| unpacking.py:57 | fail | contrived_1 | f |
| unpacking.py:65 | ok | contrived_2 | a |
| unpacking.py:65 | ok | contrived_2 | b |
| unpacking.py:65 | ok | contrived_2 | c |
| collections_.py:24 | ok | test_construction | tainted_string |
| collections_.py:25 | ok | test_construction | tainted_list |
| collections_.py:26 | ok | test_construction | tainted_tuple |
| collections_.py:27 | ok | test_construction | tainted_set |
| collections_.py:28 | ok | test_construction | tainted_dict |
| collections_.py:32 | ok | test_construction | list(..) |
| collections_.py:33 | ok | test_construction | list(..) |
| collections_.py:34 | ok | test_construction | list(..) |
| collections_.py:35 | ok | test_construction | list(..) |
| collections_.py:36 | ok | test_construction | list(..) |
| collections_.py:38 | ok | test_construction | tuple(..) |
| collections_.py:39 | ok | test_construction | set(..) |
| collections_.py:40 | ok | test_construction | frozenset(..) |
| collections_.py:48 | ok | test_access | tainted_list[0] |
| collections_.py:49 | ok | test_access | tainted_list[x] |
| collections_.py:50 | ok | test_access | tainted_list[Slice] |
| collections_.py:52 | ok | test_access | sorted(..) |
| collections_.py:53 | ok | test_access | reversed(..) |
| collections_.py:54 | ok | test_access | iter(..) |
| collections_.py:55 | ok | test_access | next(..) |
| collections_.py:56 | ok | test_access | copy(..) |
| collections_.py:57 | ok | test_access | deepcopy(..) |
| collections_.py:61 | ok | test_access | a |
| collections_.py:61 | ok | test_access | b |
| collections_.py:61 | ok | test_access | c |
| collections_.py:64 | ok | test_access | h |
| collections_.py:66 | ok | test_access | i |
| collections_.py:73 | ok | test_dict_access | tainted_dict["name"] |
| collections_.py:74 | ok | test_dict_access | tainted_dict.get(..) |
| collections_.py:75 | ok | test_dict_access | tainted_dict[x] |
| collections_.py:76 | ok | test_dict_access | tainted_dict.copy() |
| collections_.py:80 | ok | test_dict_access | v |
| collections_.py:82 | ok | test_dict_access | v |
| collections_.py:90 | fail | test_named_tuple | point[0] |
| collections_.py:91 | fail | test_named_tuple | point.x |
| collections_.py:95 | ok | test_named_tuple | point[1] |
| collections_.py:96 | ok | test_named_tuple | point.y |
| collections_.py:100 | fail | test_named_tuple | a |
| collections_.py:101 | ok | test_named_tuple | b |
| collections_.py:109 | fail | test_defaultdict | tainted_default_dict["name"] |
| collections_.py:110 | fail | test_defaultdict | tainted_default_dict.get(..) |
| collections_.py:111 | fail | test_defaultdict | tainted_default_dict[x] |
| collections_.py:112 | fail | test_defaultdict | tainted_default_dict.copy() |
| collections_.py:115 | fail | test_defaultdict | v |
| collections_.py:117 | fail | test_defaultdict | v |
| collections_.py:124 | ok | list_index_assign | my_list |
| collections_.py:127 | fail | list_index_assign | my_list |
| collections_.py:134 | ok | list_index_aug_assign | my_list |
| collections_.py:137 | fail | list_index_aug_assign | my_list |
| collections_.py:144 | ok | list_append | my_list |
| collections_.py:147 | fail | list_append | my_list |
| json_.py:26 | ok | test | json.dumps(..) |
| json_.py:27 | ok | test | json.loads(..) |
| json_.py:34 | fail | test | tainted_filelike |
| json_.py:35 | fail | test | json.load(..) |
| json_.py:48 | fail | non_syntacical | dumps(..) |
| json_.py:49 | fail | non_syntacical | dumps_alias(..) |
| json_.py:50 | fail | non_syntacical | loads(..) |
| json_.py:57 | fail | non_syntacical | tainted_filelike |
| json_.py:58 | fail | non_syntacical | load(..) |
| string_.py:25 | ok | str_operations | ts |
| string_.py:26 | ok | str_operations | BinaryExpr |
| string_.py:27 | ok | str_operations | BinaryExpr |
| string_.py:28 | ok | str_operations | BinaryExpr |
| string_.py:29 | ok | str_operations | ts[Slice] |
| string_.py:30 | ok | str_operations | ts[Slice] |
| string_.py:31 | ok | str_operations | ts[Slice] |
| string_.py:32 | ok | str_operations | ts[0] |
| string_.py:33 | ok | str_operations | str(..) |
| string_.py:34 | ok | str_operations | bytes(..) |
| string_.py:35 | ok | str_operations | unicode(..) |
| string_.py:44 | ok | str_methods | ts.capitalize() |
| string_.py:45 | ok | str_methods | ts.center(..) |
| string_.py:46 | ok | str_methods | ts.expandtabs() |
| string_.py:48 | ok | str_methods | ts.format() |
| string_.py:49 | ok | str_methods | "{}".format(..) |
| string_.py:50 | ok | str_methods | "{unsafe}".format(..) |
| string_.py:52 | ok | str_methods | ts.join(..) |
| string_.py:53 | ok | str_methods | "".join(..) |
| string_.py:55 | ok | str_methods | ts.ljust(..) |
| string_.py:56 | ok | str_methods | ts.lstrip() |
| string_.py:57 | ok | str_methods | ts.lower() |
| string_.py:59 | ok | str_methods | ts.replace(..) |
| string_.py:60 | ok | str_methods | "safe".replace(..) |
| string_.py:62 | ok | str_methods | ts.rjust(..) |
| string_.py:63 | ok | str_methods | ts.rstrip() |
| string_.py:64 | ok | str_methods | ts.strip() |
| string_.py:65 | ok | str_methods | ts.swapcase() |
| string_.py:66 | ok | str_methods | ts.title() |
| string_.py:67 | ok | str_methods | ts.upper() |
| string_.py:68 | ok | str_methods | ts.zfill(..) |
| string_.py:70 | ok | str_methods | ts.encode(..) |
| string_.py:71 | ok | str_methods | ts.encode(..).decode(..) |
| string_.py:73 | ok | str_methods | tb.decode(..) |
| string_.py:74 | ok | str_methods | tb.decode(..).encode(..) |
| string_.py:77 | ok | str_methods | ts.partition(..) |
| string_.py:78 | ok | str_methods | ts.rpartition(..) |
| string_.py:79 | ok | str_methods | ts.rsplit(..) |
| string_.py:80 | ok | str_methods | ts.split(..) |
| string_.py:81 | ok | str_methods | ts.splitlines() |
| string_.py:86 | ok | str_methods | "safe".replace(..) |
| string_.py:88 | fail | str_methods | ts.join(..) |
| string_.py:89 | fail | str_methods | ts.join(..) |
| string_.py:99 | fail | non_syntactic | meth() |
| string_.py:100 | fail | non_syntactic | _str(..) |
| string_.py:109 | ok | percent_fmt | BinaryExpr |
| string_.py:110 | ok | percent_fmt | BinaryExpr |
| string_.py:111 | ok | percent_fmt | BinaryExpr |
| string_.py:121 | fail | binary_decode_encode | base64.b64encode(..) |
| string_.py:122 | fail | binary_decode_encode | base64.b64decode(..) |
| string_.py:124 | fail | binary_decode_encode | base64.standard_b64encode(..) |
| string_.py:125 | fail | binary_decode_encode | base64.standard_b64decode(..) |
| string_.py:127 | fail | binary_decode_encode | base64.urlsafe_b64encode(..) |
| string_.py:128 | fail | binary_decode_encode | base64.urlsafe_b64decode(..) |
| string_.py:130 | fail | binary_decode_encode | base64.b32encode(..) |
| string_.py:131 | fail | binary_decode_encode | base64.b32decode(..) |
| string_.py:133 | fail | binary_decode_encode | base64.b16encode(..) |
| string_.py:134 | fail | binary_decode_encode | base64.b16decode(..) |
| string_.py:137 | fail | binary_decode_encode | base64.encodestring(..) |
| string_.py:138 | fail | binary_decode_encode | base64.decodestring(..) |
| string_.py:143 | fail | binary_decode_encode | quopri.encodestring(..) |
| string_.py:144 | fail | binary_decode_encode | quopri.decodestring(..) |
| unpacking_.py:16 | ok | unpacking | a |
| unpacking_.py:16 | ok | unpacking | b |
| unpacking_.py:16 | ok | unpacking | c |
| unpacking_.py:22 | ok | unpacking_to_list | a |
| unpacking_.py:22 | ok | unpacking_to_list | b |
| unpacking_.py:22 | ok | unpacking_to_list | c |
| unpacking_.py:31 | ok | nested | a1 |
| unpacking_.py:31 | ok | nested | a2 |
| unpacking_.py:31 | ok | nested | a3 |
| unpacking_.py:31 | ok | nested | b |
| unpacking_.py:31 | ok | nested | c |
| unpacking_.py:35 | ok | nested | a1 |
| unpacking_.py:35 | ok | nested | a2 |
| unpacking_.py:35 | ok | nested | a3 |
| unpacking_.py:35 | ok | nested | b |
| unpacking_.py:35 | ok | nested | c |
| unpacking_.py:39 | ok | nested | a1 |
| unpacking_.py:39 | ok | nested | a2 |
| unpacking_.py:39 | ok | nested | a3 |
| unpacking_.py:39 | ok | nested | b |
| unpacking_.py:39 | ok | nested | c |
| unpacking_.py:46 | ok | unpack_from_set | a |
| unpacking_.py:46 | ok | unpack_from_set | b |
| unpacking_.py:46 | ok | unpack_from_set | c |
| unpacking_.py:56 | ok | contrived_1 | a |
| unpacking_.py:56 | ok | contrived_1 | b |
| unpacking_.py:56 | ok | contrived_1 | c |
| unpacking_.py:57 | fail | contrived_1 | d |
| unpacking_.py:57 | fail | contrived_1 | e |
| unpacking_.py:57 | fail | contrived_1 | f |
| unpacking_.py:65 | ok | contrived_2 | a |
| unpacking_.py:65 | ok | contrived_2 | b |
| unpacking_.py:65 | ok | contrived_2 | c |

View File

@@ -117,16 +117,6 @@ def test_defaultdict(key, x): # TODO: defaultdict currently not handled
ensure_tainted(v)
def list_clear():
tainted_string = TAINTED_STRING
tainted_list = [tainted_string]
ensure_tainted(tainted_list)
tainted_list.clear()
ensure_not_tainted(tainted_list)
def list_index_assign():
tainted_string = TAINTED_STRING
my_list = ["safe"]
@@ -164,3 +154,7 @@ test_access(0, 0, 2)
test_dict_access("name")
test_named_tuple()
test_defaultdict("key", "key")
list_index_assign()
list_index_aug_assign()
list_append()

View File

@@ -133,18 +133,6 @@ def binary_decode_encode():
base64.b16encode(tb),
base64.b16decode(base64.b16encode(tb)),
# # New in Python 3.4
# base64.a85encode(tb),
# base64.a85decode(base64.a85encode(tb)),
# # New in Python 3.4
# base64.b85encode(tb),
# base64.b85decode(base64.b85encode(tb)),
# # New in Python 3.1
# base64.encodebytes(tb),
# base64.decodebytes(base64.encodebytes(tb)),
# deprecated since Python 3.1, but still works
base64.encodestring(tb),
base64.decodestring(base64.encodestring(tb)),