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

adapters: fix for requests 2.32.2+ #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

simondeziel
Copy link

@simondeziel simondeziel commented May 22, 2024

Without this, all requests to http+unix:// URLs fail with: requests.exceptions.InvalidURL: Not supported URL scheme http+unix.

Fixes #73

@crgwbr
Copy link

crgwbr commented May 22, 2024

Since this project seems to be abandoned, but its longevity is important to my team, we've forked the project as requests-unixsocket2. It should be a drop in replacement for this package.

We've migrated this PR there, merged it, and released to PyPI as part of v0.4.0.

simondeziel added a commit to simondeziel/pylxd that referenced this pull request May 23, 2024
simondeziel added a commit to simondeziel/pylxd that referenced this pull request May 23, 2024
requests 2.32 security fix recommends a fix:
psf/requests#6710

This was proposed (but not yet merged) to requests-unixsocket in:
msabramo/requests-unixsocket#72

Signed-off-by: Simon Deziel <[email protected]>
@cartertinney
Copy link

@msabramo Can we get this merged? This is a crucial fix

@kloczek
Copy link

kloczek commented May 27, 2024

I've tested this PR and pytest 8.2.1 fails in 4 units

Here is pytest output:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-requests-unixsocket-0.3.0-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-requests-unixsocket-0.3.0-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /home/tkloczko/rpmbuild/BUILD/requests-unixsocket-0.3.0
configfile: pytest.ini
collected 5 items

requests_unixsocket/tests/test_requests_unixsocket.py FFF.F                                                                                                                           [100%]

========================================================================================= FAILURES ==========================================================================================
________________________________________________________________________________ test_unix_domain_adapter_ok ________________________________________________________________________________
requests_unixsocket/tests/test_requests_unixsocket.py:26: in test_unix_domain_adapter_ok
    r = getattr(session, method)(url)
/usr/lib/python3.10/site-packages/requests/sessions.py:602: in get
    return self.request("GET", url, **kwargs)
/usr/lib/python3.10/site-packages/requests/sessions.py:589: in request
    resp = self.send(prep, **send_kwargs)
/usr/lib/python3.10/site-packages/requests/sessions.py:703: in send
    r = adapter.send(request, **kwargs)
/usr/lib/python3.10/site-packages/requests/adapters.py:561: in send
    self.cert_verify(conn, request.url, verify, cert)
/usr/lib/python3.10/site-packages/requests/adapters.py:320: in cert_verify
    conn.cert_reqs = "CERT_NONE"
E   AttributeError: 'NoneType' object has no attribute 'cert_reqs'
______________________________________________________________________ test_unix_domain_adapter_url_with_query_params _______________________________________________________________________
requests_unixsocket/tests/test_requests_unixsocket.py:53: in test_unix_domain_adapter_url_with_query_params
    r = getattr(session, method)(url)
/usr/lib/python3.10/site-packages/requests/sessions.py:602: in get
    return self.request("GET", url, **kwargs)
/usr/lib/python3.10/site-packages/requests/sessions.py:589: in request
    resp = self.send(prep, **send_kwargs)
/usr/lib/python3.10/site-packages/requests/sessions.py:703: in send
    r = adapter.send(request, **kwargs)
/usr/lib/python3.10/site-packages/requests/adapters.py:561: in send
    self.cert_verify(conn, request.url, verify, cert)
/usr/lib/python3.10/site-packages/requests/adapters.py:320: in cert_verify
    conn.cert_reqs = "CERT_NONE"
E   AttributeError: 'NoneType' object has no attribute 'cert_reqs'
_________________________________________________________________________ test_unix_domain_adapter_connection_error _________________________________________________________________________
requests_unixsocket/tests/test_requests_unixsocket.py:76: in test_unix_domain_adapter_connection_error
    getattr(session, method)(
/usr/lib/python3.10/site-packages/requests/sessions.py:602: in get
    return self.request("GET", url, **kwargs)
/usr/lib/python3.10/site-packages/requests/sessions.py:589: in request
    resp = self.send(prep, **send_kwargs)
/usr/lib/python3.10/site-packages/requests/sessions.py:703: in send
    r = adapter.send(request, **kwargs)
/usr/lib/python3.10/site-packages/requests/adapters.py:561: in send
    self.cert_verify(conn, request.url, verify, cert)
/usr/lib/python3.10/site-packages/requests/adapters.py:320: in cert_verify
    conn.cert_reqs = "CERT_NONE"
E   AttributeError: 'NoneType' object has no attribute 'cert_reqs'
___________________________________________________________________________ test_unix_domain_adapter_monkeypatch ____________________________________________________________________________
requests_unixsocket/tests/test_requests_unixsocket.py:101: in test_unix_domain_adapter_monkeypatch
    r = getattr(requests, method)(url)
../../BUILDROOT/python-requests-unixsocket-0.3.0-2.fc37.x86_64/usr/lib/python3.10/site-packages/requests_unixsocket/__init__.py:51: in get
    return request('get', url, **kwargs)
../../BUILDROOT/python-requests-unixsocket-0.3.0-2.fc37.x86_64/usr/lib/python3.10/site-packages/requests_unixsocket/__init__.py:46: in request
    return session.request(method=method, url=url, **kwargs)
/usr/lib/python3.10/site-packages/requests/sessions.py:589: in request
    resp = self.send(prep, **send_kwargs)
/usr/lib/python3.10/site-packages/requests/sessions.py:703: in send
    r = adapter.send(request, **kwargs)
/usr/lib/python3.10/site-packages/requests/adapters.py:561: in send
    self.cert_verify(conn, request.url, verify, cert)
/usr/lib/python3.10/site-packages/requests/adapters.py:320: in cert_verify
    conn.cert_reqs = "CERT_NONE"
E   AttributeError: 'NoneType' object has no attribute 'cert_reqs'
================================================================================== short test summary info ==================================================================================
FAILED requests_unixsocket/tests/test_requests_unixsocket.py::test_unix_domain_adapter_ok - AttributeError: 'NoneType' object has no attribute 'cert_reqs'
FAILED requests_unixsocket/tests/test_requests_unixsocket.py::test_unix_domain_adapter_url_with_query_params - AttributeError: 'NoneType' object has no attribute 'cert_reqs'
FAILED requests_unixsocket/tests/test_requests_unixsocket.py::test_unix_domain_adapter_connection_error - AttributeError: 'NoneType' object has no attribute 'cert_reqs'
FAILED requests_unixsocket/tests/test_requests_unixsocket.py::test_unix_domain_adapter_monkeypatch - AttributeError: 'NoneType' object has no attribute 'cert_reqs'
================================================================================ 4 failed, 1 passed in 0.37s ================================================================================

@layercak3
Copy link

Missing return, use return self.get_connection(request.url, proxies)

@simondeziel
Copy link
Author

@layercak3 thanks I don't understand how I could fail to copy-n-paste in such a way, embarrassing :/

@simondeziel
Copy link
Author

The original proposal was initially missing the return bit as well, it was edited to fix the issue psf/requests#6710

@kloczek
Copy link

kloczek commented Jun 2, 2024

Just retested 0.3.0 against requests 2.32.3 and all is fine now.

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-requests-unixsocket-0.3.0-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-requests-unixsocket-0.3.0-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /home/tkloczko/rpmbuild/BUILD/requests-unixsocket-0.3.0
configfile: pytest.ini
collected 5 items

requests_unixsocket/tests/test_requests_unixsocket.py .....                                                                                                                           [100%]

===================================================================================== 5 passed in 0.18s =====================================================================================

L3n41c added a commit to DataDog/integrations-core that referenced this pull request Jun 3, 2024
L3n41c added a commit to DataDog/integrations-core that referenced this pull request Jun 3, 2024
steveny91 added a commit to DataDog/integrations-core that referenced this pull request Jun 7, 2024
… to ddev (#17702)

* Upgrade `requests` to `2.32.3`

* Add changelog entry

* Bump the `requests-unixsocket` version to requests-unixsocket2==0.4.0

in order to get the following fix: msabramo/requests-unixsocket#72

* update license

* changelog

* Apply suggestions from code review

Co-authored-by: Steven Yuen <[email protected]>

* Regenerate LICENSE-3rdparty.csv

* conflicts

* sync license

* changelog

---------

Co-authored-by: steveny91 <[email protected]>
datadog-agent-integrations-bot bot pushed a commit to DataDog/integrations-core that referenced this pull request Jun 7, 2024
… to ddev (#17702)

* Upgrade `requests` to `2.32.3`

* Add changelog entry

* Bump the `requests-unixsocket` version to requests-unixsocket2==0.4.0

in order to get the following fix: msabramo/requests-unixsocket#72

* update license

* changelog

* Apply suggestions from code review

Co-authored-by: Steven Yuen <[email protected]>

* Regenerate LICENSE-3rdparty.csv

* conflicts

* sync license

* changelog

---------

Co-authored-by: steveny91 <[email protected]>
(cherry picked from commit e1e61e5)
github-actions bot pushed a commit to DataDog/integrations-core that referenced this pull request Jun 7, 2024
… to ddev (#17702)

* Upgrade `requests` to `2.32.3`

* Add changelog entry

* Bump the `requests-unixsocket` version to requests-unixsocket2==0.4.0

in order to get the following fix: msabramo/requests-unixsocket#72

* update license

* changelog

* Apply suggestions from code review

Co-authored-by: Steven Yuen <[email protected]>

* Regenerate LICENSE-3rdparty.csv

* conflicts

* sync license

* changelog

---------

Co-authored-by: steveny91 <[email protected]> e1e61e5
steveny91 pushed a commit to DataDog/integrations-core that referenced this pull request Jun 10, 2024
… to ddev (#17702) (#17776)

* Upgrade `requests` to `2.32.3`

* Add changelog entry

* Bump the `requests-unixsocket` version to requests-unixsocket2==0.4.0

in order to get the following fix: msabramo/requests-unixsocket#72

* update license

* changelog

* Apply suggestions from code review

Co-authored-by: Steven Yuen <[email protected]>

* Regenerate LICENSE-3rdparty.csv

* conflicts

* sync license

* changelog

---------

Co-authored-by: steveny91 <[email protected]>
(cherry picked from commit e1e61e5)

Co-authored-by: Lénaïc Huard <[email protected]>
kba added a commit to OCR-D/core that referenced this pull request Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Requests 2.32.0 Not supported URL scheme http+unix
5 participants