Skip to content
Myr

Merge branch 'psf:main' into patch-1

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by anupam-arista · committed by GitHub · parents 06d2a38, 23540c9 · Browse files · 11 files+82 added−187 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+82 added−187 removed

  • tests:+24 added−17 removed
  • other:+58 added−170 removed

11 files+82 added−187 removed

modified:.github/workflows/codeql-analysis.yml+4 added-4 removed
modified:.github/workflows/lint.yml+2 added-2 removed
modified:.github/workflows/run-tests.yml+26 added-14 removed
modified:.github/SECURITY.md+4 added-13 removed
1# Vulnerability Disclosure23If you think you have found a potential security vulnerability in4requests, please email [Nate](mailto:nate.prewitt@gmail.com)5and [Seth](mailto:sethmichaellarson@gmail.com) directly.6**Do not file a public issue.**4requests, please open a [draft Security Advisory](https://github.com/psf/requests/security/advisories/new)5via GitHub. We will coordinate verification and next steps through6that secure medium.78Our PGP Key fingerprints are:910- 8722 7E29 AD9C FF5C FAC3 EA6A 44D3 FF97 B80D C864 ([@nateprewitt](https://keybase.io/nateprewitt))1112- EDD5 6765 A9D8 4653 CBC8 A134 51B0 6736 1740 F5FC ([@sethmlarson](https://keybase.io/sethmlarson))1314You can also contact us on [Keybase](https://keybase.io) with the15profiles above if desired.168If English is not your first language, please try to describe the9problem and its impact to the best of your ability. For greater detail,10please use your native language and we will try our best to translate it11using online services.
50 unmodified lines
62intended patch ahead of time, to ensure that they are able to promptly63release their downstream packages. Currently the list of people we64actively contact *ahead of a public release* is:6575- Jeremy Cline, Red Hat (@jeremycline)66- Python Maintenance Team, Red Hat (python-maint@redhat.com)67- Daniele Tricoli, Debian (@eriol)6869We will notify these individuals at least a week ahead of our planned70release date to ensure that they have sufficient time to prepare. If you
14 unmodified lines
modified:docs/community/vulnerabilities.rst+2 added-107 removed
1Vulnerability Disclosure2========================34If you think you have found a potential security vulnerability in requests,5please email `Nate <mailto:nate.prewitt@gmail.com>`_ and `Seth <mailto:@sethmichaellarson@gmail.com>`_ directly. **Do not file a public issue.**67Our PGP Key fingerprints are:89- 8722 7E29 AD9C FF5C FAC3 EA6A 44D3 FF97 B80D C864 (`@nateprewitt <https://keybase.io/nateprewitt>`_)1011- EDD5 6765 A9D8 4653 CBC8 A134 51B0 6736 1740 F5FC (`@sethmlarson <https://keybase.io/sethmlarson>`_)1213You can also contact us on `Keybase <https://keybase.io/>`_ with the14profiles above if desired.1516If English is not your first language, please try to describe the problem and17its impact to the best of your ability. For greater detail, please use your18native language and we will try our best to translate it using online services.1920Please also include the code you used to find the problem and the shortest21amount of code necessary to reproduce it.2223Please do not disclose this to anyone else. We will retrieve a CVE identifier24if necessary and give you full credit under whatever name or alias you provide.25We will only request an identifier when we have a fix and can publish it in a26release.2728We will respect your privacy and will only publicize your involvement if you29grant us permission.3031Process32-------3334This following information discusses the process the requests project follows35in response to vulnerability disclosures. If you are disclosing a36vulnerability, this section of the documentation lets you know how we will37respond to your disclosure.3839Timeline40~~~~~~~~4142When you report an issue, one of the project members will respond to you within43two days *at the outside*. In most cases responses will be faster, usually44within 12 hours. This initial response will at the very least confirm receipt45of the report.4647If we were able to rapidly reproduce the issue, the initial response will also48contain confirmation of the issue. If we are not, we will often ask for more49information about the reproduction scenario.5051Our goal is to have a fix for any vulnerability released within two weeks of52the initial disclosure. This may potentially involve shipping an interim53release that simply disables function while a more mature fix can be prepared,54but will in the vast majority of cases mean shipping a complete release as soon55as possible.5657Throughout the fix process we will keep you up to speed with how the fix is58progressing. Once the fix is prepared, we will notify you that we believe we59have a fix. Often we will ask you to confirm the fix resolves the problem in60your environment, especially if we are not confident of our reproduction61scenario.6263At this point, we will prepare for the release. We will obtain a CVE number64if one is required, providing you with full credit for the discovery. We will65also decide on a planned release date, and let you know when it is. This66release date will *always* be on a weekday.6768At this point we will reach out to our major downstream packagers to notify69them of an impending security-related patch so they can make arrangements. In70addition, these packagers will be provided with the intended patch ahead of71time, to ensure that they are able to promptly release their downstream72packages. Currently the list of people we actively contact *ahead of a public73release* is:7475- Python Maintenance Team, Red Hat (python-maint@redhat.com)76- Daniele Tricoli, Debian (@eriol)7778We will notify these individuals at least a week ahead of our planned release79date to ensure that they have sufficient time to prepare. If you believe you80should be on this list, please let one of the maintainers know at one of the81email addresses at the top of this article.8283On release day, we will push the patch to our public repository, along with an84updated changelog that describes the issue and credits you. We will then issue85a PyPI release containing the patch.8687At this point, we will publicise the release. This will involve mails to88mailing lists, Tweets, and all other communication mechanisms available to the89core team.9091We will also explicitly mention which commits contain the fix to make it easier92for other distributors and users to easily patch their own versions of requests93if upgrading is not an option.9495Previous CVEs96-------------9798- Fixed in 2.20.099 - `CVE 2018-18074 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=2018-18074>`_100101- Fixed in 2.6.0102103 - `CVE 2015-2296 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=2015-2296>`_,104 reported by Matthew Daley of `BugFuzz <https://bugfuzz.com/>`_.105106- Fixed in 2.3.0107108 - `CVE 2014-1829 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=2014-1829>`_109110 - `CVE 2014-1830 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=2014-1830>`_4The latest vulnerability disclosure information can be found on GitHub in our5`Security Policy <https://github.com/psf/requests/blob/main/.github/SECURITY.md>`_.
modified:src/requests/compat.py+12 added
8 unmodified lines
910import importlib11import sys1213# -------14# urllib315# -------16from urllib3 import __version__ as urllib3_version1718# Detect which major version of urllib3 is being used.19try:20 is_urllib3_1 = int(urllib3_version.split(".")[0]) == 121except (TypeError, AttributeError):22 # If we can't discern a version, prefer old functionality.23 is_urllib3_1 = True2425# -------------------26# Character Detection27# -------------------28
78 unmodified lines
modified:src/requests/utils.py+4 added-1 removed
36 unmodified lines
37 bytes,38 getproxies,39 getproxies_environment,40 integer_types,41 is_urllib3_1,42)43from .compat import parse_http_list as _parse_list_header44from .compat import (45 proxy_bypass,
90 unmodified lines
136def super_len(o):137 total_length = None138 current_position = 0139139 if isinstance(o, str):140 if not is_urllib3_1 and isinstance(o, str):141 # urllib3 2.x+ treats all strings as utf-8 instead142 # of latin-1 (iso-8859-1) like http.client.143 o = o.encode("utf-8")144145 if hasattr(o, "__len__"):146 total_length = len(o)
953 unmodified lines
modified:tests/test_requests.py+24 added-17 removed
23 unmodified lines
24 MutableMapping,25 builtin_str,26 cookielib,27 getproxies,28 is_urllib3_1,29 urlparse,30)31from requests.cookies import cookiejar_from_dict, morsel_to_cookie32from requests.exceptions import (
1777 unmodified lines
1810 p = req.prepare()18111812 assert p.headers["Content-Length"] == length18131813 def test_content_length_for_bytes_data(self, httpbin):1814 data = "This is a string containing multi-byte UTF-8 ☃️"1815 encoded_data = data.encode("utf-8")1816 length = str(len(encoded_data))1817 req = requests.Request("POST", httpbin("post"), data=encoded_data)1818 p = req.prepare()18191820 assert p.headers["Content-Length"] == length18211822 def test_content_length_for_string_data_counts_bytes(self, httpbin):1823 data = "This is a string containing multi-byte UTF-8 ☃️"1824 length = str(len(data.encode("utf-8")))1825 req = requests.Request("POST", httpbin("post"), data=data)1826 p = req.prepare()18271828 assert p.headers["Content-Length"] == length18291814 def test_nonhttp_schemes_dont_check_URLs(self):1815 test_urls = (1816 "data:image/gif;base64,R0lGODlhAQABAHAAACH5BAUAAAAALAAAAAABAAEAAAICRAEAOw==",1817 "file:///etc/passwd",
1131 unmodified lines
29492950 assert client_cert is not None295129522953def test_content_length_for_bytes_data(httpbin):2954 data = "This is a string containing multi-byte UTF-8 ☃️"2955 encoded_data = data.encode("utf-8")2956 length = str(len(encoded_data))2957 req = requests.Request("POST", httpbin("post"), data=encoded_data)2958 p = req.prepare()29592960 assert p.headers["Content-Length"] == length296129622963@pytest.mark.skipif(2964 is_urllib3_1,2965 reason="urllib3 2.x encodes all strings to utf-8, urllib3 1.x uses latin-1",2966)2967def test_content_length_for_string_data_counts_bytes(httpbin):2968 data = "This is a string containing multi-byte UTF-8 ☃️"2969 length = str(len(data.encode("utf-8")))2970 req = requests.Request("POST", httpbin("post"), data=data)2971 p = req.prepare()29722973 assert p.headers["Content-Length"] == length297429752976def test_json_decode_errors_are_serializable_deserializable():2977 json_decode_error = requests.exceptions.JSONDecodeError(2978 "Extra data",2979 '{"responseCode":["706"],"data":null}{"responseCode":["706"],"data":null}',
4 unmodified lines
modified:requirements-dev.txt+1 added-1 removed
1-e .[socks]2pytest>=2.8.0,<93pytest-cov4pytest-httpbin==2.0.04pytest-httpbin==2.1.05httpbin~=0.10.06trustme7wheel
modified:setup.py+2 added-27 removed
2 unmodified lines
3import sys4from codecs import open56from setuptools import setup7from setuptools.command.test import test as TestCommand78CURRENT_PYTHON = sys.version_info[:2]9REQUIRED_PYTHON = (3, 8)10
15 unmodified lines
26 )27 sys.exit(1)282931class PyTest(TestCommand):32 user_options = [("pytest-args=", "a", "Arguments to pass into py.test")]3334 def initialize_options(self):35 TestCommand.initialize_options(self)36 try:37 from multiprocessing import cpu_count3839 self.pytest_args = ["-n", str(cpu_count()), "--boxed"]40 except (ImportError, NotImplementedError):41 self.pytest_args = ["-n", "1", "--boxed"]4243 def finalize_options(self):44 TestCommand.finalize_options(self)45 self.test_args = []46 self.test_suite = True4748 def run_tests(self):49 import pytest5051 errno = pytest.main(self.pytest_args)52 sys.exit(errno)535430# 'setup.py publish' shortcut.31if sys.argv[-1] == "publish":32 os.system("python setup.py sdist bdist_wheel")33 os.system("twine upload dist/*")
5 unmodified lines
39 "urllib3>=1.21.1,<3",40 "certifi>=2017.4.17",41]42test_requirements = [68 "pytest-httpbin==2.0.0",43 "pytest-httpbin==2.1.0",44 "pytest-cov",45 "pytest-mock",46 "pytest-xdist",47 "PySocks>=1.5.6, !=1.5.7",
38 unmodified lines
86 "Programming Language :: Python :: 3.9",87 "Programming Language :: Python :: 3.10",88 "Programming Language :: Python :: 3.11",89 "Programming Language :: Python :: 3.12",90 "Programming Language :: Python :: 3.13",91 "Programming Language :: Python :: 3 :: Only",92 "Programming Language :: Python :: Implementation :: CPython",93 "Programming Language :: Python :: Implementation :: PyPy",94 "Topic :: Internet :: WWW/HTTP",95 "Topic :: Software Development :: Libraries",96 ],121 cmdclass={"test": PyTest},97 tests_require=test_requirements,98 extras_require={99 "security": [],100 "socks": ["PySocks>=1.5.6, !=1.5.7"],
7 unmodified lines
modified:tox.ini+1 added-1 removed
1[tox]2envlist = py{38,39,310,311,312}-{default, use_chardet_on_py3}2envlist = py{38,39,310,311,312,313}-{default, use_chardet_on_py3}34[testenv]5deps = -rrequirements-dev.txt6extras =
12 unmodified lines