Package Details: python-safehttpx 0.1.6-4

Git Clone URL: https://aur.archlinux.org/python-safehttpx.git (read-only, click to copy)
Package Base: python-safehttpx
Description: A small Python library created to help developers protect their applications from Server Side Request Forgery (SSRF) attacks.
Upstream URL: https://github.com/gradio-app/safehttpx
Licenses: Apache-2.0
Submitter: medaminezghal
Maintainer: medaminezghal
Last Packager: medaminezghal
Votes: 1
Popularity: 0.016374
First Submitted: 2025-02-19 14:27 (UTC)
Last Updated: 2025-08-11 14:51 (UTC)

Latest Comments

1 2 Next › Last »

micwoj92 commented on 2025-09-09 21:28 (UTC)

Check fails with:

test/test.py:3: in <module>
    import safehttpx
E   ModuleNotFoundError: No module named 'safehttpx'

medaminezghal commented on 2025-08-11 14:53 (UTC)

@Felixoid I'm not the developer of this package. I'm just a maintainer.

You can raise those issues to the developers to make the tests more flexible or independent from system configuration.

Felixoid commented on 2025-08-11 12:51 (UTC) (edited on 2025-08-11 13:03 (UTC) by Felixoid)

Sorry, but you ignore the argument about DNS and poorly written function.

  1. Your check() function is written in a way, that it's impossible to run it two times without cleaning the repository. installer fails on the second time. Have you tested it as makepkg -f && makepkg -f? I doubt you have. That's how it fails with true instead of a failing test https://pastila.nl/?0037c573/f2e7b848a4b37a2db9ac9824c50097e5#S8eIFcvNy/yo9SK3eELV6w==
  2. My DNS doesn't know about 192.168.1.250.nip.io. For sure, you can argue "fix your DNS", but that's an offtopic here. The package can't be checked correctly. It tests my network, not the software. So this test is broken by design, and it's for best to disable tests that are flaky depends on the environment.

Work on my system is the worst possible reason I can imagine, with all due respect.

medaminezghal commented on 2025-08-11 12:43 (UTC)

@Felixoid I have test the installation in new cleanly installed system and it works.

Felixoid commented on 2025-08-11 11:58 (UTC)

And that's how two launches of makepkg one following another looks like https://pastila.nl/?00395479/7d9c8e05b1490c0e680c8d24e0727abc#/awv5R+RBiR6/t0/AkrpMw==

The test with install is not idempotent. It fails for the following runs.

Felixoid commented on 2025-08-11 11:54 (UTC)

That's how the build looks like for a clean git repo without any changes. https://pastila.nl/?001b73b2/ed5a381604f61612721c1076de6d313d#f25DNjDNVy0JKdQ/JxLj3A==

Testing user's DNS is a strange approach that for the best must be addressed by the upstream developer.

Although now the AUR package tests my DNS.

> dig 192.168.1.250.nip.io

; <<>> DiG 9.20.11 <<>> 192.168.1.250.nip.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5127
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;192.168.1.250.nip.io.          IN      A

;; Query time: 19 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Mon Aug 11 13:53:51 CEST 2025
;; MSG SIZE  rcvd: 49

> dig @1.1.1.1 192.168.1.250.nip.io

; <<>> DiG 9.20.11 <<>> @1.1.1.1 192.168.1.250.nip.io
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21873
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;192.168.1.250.nip.io.          IN      A

;; ANSWER SECTION:
192.168.1.250.nip.io.   3600    IN      A       192.168.1.250

;; Query time: 75 msec
;; SERVER: 1.1.1.1#53(1.1.1.1) (UDP)
;; WHEN: Mon Aug 11 13:54:26 CEST 2025
;; MSG SIZE  rcvd: 65

And it's a strange approach.

medaminezghal commented on 2025-08-11 11:39 (UTC)

@Felixoid I have made a script to test if the package works before I upload it to the AUR.

medaminezghal commented on 2025-08-11 11:37 (UTC)

@Felixoid the sed -i "/93.184.215.14.nip.io/d" test/test.py should remove the broken link from the tests.

Try to clear the cache and install it again.

Felixoid commented on 2025-08-11 11:34 (UTC) (edited on 2025-08-11 11:44 (UTC) by Felixoid)

Thanks.

Unfortunately, the check() is still completely broken.

  1. The 192.168.1.250.nip.io is an unknown host, so there are more broken tests
> dig 192.168.1.250.nip.io

; <<>> DiG 9.20.11 <<>> 192.168.1.250.nip.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37326
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;192.168.1.250.nip.io.          IN      A

;; Query time: 22 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Mon Aug 11 13:13:37 CEST 2025
;; MSG SIZE  rcvd: 49
python -m pytest test/test.py
===================================================================== test session starts ======================================================================
platform linux -- Python 3.13.5, pytest-8.4.1, pluggy-1.6.0
rootdir: /home/felixoid/.cache/yay/python-safehttpx/src/safehttpx-0.1.6
configfile: pyproject.toml
plugins: anyio-4.10.0, mock-3.14.0, xdist-3.6.1, cov-6.1.1, asyncio-0.26.0
asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 11 items

test/test.py .....F...F.                                                                                                                                 [100%]
....
E       AssertionError: Regex pattern did not match.
E        Regex: 'failed validation'
E        Input: 'Unable to resolve hostname 192.168.1.250.nip.io: [Errno -5] No address associated with hostname'

test/test.py:20: AssertionError
....
E       AssertionError: Regex pattern did not match.
E        Regex: 'failed validation'
E        Input: 'Unable to resolve hostname 192.168.1.250.nip.io: [Errno -5] No address associated with hostname'

test/test.py:48: AssertionError
=================================================================== short test summary info ====================================================================
FAILED test/test.py::test_local_urls_fail[http://192.168.1.250.nip.io] - AssertionError: Regex pattern did not match.
FAILED test/test.py::test_domain_whitelist - AssertionError: Regex pattern did not match.
================================================================= 2 failed, 9 passed in 1.28s ==================================================================
  1. The test environment looks broken, didn't you want to use the virtual-env that was created? In any case, using venv looks like an antipattern to me. Every package necessary for check must be defined in checkdepends list, so no "install" should be required.

That's how the git diff is looking for addressed issues:

--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,7 +3,7 @@
 _name=safehttpx
 pkgname=python-${_name}
 pkgver=0.1.6
-pkgrel=2
+pkgrel=3
 pkgdesc='A small Python library created to help developers protect their applications from Server Side Request Forgery (SSRF) attacks.'
 arch=('any')
 url='https://github.com/gradio-app/safehttpx'
@@ -14,11 +14,6 @@ depends=('python>=3.9' 'python-httpx')
 makedepends=('python-hatchling' 'python-build' 'python-installer' 'python-wheel')
 checkdepends=('python-pytest')

-prepare(){
-  cd "${srcdir}"/${_name}-${pkgver}
-  sed -i "/93.184.215.14.nip.io/d" test/test.py
-}
-
 build() {
   cd "${srcdir}"/${_name}-${pkgver}
   python -m build --wheel --no-isolation
@@ -26,9 +21,9 @@ build() {

 check() {
   cd "${srcdir}"/${_name}-${pkgver}
-  python -m venv --system-site-packages test-env
-  test-env/bin/python -m installer dist/*.whl
-  test-env/bin/python -m pytest "${pytest_options[@]}" test/test.py
+  # The pytest expression for broken tests
+  broken_tests='not (.nip.io or test_domain_whitelist)'
+  python -m pytest test/test.py -k "${broken_tests}"
 }

 package() {

medaminezghal commented on 2025-08-11 04:45 (UTC)

@Felixoid I have fixed the issue by removing just the broken link. Thanks for mentioning python-build python-installer, I've added them to makedepends.