Update to version 2.31.0

This commit is contained in:
lingjuer 2023-07-13 15:41:03 +08:00
parent c1f7bf198e
commit 8b1af613bc
8 changed files with 66 additions and 171 deletions

View File

@ -1,55 +0,0 @@
From 38c03ce77f9f5fd0f65cc4dcdf0f321d7aa01cb0 Mon Sep 17 00:00:00 2001
From: starlet-dx <15929766099@163.com>
Date: Wed, 11 Jan 2023 11:00:46 +0800
Subject: [PATCH 1/1] Allow charset normalizer >=2 and <4 (#6261)
---
requests/__init__.py | 4 ++--
setup.cfg | 2 +-
setup.py | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/requests/__init__.py b/requests/__init__.py
index 7ac8e29..22db3c1 100644
--- a/requests/__init__.py
+++ b/requests/__init__.py
@@ -80,8 +80,8 @@ def check_compatibility(urllib3_version, chardet_version, charset_normalizer_ver
elif charset_normalizer_version:
major, minor, patch = charset_normalizer_version.split(".")[:3]
major, minor, patch = int(major), int(minor), int(patch)
- # charset_normalizer >= 2.0.0 < 3.0.0
- assert (2, 0, 0) <= (major, minor, patch) < (3, 0, 0)
+ # charset_normalizer >= 2.0.0 < 4.0.0
+ assert (2, 0, 0) <= (major, minor, patch) < (4, 0, 0)
else:
raise Exception("You need either charset_normalizer or chardet installed")
diff --git a/setup.cfg b/setup.cfg
index 0a94be6..906c0f1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -4,7 +4,7 @@ provides-extra =
socks
use_chardet_on_py3
requires-dist =
- charset_normalizer>=2,<3
+ charset_normalizer>=2,<4
idna>=2.5,<4
urllib3>=1.21.1,<1.27
diff --git a/setup.py b/setup.py
index 599533c..c6c0ad5 100755
--- a/setup.py
+++ b/setup.py
@@ -59,7 +59,7 @@ if sys.argv[-1] == "publish":
sys.exit()
requires = [
- "charset_normalizer>=2,<3",
+ "charset_normalizer>=2,<4",
"idna>=2.5,<4",
"urllib3>=1.21.1,<1.27",
]
--
2.30.0

View File

@ -1,59 +0,0 @@
From 74ea7cf7a6a27a4eeb2ae24e162bcc942a6706d5 Mon Sep 17 00:00:00 2001
From: Nate Prewitt <nate.prewitt@gmail.com>
Date: Mon, 22 May 2023 08:08:57 -0700
Subject: [PATCH] Merge pull request from GHSA-j8r2-6x86-q33q
Reference:https://github.com/psf/requests/commit/74ea7cf7a6a27a4eeb2ae24e162bcc942a6706d5
Conflict:NA
---
requests/sessions.py | 4 +++-
tests/test_requests.py | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/requests/sessions.py b/requests/sessions.py
index 6cb3b4dae3..dbcf2a7b0e 100644
--- a/requests/sessions.py
+++ b/requests/sessions.py
@@ -324,7 +324,9 @@ def rebuild_proxies(self, prepared_request, proxies):
except KeyError:
username, password = None, None
- if username and password:
+ # urllib3 handles proxy authorization for us in the standard adapter.
+ # Avoid appending this to TLS tunneled requests where it may be leaked.
+ if not scheme.startswith('https') and username and password:
headers["Proxy-Authorization"] = _basic_auth_str(username, password)
return new_proxies
diff --git a/tests/test_requests.py b/tests/test_requests.py
index b1c8dd4534..b420c44d73 100644
--- a/tests/test_requests.py
+++ b/tests/test_requests.py
@@ -647,6 +647,26 @@ def test_proxy_authorization_preserved_on_request(self, httpbin):
assert sent_headers.get("Proxy-Authorization") == proxy_auth_value
+
+ @pytest.mark.parametrize(
+ "url,has_proxy_auth",
+ (
+ ('http://example.com', True),
+ ('https://example.com', False),
+ ),
+ )
+ def test_proxy_authorization_not_appended_to_https_request(self, url, has_proxy_auth):
+ session = requests.Session()
+ proxies = {
+ 'http': 'http://test:pass@localhost:8080',
+ 'https': 'http://test:pass@localhost:8090',
+ }
+ req = requests.Request('GET', url)
+ prep = req.prepare()
+ session.rebuild_proxies(prep, proxies)
+
+ assert ('Proxy-Authorization' in prep.headers) is has_proxy_auth
+
def test_basicauth_with_netrc(self, httpbin):
auth = ("user", "pass")
wrong_auth = ("wronguser", "wrongpass")

View File

@ -1,37 +0,0 @@
--- requests-2.28.1/requests/certs.py 2022-07-12 13:55:25.378079641 -0700
+++ requests-2.28.1/requests/certs.py.new 2022-07-12 13:57:03.834621295 -0700
@@ -9,8 +9,13 @@
If you are packaging Requests, e.g., for a Linux distribution or a managed
environment, you can change the definition of where() to return a separately
packaged CA bundle.
+
+This OpenEuler-patched package returns "/etc/pki/tls/certs/ca-bundle.crt" provided
+by the ca-certificates RPM package.
"""
-from certifi import where
+def where():
+ """Return the absolute path to the system CA bundle."""
+ return '/etc/pki/tls/certs/ca-bundle.crt'
if __name__ == "__main__":
print(where())
--- requests-2.28.1/setup.py 2022-06-29 08:09:11.000000000 -0700
+++ requests-2.28.1/setup.py.new 2022-07-12 13:58:33.830116402 -0700
@@ -62,7 +62,6 @@
"charset_normalizer>=2,<3",
"idna>=2.5,<4",
"urllib3>=1.21.1,<1.27",
- "certifi>=2017.4.17",
]
test_requirements = [
"pytest-httpbin==0.0.7",
--- requests-2.28.1/setup.cfg 2022-06-29 08:09:11.000000000 -0700
+++ requests-2.28.1/setup.cfg.new 2022-07-12 13:58:19.619038220 -0700
@@ -4,7 +4,6 @@
socks
use_chardet_on_py3
requires-dist =
- certifi>=2017.4.17
charset_normalizer>=2,<3
idna>=2.5,<4
urllib3>=1.21.1,<1.27

View File

@ -1,11 +0,0 @@
--- requests-2.28.1/tests/testserver/server.py 2022-06-29 08:09:11.000000000 -0700
+++ requests-2.28.1/tests/testserver/server.py.new 2022-07-12 14:04:30.218077055 -0700
@@ -29,7 +29,7 @@
def __init__(
self,
handler=None,
- host="localhost",
+ host="127.0.0.1",
port=0,
requests_to_handle=1,
wait_to_close_event=None,

View File

@ -0,0 +1,58 @@
From c8ed737d0390497b63c410a8239fea425c62a757 Mon Sep 17 00:00:00 2001
From: lingjuer <zhangchenglin@kylinos.cn>
Date: Wed, 26 Jul 2023 10:20:57 +0800
Subject: [PATCH] backport-requests-2.31.0-system-certs
---
requests/certs.py | 7 ++++++-
setup.cfg | 1 -
setup.py | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/requests/certs.py b/requests/certs.py
index be422c3..1795e1c 100644
--- a/requests/certs.py
+++ b/requests/certs.py
@@ -10,8 +10,13 @@ only one — the one from the certifi package.
If you are packaging Requests, e.g., for a Linux distribution or a managed
environment, you can change the definition of where() to return a separately
packaged CA bundle.
+
+This OpenEuler-patched package returns "/etc/pki/tls/certs/ca-bundle.crt" provided
+by the ca-certificates RPM package.
"""
-from certifi import where
+def where():
+ """Return the absolute path to the system CA bundle."""
+ return '/etc/pki/tls/certs/ca-bundle.crt'
if __name__ == "__main__":
print(where())
diff --git a/setup.cfg b/setup.cfg
index ea45aaf..056b065 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -4,7 +4,6 @@ provides-extra =
socks
use_chardet_on_py3
requires-dist =
- certifi>=2017.4.17
charset_normalizer>=2,<4
idna>=2.5,<4
urllib3>=1.21.1,<1.27
diff --git a/setup.py b/setup.py
index 0123545..a1a50a3 100755
--- a/setup.py
+++ b/setup.py
@@ -62,7 +62,7 @@ requires = [
"charset_normalizer>=2,<4",
"idna>=2.5,<4",
"urllib3>=1.21.1,<3",
- "certifi>=2017.4.17",
+
]
test_requirements = [
"pytest-httpbin==2.0.0",
--
2.39.1

View File

@ -1,18 +1,13 @@
%bcond_with tests
Name: python-requests
Version: 2.28.1
Release: 3
Version: 2.31.0
Release: 1
Summary: Python HTTP Library
License: ASL 2.0
URL: http://python-requests.org/
Source0: https://github.com/requests/requests/archive/v%{version}/requests-v%{version}.tar.gz
Patch6001: backport-requests-2.28.1-system-certs.patch
Patch6002: backport-requests-2.28.1-tests_nonet.patch
Patch6003: Allow-charset-normalizer-version-between-2-and-4.patch
Patch6004: backport-CVE-2023-32681.patch
Source0: https://github.com/requests/requests/archive/v%{version}/requests-v%{version}.tar.gz#/requests-%{version}.tar.gz
Patch6001: backport-requests-2.31.0-system-certs.patch
BuildArch: noarch
%description
@ -42,6 +37,7 @@ BuildRequires: python%{python3_pkgversion}-chardet
BuildRequires: python%{python3_pkgversion}-urllib3
BuildRequires: python%{python3_pkgversion}-idna
Provides: python%{python3_pkgversion}dist(requests) = %{version}
Provides: python%{python3_version}dist(requests) = %{version}
@ -96,6 +92,9 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} -m pytest -v
%doc HISTORY.md README.md
%changelog
* Thu Jul 13 2023 zhangchenglin <zhangchenglin@kylinos.cn> - 2.31.0-1
- Update package to version 2.31.0
* Wed May 31 2023 zhangpan <zhangpan103@h-partners.com> - 2.28.1-3
- fix CVE-2023-32681

BIN
requests-2.31.0.tar.gz Normal file

Binary file not shown.

Binary file not shown.