We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f364e41 commit cafbd98Copy full SHA for cafbd98
python/ql/src/experimental/Security/CWE-022/zipslip_bad.py
@@ -2,13 +2,15 @@
2
import shutil
3
4
def unzip(filename):
5
- with zipfile.ZipFile(filename) as zipf:
+ with tarfile.open(filename) as zipf:
6
#BAD : This could write any file on the filesystem.
7
for entry in zipf:
8
- shutil.copy(entry, "/tmp/unpack/")
+ shutil.copyfile(entry, "/tmp/unpack/")
9
10
-def unzip1(filename):
11
12
- for entry in zipf:
13
- with open(entry, 'wb') as dstfile:
14
- shutil.copyfileobj(zipf, dstfile)
+def unzip4(filename):
+ zf = zipfile.ZipFile(filename)
+ filelist = zf.namelist()
+ for filename in filelist:
+ with zf.open(filename) as srcf:
15
+ shutil.copyfileobj(srcf, dstfile)
16
+
0 commit comments