Fix safe_extract_tarball: pass safe_members to extractall on Python 3.12+

This commit is contained in:
copilot-swe-agent[bot]
2026-05-11 15:28:48 +00:00
committed by GitHub
parent 0825f508a7
commit a8320d9b61

View File

@@ -227,10 +227,10 @@ def safe_extract_tarball(
safe_members.append(member)
# Extract — use the "data" filter on Python 3.12+ for extra hardening.
# On older versions pass only the pre-validated members so that no
# On all versions pass only the pre-validated members so that no
# unvetted entry (added concurrently or via a race) slips through.
if sys.version_info >= (3, 12):
tf.extractall(dest_dir, filter="data") # type: ignore[call-arg]
tf.extractall(dest_dir, members=safe_members, filter="data") # type: ignore[call-arg]
else:
tf.extractall(dest_dir, members=safe_members) # noqa: S202 — validated above
except error_class: