Expand description
Web sanitize: URL fetch + 2-layer injection strip + envelope wrap. Covers the L4 × V1 cell (cf. crate root §Threat surface × vector).
§Pipeline
fetch_and_sanitize composes:
fetch::get— HTTP GET with a 2 MiB body cap and a configurable timeout driven bycrate::config::WebConfig::timeout_secs. Non-2xx responses and oversized bodies are rejected, not truncated.sanitize::regex_layer::strip— fast local pass that replaces known injection markers with the literal[STRIPPED].sanitize::semantic_layer::review— optional LLM-backed pass that runs only whenANTHROPIC_API_KEYis set (fail-open; see that module).sanitize::wrap::envelope— wrap the cleaned body in an<untrusted_content src=... sanitized_at=... removed_patterns=...>envelope so the caller LLM physically separates instruction from data.
Result is persisted to <home>/web_log/<UTC-ts>-<id>.json as an audit
row.
§Read-only invariant
The fetched body is never written to disk in raw form. Only the sanitized envelope text and the list of removed patterns are persisted.
Modules§
- fetch
- HTTP fetch with a hard body cap and a configurable timeout.
- sanitize
- Two-layer sanitize pipeline for fetched URL content.
Structs§
- Sanitized
Content - One sanitize call’s full result payload.
Functions§
- fetch_
and_ sanitize - Fetch a URL, run the 2-layer sanitize pipeline, wrap in
<untrusted_content>, and persist to<cfg.paths.home>/web_log/.