Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CVE-2007-4559 Patch #829

Merged
merged 11 commits into from
Oct 5, 2022
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Removed
- Removed upper bound of Python 4 on ``python_requires`` (#781).
- Dropped support for Python 3.6 and Python 3.7 (#715) following the recommended support schedules of `NEP 29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`__.
- Dropped dependency on ``deprecation`` package (#687, #718).
- Removed unused ``_extract`` utility function to avoid CVE-2007-4559 (#829).

[1.7.0] -- 2021-06-08
---------------------
Expand Down
37 changes: 0 additions & 37 deletions signac/contrib/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
import logging
import os
import sys
import tarfile
import zipfile
from collections.abc import Mapping
from contextlib import contextmanager
from datetime import timedelta
from tempfile import TemporaryDirectory
from time import time

from ..common.deprecation import deprecated
Expand Down Expand Up @@ -339,39 +335,6 @@ def split_and_print_progress(iterable, num_chunks=10, write=None, desc="Progress
yield iterable


@contextmanager
def _extract(filename):
"""Extract zipfile and tarfile.

Parameters
----------
filename : str
Name of zipfile/tarfile to extract.

Yields
------
str
Path to the extracted directory.

Raises
------
RuntimeError
When the provided file is neither a zipfile nor a tarfile.

"""
with TemporaryDirectory() as tmpdir:
if zipfile.is_zipfile(filename):
with zipfile.ZipFile(filename) as file:
file.extractall(tmpdir)
yield tmpdir
elif tarfile.is_tarfile(filename):
with tarfile.open(filename) as file:
file.extractall(path=tmpdir)
yield tmpdir
else:
raise RuntimeError(f"Unknown file type: '{filename}'.")


def _dotted_dict_to_nested_dicts(dotted_dict, delimiter_nested="."):
"""Convert dotted keys in the state point dict to a nested dict.

Expand Down