File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
python/ql/test/query-tests/Security/CWE-022 Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,21 @@ def safemembers(members):
62
62
# OK Sanitized using not
63
63
tar = tarfile .open (unsafe_filename_tar )
64
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.
65
+ if not (os .path .isabs (entry .name ) or ".." in entry .name ):
66
+ tar .extract (entry , "/tmp/unpack/" )
67
+
68
+ # The following two variants are included by purpose, since by default there is a
69
+ # difference in handling `not x` and `not (x or False)` when overriding
70
+ # Sanitizer.sanitizingEdge. We want to ensure we handle both consistently.
71
+
72
+ # Not reported, although vulnerable to '..'
73
+ tar = tarfile .open (unsafe_filename_tar )
74
+ for entry in tar :
75
+ if not (os .path .isabs (entry .name ) or False ):
76
+ tar .extract (entry , "/tmp/unpack/" )
77
+
78
+ # Not reported, although vulnerable to '..'
79
+ tar = tarfile .open (unsafe_filename_tar )
80
+ for entry in tar :
67
81
if not os .path .isabs (entry .name ):
68
82
tar .extract (entry , "/tmp/unpack/" )
You can’t perform that action at this time.
0 commit comments