Skip to main content

url-guard (Python)

SSRF guard for outbound URLs. This is the Python twin of the @mpointer/url-guard npm package: identical IP-literal grammar, identical classification tables, identical URL rules, shared vectors decoded by both suites in CI. Zero dependencies.

pip install url-guard
from url_guard import assert_public_url, assert_public_url_resolved, UnsafeUrlError

url = assert_public_url("https://api.example.com/v1")            # structural check, no DNS
url = assert_public_url_resolved("https://partner.example/feed")  # every resolved address must be public

assert_public_url(
    "http://docling.railway.internal:5001",
    allow_private=True,                              # self-hosted targets on the private network
    allowed_host_suffixes=(".railway.internal",),    # and nothing else
)
assert_public_url(base_url, require_https=True)      # plaintext only to loopback

UnsafeUrlError subclasses ValueError and carries .reason (parse, protocol, blocked-host, private-address, allow-list, dns, timeout), so a call site that already catches ValueError around its own URL check keeps working when it switches.

See the repository README for the full design: why hostname string matching is not a guard, the encodings that are canonicalized, what allow_private never relaxes, the DNS rules, and the rebinding window this does not close.

Metadata

Release files for url-guard 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for url-guard 0.1.1
File Size Uploaded Provenance
url_guard-0.1.1.tar.gz 10.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for url-guard 0.1.1
File Interpreter ABI Platform
url_guard-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.8 kB

Release files / url_guard-0.1.1.tar.gz

Download URL url_guard-0.1.1.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9956ffcc2d8fa98544c70bef18f64655d6d0d80db7f86d78c1d9e0f7ffff4f7a
BLAKE2b-256 checksum
How to use checksums
18c0b856b8a11693717ae69d8d4d7c6cb0c92de21449c27d7ed835c34a708c49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / url_guard-0.1.1-py3-none-any.whl

Download URL url_guard-0.1.1-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
334e72139d8f3253f9d58e55312d2f1f07f229db266178ad436ee1855e42b190
BLAKE2b-256 checksum
How to use checksums
1107a26d95825253cda774fc801ff3a5c7149a9ae309a3af672f51a97203be9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Security for url-guard 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for url_guard-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page