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.0

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.0
File Size Uploaded Provenance
url_guard-0.1.0.tar.gz 10.7 kB With provenance Details

Built distribution (wheel)

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

Total release size: 19.6 kB

Release files / url_guard-0.1.0.tar.gz

Download URL url_guard-0.1.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5f0df8f9ba081e0571d894330abcaef808e56ff67faf135197521e62e13f5e1a
BLAKE2b-256 checksum
How to use checksums
dc67f164b97ab70b481deeff1c41932694725bbe387e08470f1d2c3ce52fc48b
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.0-py3-none-any.whl

Download URL url_guard-0.1.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50630cd243c90f1161acd5ff1d11c91b07e5ec3b53d0c93bce49f8ecd07b92df
BLAKE2b-256 checksum
How to use checksums
cfde54dc34db6aa7456fc5d49c41d420449a06b620bedc988ea2342ca7fece99
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.0

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.0.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.0 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