What You’ll Learn
- Creating a sandbox with
InjectionDefenseConfiginside aSecurityPolicy - Sensitivity levels:
LOW,MEDIUM,HIGH— and when to use each - Enforcement actions:
BLOCK,LOG_ONLY - Scoping scanning to specific egress domains with
domains=[...] - Example injection payloads the scanner detects (prompt override, base64-encoded attacks)
- Shorthand boolean syntax:
injection_defense=Truefor default settings
Prerequisites
- Declaw instance running and
DECLAW_API_KEY/DECLAW_DOMAINset - (Optional) Guardrails service deployed for ML-powered scanning — falls back to regex without it
Code Walkthrough
This example is available in Python. TypeScript support coming soon.
1. Create a sandbox with injection defense
Pass anInjectionDefenseConfig to SecurityPolicy at sandbox creation time. The proxy enforces the policy for outbound HTTP requests to the domains you list.
domains (here, the LLM API the sandbox calls). An empty or unset domains list means no scanning happens at all, even with enabled=True.
2. Sensitivity levels
Thesensitivity field controls how aggressively the scanner flags content.
3. Enforcement actions
When the scanner detects an injection attempt, theaction field determines what happens.
4. Example payloads the scanner catches
5. Shorthand boolean syntax
For default settings —sensitivity="medium", action="log_only" — pass True directly:
domains, so on its own it scans nothing. To actually scan traffic, use the explicit config form and list the egress hosts (an empty domains list means no scanning):