Update zipslip_good.py

This commit is contained in:
Ahmed Farid
2022-03-08 23:55:17 +01:00
committed by GitHub
parent 3b8c7e8944
commit 23bd53a325

View File

@@ -1,4 +1,6 @@
import zipfile
import tarfile
import shutil
def unzip(filename, dir):
zf = zipfile.ZipFile(filename)
@@ -8,3 +10,11 @@ def unzip(filename, dir):
def unzip1(filename, dir):
zf = zipfile.ZipFile(filename)
zf.extract(dir)
def unzip2(filename):
with tarfile.open(filename) as tar:
for entry in tar:
#GOOD: Check that entry is safe
if os.path.isabs(entry.name) or ".." in entry.name:
raise ValueError("Illegal tar archive entry")
shutil.copy(entry, "/tmp/unpack/")