Compare commits
No commits in common. "55051c2e64b9ecb67fd9fa154ec412f7875e3787" and "4be6d4259e53aa6c4e897e61f3ccf60e231a7c0d" have entirely different histories.
55051c2e64
...
4be6d4259e
9
0001-add-setup.py.patch
Normal file
9
0001-add-setup.py.patch
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
--- a/setup.py 1970-01-01 08:00:00.000000000 +0800
|
||||||
|
+++ b/setup.py 2022-10-19 09:38:57.746598491 +0800
|
||||||
|
@@ -0,0 +1,6 @@
|
||||||
|
+#!/usr/bin/env python
|
||||||
|
+
|
||||||
|
+from setuptools import setup
|
||||||
|
+
|
||||||
|
+if __name__ == "__main__":
|
||||||
|
+ setup()
|
||||||
@ -1,114 +0,0 @@
|
|||||||
From fd604bd34f0343472521a36da1fbd22e793e14fd Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Jason R. Coombs" <jaraco@jaraco.com>
|
|
||||||
Date: Fri, 31 May 2024 12:31:40 -0400
|
|
||||||
Subject: [PATCH] Merge pull request #120 from jaraco/bugfix/119-malformed-paths
|
|
||||||
|
|
||||||
Sanitize malformed paths
|
|
||||||
---
|
|
||||||
tests/test_path.py | 17 ++++++++++++
|
|
||||||
zipp/__init__.py | 64 +++++++++++++++++++++++++++++++++++++++++++++-
|
|
||||||
2 files changed, 80 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/tests/test_path.py b/tests/test_path.py
|
|
||||||
index 9504821..0e0ee43 100644
|
|
||||||
--- a/tests/test_path.py
|
|
||||||
+++ b/tests/test_path.py
|
|
||||||
@@ -582,3 +582,20 @@ class TestPath(unittest.TestCase):
|
|
||||||
zipp.Path(alpharep)
|
|
||||||
with self.assertRaises(KeyError):
|
|
||||||
alpharep.getinfo('does-not-exist')
|
|
||||||
+
|
|
||||||
+ def test_malformed_paths(self):
|
|
||||||
+ """
|
|
||||||
+ Path should handle malformed paths.
|
|
||||||
+ """
|
|
||||||
+ data = io.BytesIO()
|
|
||||||
+ zf = zipfile.ZipFile(data, "w")
|
|
||||||
+ zf.writestr("/one-slash.txt", b"content")
|
|
||||||
+ zf.writestr("//two-slash.txt", b"content")
|
|
||||||
+ zf.writestr("../parent.txt", b"content")
|
|
||||||
+ zf.filename = ''
|
|
||||||
+ root = zipp.Path(zf)
|
|
||||||
+ assert list(map(str, root.iterdir())) == [
|
|
||||||
+ 'one-slash.txt',
|
|
||||||
+ 'two-slash.txt',
|
|
||||||
+ 'parent.txt',
|
|
||||||
+ ]
|
|
||||||
diff --git a/zipp/__init__.py b/zipp/__init__.py
|
|
||||||
index 3354c2b..79efbe0 100644
|
|
||||||
--- a/zipp/__init__.py
|
|
||||||
+++ b/zipp/__init__.py
|
|
||||||
@@ -84,7 +84,69 @@ class InitializedState:
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
-class CompleteDirs(InitializedState, zipfile.ZipFile):
|
|
||||||
+class SanitizedNames:
|
|
||||||
+ """
|
|
||||||
+ ZipFile mix-in to ensure names are sanitized.
|
|
||||||
+ """
|
|
||||||
+
|
|
||||||
+ def namelist(self):
|
|
||||||
+ return list(map(self._sanitize, super().namelist()))
|
|
||||||
+
|
|
||||||
+ @staticmethod
|
|
||||||
+ def _sanitize(name):
|
|
||||||
+ r"""
|
|
||||||
+ Ensure a relative path with posix separators and no dot names.
|
|
||||||
+
|
|
||||||
+ Modeled after
|
|
||||||
+ https://github.com/python/cpython/blob/bcc1be39cb1d04ad9fc0bd1b9193d3972835a57c/Lib/zipfile/__init__.py#L1799-L1813
|
|
||||||
+ but provides consistent cross-platform behavior.
|
|
||||||
+
|
|
||||||
+ >>> san = SanitizedNames._sanitize
|
|
||||||
+ >>> san('/foo/bar')
|
|
||||||
+ 'foo/bar'
|
|
||||||
+ >>> san('//foo.txt')
|
|
||||||
+ 'foo.txt'
|
|
||||||
+ >>> san('foo/.././bar.txt')
|
|
||||||
+ 'foo/bar.txt'
|
|
||||||
+ >>> san('foo../.bar.txt')
|
|
||||||
+ 'foo../.bar.txt'
|
|
||||||
+ >>> san('\\foo\\bar.txt')
|
|
||||||
+ 'foo/bar.txt'
|
|
||||||
+ >>> san('D:\\foo.txt')
|
|
||||||
+ 'D/foo.txt'
|
|
||||||
+ >>> san('\\\\server\\share\\file.txt')
|
|
||||||
+ 'server/share/file.txt'
|
|
||||||
+ >>> san('\\\\?\\GLOBALROOT\\Volume3')
|
|
||||||
+ '?/GLOBALROOT/Volume3'
|
|
||||||
+ >>> san('\\\\.\\PhysicalDrive1\\root')
|
|
||||||
+ 'PhysicalDrive1/root'
|
|
||||||
+
|
|
||||||
+ Retain any trailing slash.
|
|
||||||
+ >>> san('abc/')
|
|
||||||
+ 'abc/'
|
|
||||||
+
|
|
||||||
+ Raises a ValueError if the result is empty.
|
|
||||||
+ >>> san('../..')
|
|
||||||
+ Traceback (most recent call last):
|
|
||||||
+ ...
|
|
||||||
+ ValueError: Empty filename
|
|
||||||
+ """
|
|
||||||
+
|
|
||||||
+ def allowed(part):
|
|
||||||
+ return part and part not in {'..', '.'}
|
|
||||||
+
|
|
||||||
+ # Remove the drive letter.
|
|
||||||
+ # Don't use ntpath.splitdrive, because that also strips UNC paths
|
|
||||||
+ bare = re.sub('^([A-Z]):', r'\1', name, flags=re.IGNORECASE)
|
|
||||||
+ clean = bare.replace('\\', '/')
|
|
||||||
+ parts = clean.split('/')
|
|
||||||
+ joined = '/'.join(filter(allowed, parts))
|
|
||||||
+ if not joined:
|
|
||||||
+ raise ValueError("Empty filename")
|
|
||||||
+ return joined + '/' * name.endswith('/')
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+class CompleteDirs(InitializedState, SanitizedNames, zipfile.ZipFile):
|
|
||||||
"""
|
|
||||||
A ZipFile subclass that ensures that implied directories
|
|
||||||
are always included in the namelist.
|
|
||||||
--
|
|
||||||
2.45.2
|
|
||||||
|
|
||||||
@ -1,21 +1,23 @@
|
|||||||
%global _empty_manifest_terminate_build 0
|
%global _empty_manifest_terminate_build 0
|
||||||
Name: python-zipp
|
Name: python-zipp
|
||||||
Version: 3.17.0
|
Version: 3.11.0
|
||||||
Release: 2
|
Release: 1
|
||||||
Summary: Backport of pathlib-compatible object wrapper for zip files
|
Summary: Backport of pathlib-compatible object wrapper for zip files
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: https://github.com/jaraco/zipp
|
URL: https://github.com/jaraco/zipp
|
||||||
Source0: https://pypi.io/packages/source/z/zipp/zipp-%{version}.tar.gz
|
Source0: https://files.pythonhosted.org/packages/8e/b3/8b16a007184714f71157b1a71bbe632c5d66dd43bc8152b3c799b13881e1/zipp-3.11.0.tar.gz
|
||||||
# https://github.com/jaraco/zipp/commit/fd604bd34f0343472521a36da1fbd22e793e14fd
|
Patch0: 0001-add-setup.py.patch
|
||||||
Patch3000: backport-CVE-2024-5569.patch
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
|
Requires: python3-toml
|
||||||
|
Requires: python3-setuptools_scm
|
||||||
|
|
||||||
%description
|
%description
|
||||||
A pathlib-compatible Zipfile object wrapper. A backport of the Path object.
|
A pathlib-compatible Zipfile object wrapper. A backport of the Path object.
|
||||||
|
|
||||||
%package -n python3-zipp
|
%package -n python3-zipp
|
||||||
Summary: Backport of pathlib-compatible object wrapper for zip files
|
Summary: Backport of pathlib-compatible object wrapper for zip files
|
||||||
Provides: python-zipp = %{version}-%{release}
|
Provides: python-zipp
|
||||||
BuildRequires: python3-devel
|
BuildRequires: python3-devel
|
||||||
BuildRequires: python3-setuptools
|
BuildRequires: python3-setuptools
|
||||||
BuildRequires: python3-pbr
|
BuildRequires: python3-pbr
|
||||||
@ -26,62 +28,45 @@ BuildRequires: python3-toml
|
|||||||
BuildRequires: python3-pytest
|
BuildRequires: python3-pytest
|
||||||
BuildRequires: python3-more-itertools
|
BuildRequires: python3-more-itertools
|
||||||
BuildRequires: python3-jaraco-functools
|
BuildRequires: python3-jaraco-functools
|
||||||
BuildRequires: shadow
|
BuildRequires: shadow
|
||||||
|
|
||||||
%description -n python3-zipp
|
%description -n python3-zipp
|
||||||
A pathlib-compatible Zipfile object wrapper. A backport of the Path object.
|
A pathlib-compatible Zipfile object wrapper. A backport of the Path object.
|
||||||
|
|
||||||
%package help
|
%package help
|
||||||
Summary: Development documents and examples for zipp
|
Summary: Development documents and examples for zipp
|
||||||
Provides: python3-zipp-doc
|
Provides: python3-zipp-doc
|
||||||
|
|
||||||
%description help
|
%description help
|
||||||
A pathlib-compatible Zipfile object wrapper. A backport of the Path object.
|
A pathlib-compatible Zipfile object wrapper. A backport of the Path object.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n zipp-%{version} -p1
|
%autosetup -n zipp-%{version}
|
||||||
|
%patch0
|
||||||
# Skip tests that depend on jaraco.itertools
|
# Skip tests that depend on jaraco.itertools
|
||||||
sed -i "/import jaraco.itertools/d" tests/test_path.py
|
sed -i "/import jaraco.itertools/d" tests/test_zipp.py
|
||||||
|
sed -i "/func_timeout/d" tests/test_zipp.py
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%pyproject_build
|
%_bindir/python3 setup.py build '--executable=%_bindir/python3 -s'
|
||||||
|
|
||||||
%install
|
%install
|
||||||
%pyproject_install zipp==%{version}
|
%_bindir/python3 setup.py install -O1 --skip-build --root %buildroot
|
||||||
install -d -m755 %{buildroot}/%{_pkgdocdir}
|
|
||||||
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
|
|
||||||
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
|
|
||||||
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
|
|
||||||
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
|
|
||||||
if [ -f README.rst ]; then cp -af README.rst %{buildroot}/%{_pkgdocdir}; fi
|
|
||||||
if [ -f README.md ]; then cp -af README.md %{buildroot}/%{_pkgdocdir}; fi
|
|
||||||
if [ -f README.txt ]; then cp -af README.txt %{buildroot}/%{_pkgdocdir}; fi
|
|
||||||
|
|
||||||
%check
|
%check
|
||||||
pytest -k "not test_joinpath_constant_time"
|
pytest -k "not test_joinpath_constant_time"
|
||||||
|
|
||||||
%files -n python3-zipp
|
%files -n python3-zipp
|
||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
%{python3_sitelib}/*
|
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
|
%_prefix/lib/python%{python3_version}/site-packages/zipp*
|
||||||
|
%_prefix/lib/python%{python3_version}/site-packages/a/*
|
||||||
|
|
||||||
%files help
|
%files help
|
||||||
%{_docdir}/*
|
%defattr(-,root,root)
|
||||||
|
%doc README.rst
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Mon Jul 22 2024 yaoxin <yao_xin001@hoperun.com> - 3.17.0-2
|
|
||||||
- Fix CVE-2024-5569
|
|
||||||
|
|
||||||
* Mon Sep 11 2023 xu_ping <707078654@qq.com> - 3.17.0-1
|
|
||||||
- Upgrade version to 3.17.0
|
|
||||||
|
|
||||||
* Wed Apr 26 2023 wangjunqi <wangjunqi@kylinos.cn> - 3.15.0-2
|
|
||||||
- apply pyproject.toml
|
|
||||||
|
|
||||||
* Fri Mar 17 2023 wangjunqi <wangjunqi@kylinos.cn> - 3.15.0-1
|
|
||||||
- Update package to version 3.15.0
|
|
||||||
|
|
||||||
* Mon Feb 27 2023 wangkai <wangkai385@h-partners.com> - 3.11.0-2
|
|
||||||
- Modify the patching method
|
|
||||||
|
|
||||||
* Fri Dec 16 2022 liqiuyu <liqiuyu@kylinos.cn> - 3.11.0-1
|
* Fri Dec 16 2022 liqiuyu <liqiuyu@kylinos.cn> - 3.11.0-1
|
||||||
- Update package to version 3.11.0
|
- Update package to version 3.11.0
|
||||||
|
|
||||||
@ -105,3 +90,4 @@ pytest -k "not test_joinpath_constant_time"
|
|||||||
|
|
||||||
* Tue Feb 11 2020 huzunhao<huzunhao2@huawei.com> - 0.5.1-1
|
* Tue Feb 11 2020 huzunhao<huzunhao2@huawei.com> - 0.5.1-1
|
||||||
- Package init
|
- Package init
|
||||||
|
|
||||||
|
|||||||
BIN
zipp-3.11.0.tar.gz
Normal file
BIN
zipp-3.11.0.tar.gz
Normal file
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user