File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
python/ql/test/query-tests/Security/CWE-022 Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -50,3 +50,19 @@ def safemembers(members):
50
50
51
51
tar = tarfile .open (unsafe_filename_tar )
52
52
tar .extractall (members = safemembers (tar ))
53
+
54
+
55
+ # Wrong sanitizer (is missing not)
56
+ tar = tarfile .open (unsafe_filename_tar )
57
+ for entry in tar :
58
+ if os .path .isabs (entry .name ) or ".." in entry .name :
59
+ tar .extract (entry , "/tmp/unpack/" ) # TODO: FN
60
+
61
+
62
+ # OK Sanitized using not
63
+ tar = tarfile .open (unsafe_filename_tar )
64
+ for entry in tar :
65
+ # using `if not (os.path.isabs(entry.name) or ".." in entry.name):`
66
+ # would make the sanitizer work, but for the wrong reasons since out library is a bit broken.
67
+ if not os .path .isabs (entry .name ):
68
+ tar .extract (entry , "/tmp/unpack/" )
You can’t perform that action at this time.
0 commit comments