Skip to content

Commit 79e59ee

Browse files
msureshkumar88Suresh Kumar Moharajan
authored andcommitted
fix(plugins): recover missing Rust implementation for url_reputation plugin (#38)
* fix(plugins): recover missing Rust implementation for url_reputation plugin The url_reputation plugin was missing its complete Rust implementation after migration from mcp-context-forge. This commit recovers all missing Rust source files from git history (commit 8bb308c50). Recovered files: - src/engine.rs (707 lines) - Core validation engine - src/types.rs (79 lines) - Type definitions and PyO3 bindings - src/filters/ - Heuristic, IANA TLD, and pattern filters - benches/url_validation.rs - Performance benchmarks - Enhanced test suite and documentation The plugin now has complete functionality including: - URL reputation validation with configurable policies - Heuristic entropy-based checks - IANA TLD validation - Pattern-based allow/block lists - Domain whitelist/blocklist support - HTTP/HTTPS scheme enforcement Updated Cargo.toml with required dependencies: - idna, url, regex for URL parsing and validation - phf for efficient TLD lookups - unicode-script, unicode-security for domain validation - criterion for benchmarking Fixed test imports to use cpex_url_reputation module path. Added _RUST_AVAILABLE flag for Python fallback detection. Build verification: - All 24 Rust unit tests pass - 30 out of 32 Python tests pass (2 pre-existing test issues) - Plugin compiles and installs successfully Signed-off-by: Suresh Kumar Moharajan <suresh.kumar.m@ibm.com> * fix(plugins): remove Python fallback logic from url_reputation plugin The url_reputation plugin now requires the Rust implementation and will raise a clear error if the Rust module is not available, rather than falling back to a limited Python implementation. Changes: - Modified URLReputationPlugin.__init__ to raise RuntimeError if Rust module is not available - Removed all Python fallback tests (test_python_* functions) - Removed Rust error fallback test (test_rust_error_fallback_blocks_url) - Plugin now enforces Rust-only operation for consistency and performance Test results: - 22 tests passed - 9 tests skipped (Rust-specific features) - 0 tests failed This ensures users get the full Rust-powered functionality or a clear error message to install the plugin properly with 'make install'. Signed-off-by: Suresh Kumar Moharajan <suresh.kumar.m@ibm.com> --------- Signed-off-by: Suresh Kumar Moharajan <suresh.kumar.m@ibm.com> Co-authored-by: Suresh Kumar Moharajan <suresh.kumar.m@ibm.com> Signed-off-by: lucarlig <luca.carlig@ibm.com>
1 parent 0f75b05 commit 79e59ee

17 files changed

Lines changed: 2705 additions & 55 deletions

File tree

Cargo.lock

Lines changed: 104 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/rust/python-package/url_reputation/Cargo.toml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "url_reputation"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
edition.workspace = true
55
authors.workspace = true
66
license.workspace = true
@@ -16,5 +16,29 @@ name = "stub_gen"
1616
path = "src/bin/stub_gen.rs"
1717

1818
[dependencies]
19-
pyo3 = { workspace = true }
19+
idna = "1.1.0"
20+
log = "0.4"
21+
phf = { version = "0.13.1", features = ["macros"] }
22+
pyo3 = { workspace = true, features = ["abi3-py311"] }
2023
pyo3-log = { workspace = true }
24+
regex = "1.12.3"
25+
unicode-script = "0.5.8"
26+
unicode-security = "0.1.2"
27+
url = "2.5.8"
28+
29+
[dev-dependencies]
30+
criterion = "0.8.2"
31+
32+
[[bench]]
33+
name = "url_validation"
34+
harness = false
35+
36+
[profile.release]
37+
opt-level = 3
38+
lto = "fat"
39+
codegen-units = 1
40+
strip = true
41+
42+
[profile.bench]
43+
inherits = "release"
44+
debug = true

0 commit comments

Comments
 (0)