Commit 79e59ee
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
- plugins/rust/python-package/url_reputation
- benches
- cpex_url_reputation
- src
- filters
- tests
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
0 commit comments