From cccbbc2485a0f8c4af5ca23238ee8c625df6caf2 Mon Sep 17 00:00:00 2001 From: jedarden Date: Mon, 6 Jul 2026 17:58:10 -0400 Subject: [PATCH] feat(bf-pxdn0): add SSRF_BLOCKED helper function signature - Add standalone is_ssrf_blocked() function to mcp_helpers module - Function accepts JsonRpcError reference and returns bool (stub returning false) - Added comprehensive documentation with usage examples - Located in TH-05-ssrf-block.rs after is_ssrf_blocked_error() function - Verification: notes/bf-pxdn0.md Closes bf-pxdn0 --- .../pdftract-core/tests/TH-05-ssrf-block.rs | 36 +++++++++++++++ notes/bf-pxdn0.md | 46 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 notes/bf-pxdn0.md diff --git a/crates/pdftract-core/tests/TH-05-ssrf-block.rs b/crates/pdftract-core/tests/TH-05-ssrf-block.rs index 95976dc..b116556 100644 --- a/crates/pdftract-core/tests/TH-05-ssrf-block.rs +++ b/crates/pdftract-core/tests/TH-05-ssrf-block.rs @@ -751,6 +751,42 @@ pub mod mcp_helpers { Ok(false) } + /// Check if a JsonRpcError indicates an SSRF_BLOCKED error. + /// + /// This is a standalone helper function that accepts a JsonRpcError reference + /// and returns a boolean indicating whether the error represents an SSRF_BLOCKED + /// condition. + /// + /// # Arguments + /// + /// * `error` - Reference to the JsonRpcError to check + /// + /// # Returns + /// + /// * `true` if the error indicates SSRF_BLOCKED + /// * `false` otherwise (currently a stub implementation) + /// + /// # Example + /// + /// ```rust + /// use mcp_helpers::{is_ssrf_blocked, JsonRpcError}; + /// + /// let error = JsonRpcError { + /// code: -32001, + /// message: "SSRF_BLOCKED: URL rejected".to_string(), + /// data: None, + /// }; + /// + /// if is_ssrf_blocked(&error) { + /// // Handle SSRF blocked error + /// } + /// ``` + pub fn is_ssrf_blocked(error: &JsonRpcError) -> bool { + // Stub implementation - returns false for now + // TODO: Implement proper SSRF_BLOCKED detection logic + false + } + /// Extract error information from a JSON-RPC error response. /// /// Returns a tuple of (code, message, optional_data) for easier error handling. diff --git a/notes/bf-pxdn0.md b/notes/bf-pxdn0.md new file mode 100644 index 0000000..10e7c11 --- /dev/null +++ b/notes/bf-pxdn0.md @@ -0,0 +1,46 @@ +# Bead bf-pxdn0: Add SSRF_BLOCKED helper function signature + +## Summary + +Added a standalone helper function `is_ssrf_blocked()` to the `mcp_helpers` module in the TH-05 SSRF test file. The function accepts a `JsonRpcError` reference and returns a boolean. + +## Implementation + +**File Modified:** `/home/coding/pdftract/crates/pdftract-core/tests/TH-05-ssrf-block.rs` + +**Function Added:** +```rust +pub fn is_ssrf_blocked(error: &JsonRpcError) -> bool { + // Stub implementation - returns false for now + // TODO: Implement proper SSRF_BLOCKED detection logic + false +} +``` + +**Location:** Added after the `is_ssrf_blocked_error()` function (around line 754) in the `mcp_helpers` module. + +## Acceptance Criteria Status + +- ✅ **PASS**: Function exists with correct signature accepting `JsonRpcError` reference +- ✅ **PASS**: Function returns `bool` type +- ✅ **PASS**: Function compiles successfully (verified with `cargo check --tests -p pdftract-core`) +- ✅ **PASS**: Function is a stub that returns `false` + +## Notes + +- The function is added as a standalone helper in the `mcp_helpers` module (line 754-770) +- It follows the same pattern as other helper functions in the module (e.g., `is_ssrf_blocked_error()`) +- The function is well-documented with comprehensive doc comments including usage examples +- This provides a clean API for checking SSRF errors separate from the method on `JsonRpcError` itself +- The implementation is intentionally left as a stub (returns `false`) as specified in the acceptance criteria + +## Testing + +The code compiles successfully without any errors. The function signature matches the requirements exactly and can be called with a `JsonRpcError` reference: + +```rust +let error = JsonRpcError { /* ... */ }; +if is_ssrf_blocked(&error) { + // Handle SSRF blocked case +} +```