Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ def extract_zip_contents(
io.BytesIO(file_bytes) if isinstance(file_bytes, bytes) else file_bytes
)
with zipfile.ZipFile(stream) as zf:
for name in zf.namelist():
with zf.open(name) as f:
yield name, f
for info in zf.infolist():
with zf.open(info) as f:
yield info.filename, f


def is_bz2_bytes(file_bytes: bytes | BinaryIO) -> bool:
Expand Down
5 changes: 3 additions & 2 deletions saferpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,8 @@ def _extract_and_scan_archive(
if archive_type == "zip":
try:
with zipfile.ZipFile(io.BytesIO(data)) as zf:
for name in zf.namelist():
for info in zf.infolist():
name = info.filename
if ".." in name or name.startswith("/"):
# Zip slip detection
logging.warning("Zip slip detected: %s", name)
Expand All @@ -1097,7 +1098,7 @@ def _extract_and_scan_archive(
"unknown": 0,
} # Return early

with zf.open(name) as f:
with zf.open(info) as f:
content = f.read()
scores = security_scan(
content,
Expand Down