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

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.7
File Size Uploaded
cpex_url_reputation-0.3.7.tar.gz 45.2 kB Details

Built distributions (wheels)

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

Total release size: 5.6 MB

Release files / cpex_url_reputation-0.3.7.tar.gz

Download URL cpex_url_reputation-0.3.7.tar.gz
Size 45.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b6d1b6dda6fd5e17f810ea877e4160a734efe4a015a13a8b02483b2cf3ad4a04
BLAKE2b-256 checksum
How to use checksums
2ac29f4ae45fd17b3365669185a267984df0f593a10760e59b026577c4fa92e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.7-cp311-abi3-win_amd64.whl
Size 858.2 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e9baa07e060eb5b6b02a0a1a112c1751b3b04ecebfd74b8471977be5c99042e6
BLAKE2b-256 checksum
How to use checksums
3805b68d8e1448ab3501d247c53937c0418711ab872c4ababbbc6a5768ebd96c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.7-cp311-abi3-manylinux_2_34_x86_64.whl
Size 945.1 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
f8922431300d3ea464f79088f066dfce11382aa5cd6878feee6e465ef8ebf0b6
BLAKE2b-256 checksum
How to use checksums
261bd30570b1650809f852679b292bd8ac80973ee244c6bdad7a89acabd425d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.7-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
bec4afa79bbf5fa214c8f29764dccfdfce16e3abcf2a0b13b05f6c56acdb3168
BLAKE2b-256 checksum
How to use checksums
a8cee2a466b76d422bd51f2799d23cfaa55fb8dcdd058f3837878c6034f7c88f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.7-cp311-abi3-manylinux_2_34_ppc64le.whl
Size 983.8 kB
Tags CPython 3.11 Linux glibc 2.34+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
20a88694e9c0a2d2a6d7302b4f6f48038fdeb4fe75f33f5686edbfa6c9be97de
BLAKE2b-256 checksum
How to use checksums
88c6f013eb5d3a62908a9735aa873ab91669c4b9563bbd31814809bf53a072b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.7-cp311-abi3-manylinux_2_34_aarch64.whl
Size 896.3 kB
Tags CPython 3.11 Linux glibc 2.34+ ARM64 abi3
SHA-256 checksum
How to use checksums
feaa2789d8a1849ff7bd8d50bf8ec028407e123b0ae7102ac220b8dd3caab57f
BLAKE2b-256 checksum
How to use checksums
a66e630b72c4cfed7b78176ce6dfcb7dd21b48ab84d564139a9bdbb28b6e015f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

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

Download URL cpex_url_reputation-0.3.7-cp311-abi3-macosx_11_0_arm64.whl
Size 839.3 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
67c6448d1963b4ff3863c6a9212c5ac2dc02d5fa0acb888e0938986ba6f7ba12
BLAKE2b-256 checksum
How to use checksums
a3eea4bcdd72c883f2d61a4fe67f7d10f5dfd8bc28b53dfb27aac6aebdfc283e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.9

7 release files

0.3.8

7 release files

This release

0.3.7 This release

7 release files

0.3.6

7 release files

0.3.5

7 release files

0.3.4

7 release files

0.3.3

7 release files

0.3.2

7 release files

0.3.1

7 release files

0.3.0

7 release files

0.2.1

7 release files

0.2.0

7 release files

0.1.1

7 release files

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