Skip to main content

URL Reputation (Rust)

Static URL policy checks for ContextForge and MCP Gateway resource fetches.

Features

  • Blocks resource fetches before execution with the resource_pre_fetch hook
  • Allows trusted domains or URL regex patterns to bypass later checks
  • Blocks configured domains, subdomains, or URL regex patterns
  • Blocks non-HTTPS URLs by default
  • Optional domain heuristics for high entropy, static IANA TLD validity, and Unicode security
  • Case-insensitive domain normalization for allowlist and blocklist entries
  • Pure static policy checks; no external reputation provider or threat-intel feed calls

Build

make install

Runtime Requirements

This plugin depends on cpex>=0.1.0,<0.2 and imports hook models from cpex.framework. The compiled Rust extension is mandatory; there is no Python fallback implementation.

Usage

The plugin runs on resource_pre_fetch before a resource URI is fetched.

Typical uses:

  • block known bad domains and subdomains
  • allow trusted internal URL patterns before enforcing HTTPS
  • reject insecure http:// resource fetches
  • enable lightweight domain heuristics for suspicious generated or Unicode domains

Configuration

config:
  whitelist_domains:
    - "example.com"
  allowed_patterns:
    - "^https://trusted\\.internal/.*"
  blocked_domains:
    - "malicious.example.com"
  blocked_patterns:
    - "casino"
    - "crypto"
  use_heuristic_check: false
  entropy_threshold: 3.65
  block_non_secure_http: true
Field Type Default Description
whitelist_domains set [] Domains and subdomains that bypass remaining checks
allowed_patterns list [] Regexes matched against the full trimmed URL; a match bypasses remaining checks
blocked_domains set [] Domains and subdomains that are always blocked unless allowlisted first
blocked_patterns list [] Regexes matched against the full trimmed URL; a match blocks the request
use_heuristic_check bool false Enable entropy, TLD, and Unicode domain checks for non-IP hosts
entropy_threshold float 3.65 Maximum allowed Shannon entropy for the domain
block_non_secure_http bool true Block URLs whose scheme is not https

Logic Workflow

  1. Trim and parse the URL.
  2. Extract the host/domain.
  3. Detect IPv4 or IPv6 hosts so domain heuristics can be skipped.
  4. Allow exact or parent-domain matches in whitelist_domains.
  5. Allow matches in allowed_patterns; this also bypasses HTTPS enforcement.
  6. Block non-HTTPS schemes when block_non_secure_http=true.
  7. Block exact or parent-domain matches in blocked_domains.
  8. Block matches in blocked_patterns.
  9. If heuristics are enabled for a non-IP host, block high-entropy domains, illegal static TLDs, or unsafe Unicode domains.

Returned Metadata

Allowed URLs return continue_processing=true.

Blocked URLs return continue_processing=false with a PluginViolation using code URL_REPUTATION_BLOCK. Violation details include the URL or domain involved in the decision.

resource_pre_fetch accepts an optional extensions parameter carrying OpenTelemetry trace context. When a trace context is present (via extensions.request.trace_id), the plugin emits operational metrics on result.metadata["url_reputation"] with the following schema:

result.metadata["url_reputation"] = {
    "total_checked": 1,                    # int — always 1; one URL is checked per call
    "total_blocked": 0,                     # int — 0 or 1; this call's outcome, not a running total
    "reputation_categories": [],            # list[str] — category slugs; empty when allowed
}

resource_pre_fetch evaluates exactly one URL per call with no running counter, so — mirroring rate_limiter's per-call allowed/throttled semantics — total_checked and total_blocked describe only the current call's outcome; the gateway aggregates counts across spans/time. When the URL is blocked, reputation_categories contains exactly one slug describing why (e.g. blocked_domain, insecure_scheme, high_entropy_domain, illegal_tld, unicode_spoofing, blocked_pattern, malformed_url, malformed_domain, internal_error).

Gating: Metrics are only emitted when a valid trace_id is present in the trace context (extensions.request.trace_id). No trace context means no result.metadata write at all.

Security Note (S1): The plugin never includes the raw URL or domain in result.metadata. Only counts and category slugs (derived from the plugin's static, hardcoded violation reasons) are reported; the actual URL/domain stays confined to PluginViolation.details on the blocking path, a separate channel unaffected by this metrics addition.

Limitations

  • Reputation data is static configuration only; there are no external provider lookups.
  • The IANA TLD list is compiled into the plugin and can lag newly delegated TLDs.
  • allowed_patterns intentionally runs before HTTPS enforcement, so trusted patterns can allow http:// URLs.
  • IP addresses skip domain heuristics.

Testing

make ci

Metadata

Release files for cpex-url-reputation 0.3.11

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

Source distribution (sdist)

Source distribution for cpex-url-reputation 0.3.11
File Size Uploaded Provenance Actions
cpex_url_reputation-0.3.11.tar.gz 45.5 kB With provenance Details for cpex_url_reputation-0.3.11.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for cpex-url-reputation 0.3.11
File Actions
cpex_url_reputation-0.3.11-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for cpex_url_reputation-0.3.11-cp311-abi3-win_amd64.whl
cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_x86_64.whl CPython 3.11 abi3 Linux glibc 2.34+ x86-64 Details for cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_x86_64.whl
cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_s390x.whl CPython 3.11 abi3 Linux glibc 2.34+ IBM System/390x Details for cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_s390x.whl
cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_ppc64le.whl CPython 3.11 abi3 Linux glibc 2.34+ PowerPC 64-le Details for cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_ppc64le.whl
cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_aarch64.whl CPython 3.11 abi3 Linux glibc 2.34+ ARM64 Details for cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_aarch64.whl
cpex_url_reputation-0.3.11-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for cpex_url_reputation-0.3.11-cp311-abi3-macosx_11_0_arm64.whl

Total release size: 5.6 MB

Release files / cpex_url_reputation-0.3.11.tar.gz

Download URL cpex_url_reputation-0.3.11.tar.gz
Size 45.5 kB
Tags Source
SHA-256 checksum
How to use checksums
84dd91bc090e222ec0916f3993b3fca8c2b8f8e9acd8cb16392a43b8e0598258
BLAKE2b-256 checksum
How to use checksums
92ba6ce9ac86f4a508cf8bcd0982e10eebbbf637371e0ba8f9afa8b5769c009d
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 Nov 25, 2026.

Transparency log

Release files / cpex_url_reputation-0.3.11-cp311-abi3-win_amd64.whl

Download URL cpex_url_reputation-0.3.11-cp311-abi3-win_amd64.whl
Size 866.4 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
aaf0dfcbecd8504f0e08f2cdf420792c2fa2c26a429ba6d53578965a98995d30
BLAKE2b-256 checksum
How to use checksums
30d82d072a13bdc1b87b9c6677f5f9a88da3e160bbf0ec24e3997db818840dc8
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 Nov 25, 2026.

Transparency log

Release files / cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_x86_64.whl

Download URL cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_x86_64.whl
Size 939.9 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
c74d8b66d6aa30ed8b0d51119fcd6ea3fc1f53b3b264afbcfa723646dc5029b0
BLAKE2b-256 checksum
How to use checksums
a534bb0a9e2cc9c28ee7124809601dcb84b1cc57d2e2dd219ac901a30b50b8fd
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 Nov 25, 2026.

Transparency log

Release files / cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_s390x.whl

Download URL cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_s390x.whl
Size 998.2 kB
Tags CPython 3.11 Linux glibc 2.34+ IBM System/390x abi3
SHA-256 checksum
How to use checksums
66b192c139b183f5bb9fcc1b1f898e399f65640dd898d476b9442b7e43e8e68a
BLAKE2b-256 checksum
How to use checksums
869fcc19e3ca5c5c9e32196020b7758332c0697606f7903499d09ae577669643
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 Nov 25, 2026.

Transparency log

Release files / cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_ppc64le.whl

Download URL cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_ppc64le.whl
Size 971.9 kB
Tags CPython 3.11 Linux glibc 2.34+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
12a45a3f7b6797d8476aaf313503ec52ff692a643d49fbf029e4b2ac21bc9cc1
BLAKE2b-256 checksum
How to use checksums
16ed3c3ebc8ab24f198f9bb0b47e20d288edb0f3164a54beaa06ab1eb57cb718
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 Nov 25, 2026.

Transparency log

Release files / cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_aarch64.whl

Download URL cpex_url_reputation-0.3.11-cp311-abi3-manylinux_2_34_aarch64.whl
Size 891.4 kB
Tags CPython 3.11 Linux glibc 2.34+ ARM64 abi3
SHA-256 checksum
How to use checksums
8f5dfe4d2bbce7dce3f880b7764bd0f7c638b5f45419f2ea731a653dd4629e5d
BLAKE2b-256 checksum
How to use checksums
3437128c3f7ea86024ecfb7de80427745b69b406a163851dd209e349354aca15
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 Nov 25, 2026.

Transparency log

Release files / cpex_url_reputation-0.3.11-cp311-abi3-macosx_11_0_arm64.whl

Download URL cpex_url_reputation-0.3.11-cp311-abi3-macosx_11_0_arm64.whl
Size 843.7 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d6299af5d75df14962779a5bfa06fe73c5c726639412906acf96ca90727cf12a
BLAKE2b-256 checksum
How to use checksums
8117a697a9ecc381b011adbc18717ba236bc64cd27445f76475eb6cf6efec843
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 Nov 25, 2026.

Transparency log

Security for cpex-url-reputation 0.3.11

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 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for cpex_url_reputation-0.3.11.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 Nov 25, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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