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

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.10
File Size Uploaded Provenance
cpex_url_reputation-0.3.10.tar.gz 45.5 kB With provenance Details

Built distributions (wheels)

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

Total release size: 5.5 MB

Release files / cpex_url_reputation-0.3.10.tar.gz

Download URL cpex_url_reputation-0.3.10.tar.gz
Size 45.5 kB
Tags Source
SHA-256 checksum
How to use checksums
74ba24cf69207455c4a9a5dcf618ccb47edac42a89699b28cce7ef6f037b6215
BLAKE2b-256 checksum
How to use checksums
bc5e2001f23881d50a4c9481314b1eabdc646c27bda78cb2d458f5194340d0cf
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 28, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.10-cp311-abi3-win_amd64.whl
Size 856.6 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3286739c8a439e06343ae249b8b07bb432cad4f366073beceb36148e8e549b00
BLAKE2b-256 checksum
How to use checksums
0b86a577fa12e130c509fbb70fb6fd98313868b0681c99deb6488ff746ea0bc6
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 28, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.10-cp311-abi3-manylinux_2_34_x86_64.whl
Size 941.2 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
c77ca4d837315634620c15edede5745a4e39f5ef181a72b2c6215d3b4f0302e9
BLAKE2b-256 checksum
How to use checksums
31a22ee740327a7aa9c537d944f7d631eb51503c14925ed00d24207a96692c6d
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 28, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.10-cp311-abi3-manylinux_2_34_s390x.whl
Size 1.0 MB
Tags CPython 3.11 Linux glibc 2.34+ IBM System/390x abi3
SHA-256 checksum
How to use checksums
f704c7e4428020f5f5145be8b45c28766f76d70c4dc95dc234851a41ec690f31
BLAKE2b-256 checksum
How to use checksums
f253e9199296bd7a37e4d1150b21cef134f168b05e51eb4a12a671f571aa7be7
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 28, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.10-cp311-abi3-manylinux_2_34_ppc64le.whl
Size 974.2 kB
Tags CPython 3.11 Linux glibc 2.34+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
4ec16fc969c4b8d11b3fce7fd72ad3b3c25c5e9bf5ee042c3e0e264a5c28fc18
BLAKE2b-256 checksum
How to use checksums
6f3fb22312ee4f21b8851651ebbb4d2809a23c65eea3748602f80d3f81966dcb
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 28, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.10-cp311-abi3-manylinux_2_34_aarch64.whl
Size 891.5 kB
Tags CPython 3.11 Linux glibc 2.34+ ARM64 abi3
SHA-256 checksum
How to use checksums
f04bc59199afcff20d2773f6986a3920ccda22885535311223128861b82f500e
BLAKE2b-256 checksum
How to use checksums
b78cfde8cbab7a151c66b11aea56c3ad22e0a81ffa379ef4d6d74f9d3f58e591
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 28, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.10-cp311-abi3-macosx_11_0_arm64.whl
Size 835.3 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
28724ddd3d1aaf1e39b4da512c1c4f3e63a21ac0b65ef554c1f92ea72206184b
BLAKE2b-256 checksum
How to use checksums
3ccab9f0af9e7ddc66fba07ba051d5c974901531bce4fa0185acbe696d7a3978
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 28, 2026.

Transparency log

Security for cpex-url-reputation 0.3.10

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.10.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 28, 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