From 34253f1de1ae27affcf1f7fc05440506638b9650 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sat, 24 Dec 2022 07:33:55 +0100 Subject: dev-python/future: Patch ReDoS copied from stdlib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://bugs.gentoo.org/888109 Signed-off-by: Michał Górny --- .../files/future-0.18.2-cve-2022-40899.patch | 52 ++++++++++++++++++++++ dev-python/future/future-0.18.2-r2.ebuild | 40 ----------------- dev-python/future/future-0.18.2-r3.ebuild | 47 +++++++++++++++++++ 3 files changed, 99 insertions(+), 40 deletions(-) create mode 100644 dev-python/future/files/future-0.18.2-cve-2022-40899.patch delete mode 100644 dev-python/future/future-0.18.2-r2.ebuild create mode 100644 dev-python/future/future-0.18.2-r3.ebuild (limited to 'dev-python/future') diff --git a/dev-python/future/files/future-0.18.2-cve-2022-40899.patch b/dev-python/future/files/future-0.18.2-cve-2022-40899.patch new file mode 100644 index 000000000000..c7341e0d6fdb --- /dev/null +++ b/dev-python/future/files/future-0.18.2-cve-2022-40899.patch @@ -0,0 +1,52 @@ +From c91d70b34ef0402aef3e9d04364ba98509dca76f Mon Sep 17 00:00:00 2001 +From: Will Shanks +Date: Fri, 23 Dec 2022 13:38:26 -0500 +Subject: [PATCH] Backport fix for bpo-38804 + +The regex http.cookiejar.LOOSE_HTTP_DATE_RE was vulnerable to regular +expression denial of service (REDoS). The regex contained multiple +overlapping \s* capture groups. A long sequence of spaces can trigger +bad performance. + +See https://github.com/python/cpython/pull/17157 and https://pyup.io/posts/pyup-discovers-redos-vulnerabilities-in-top-python-packages/ +--- + src/future/backports/http/cookiejar.py | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +diff --git a/src/future/backports/http/cookiejar.py b/src/future/backports/http/cookiejar.py +index af3ef415..0ad80a02 100644 +--- a/src/future/backports/http/cookiejar.py ++++ b/src/future/backports/http/cookiejar.py +@@ -225,10 +225,14 @@ def _str2time(day, mon, yr, hr, min, sec, tz): + (?::(\d\d))? # optional seconds + )? # optional clock + \s* +- ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone ++ (?: ++ ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+) # timezone ++ \s* ++ )? ++ (?: ++ \(\w+\) # ASCII representation of timezone in parens. + \s* +- (?:\(\w+\))? # ASCII representation of timezone in parens. +- \s*$""", re.X | re.ASCII) ++ )?$""", re.X | re.ASCII) + def http2time(text): + """Returns time in seconds since epoch of time represented by a string. + +@@ -298,9 +302,11 @@ def http2time(text): + (?::?(\d\d(?:\.\d*)?))? # optional seconds (and fractional) + )? # optional clock + \s* +- ([-+]?\d\d?:?(:?\d\d)? +- |Z|z)? # timezone (Z is "zero meridian", i.e. GMT) +- \s*$""", re.X | re. ASCII) ++ (?: ++ ([-+]?\d\d?:?(:?\d\d)? ++ |Z|z) # timezone (Z is "zero meridian", i.e. GMT) ++ \s* ++ )?$""", re.X | re. ASCII) + def iso2time(text): + """ + As for http2time, but parses the ISO 8601 formats: diff --git a/dev-python/future/future-0.18.2-r2.ebuild b/dev-python/future/future-0.18.2-r2.ebuild deleted file mode 100644 index 1558c0ea92ce..000000000000 --- a/dev-python/future/future-0.18.2-r2.ebuild +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -DISTUTILS_USE_PEP517=setuptools -PYTHON_COMPAT=( python3_{8..11} pypy3 ) -inherit distutils-r1 - -DESCRIPTION="Easy, clean, reliable Python 2/3 compatibility" -HOMEPAGE="https://python-future.org/" -SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" - -LICENSE="MIT" -SLOT="0" -KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux" - -BDEPEND=" - test? ( - $(python_gen_cond_dep ' - dev-python/numpy[${PYTHON_USEDEP}] - ' 'python*') - )" - -distutils_enable_tests pytest -distutils_enable_sphinx docs dev-python/sphinx-bootstrap-theme - -PATCHES=( - "${FILESDIR}"/${P}-tests.patch - "${FILESDIR}"/${P}-py39.patch - "${FILESDIR}"/${P}-py39-fileurl.patch - "${FILESDIR}"/${P}-py3.10.patch -) - -EPYTEST_DESELECT=( - # tests requiring network access - tests/test_future/test_requests.py - tests/test_future/test_standard_library.py::TestStandardLibraryReorganization::test_moves_urllib_request_http - tests/test_future/test_standard_library.py::TestStandardLibraryReorganization::test_urllib_request_http -) diff --git a/dev-python/future/future-0.18.2-r3.ebuild b/dev-python/future/future-0.18.2-r3.ebuild new file mode 100644 index 000000000000..a05bf7f207d5 --- /dev/null +++ b/dev-python/future/future-0.18.2-r3.ebuild @@ -0,0 +1,47 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( python3_{8..11} pypy3 ) + +inherit distutils-r1 + +DESCRIPTION="Easy, clean, reliable Python 2/3 compatibility" +HOMEPAGE=" + https://python-future.org/ + https://github.com/PythonCharmers/python-future/ + https://pypi.org/project/future/ +" +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux" + +BDEPEND=" + test? ( + $(python_gen_cond_dep ' + dev-python/numpy[${PYTHON_USEDEP}] + ' 'python*') + ) +" + +distutils_enable_tests pytest +distutils_enable_sphinx docs dev-python/sphinx-bootstrap-theme + +PATCHES=( + "${FILESDIR}"/${P}-tests.patch + "${FILESDIR}"/${P}-py39.patch + "${FILESDIR}"/${P}-py39-fileurl.patch + "${FILESDIR}"/${P}-py3.10.patch + "${FILESDIR}"/${P}-cve-2022-40899.patch +) + +EPYTEST_DESELECT=( + # tests requiring network access + tests/test_future/test_requests.py + tests/test_future/test_standard_library.py::TestStandardLibraryReorganization::test_moves_urllib_request_http + tests/test_future/test_standard_library.py::TestStandardLibraryReorganization::test_urllib_request_http +) -- cgit v1.2.3-65-gdbad