Skip to main content

What You’ll Learn

  • How to configure every security layer in the Declaw SDK in a single SecurityPolicy
  • How transformation rules mask internal hostnames and API key patterns in transit
  • How to inspect the configured security policy programmatically
  • The defense-in-depth model: six independent layers that work together

Prerequisites

  • Declaw running locally or in the cloud (see Deployment)
  • DECLAW_API_KEY and DECLAW_DOMAIN set in your environment
This example is available in Python. TypeScript support coming soon.

Security Layers Configured

Code Walkthrough

1. Define transformation rules

Transformation rules apply regex replacements to HTTP request and response bodies passing through the proxy:

2. Build the full SecurityPolicy

Injection scanning is opt-in per domain and outbound-only: the domains list names the egress hosts whose request bodies are scanned (here, the only allowed egress host). An empty or unset domains list means no scanning, even with enabled=True.

3. Create the sandbox with network policy and security policy

4. The agent script (runs inside the secured sandbox)

The agent processes PII-like data and tests network connectivity. In a live deployment with the guardrails service active, any email or phone number in HTTP traffic would be redacted before leaving the sandbox:

5. Run the agent and inspect results

Expected Output

Defense-in-Depth Summary

Each layer operates independently. A failure in one layer (for example, a misconfigured transformation rule) does not reduce the protection provided by the others.