Skip to main content
A SecurityPolicy is passed to Create() via the WithSecurity option. It composes PII detection, injection defense, toxicity / code-security / invisible-text scanners, network policy, transformation rules, audit logging, and environment variable security into a single struct.

SecurityPolicy

Methods


PIIConfig

Configure detection and handling of personally identifiable information in outbound HTTP traffic.

PIIType constants

RedactionAction constants


InjectionDefenseConfig

Detect and block prompt injection attempts in outbound HTTP request bodies.

ToxicityConfig

Scan outbound HTTP request bodies for toxic content.

CodeSecurityConfig

Detect suspicious code in outbound HTTP request bodies.

InvisibleTextConfig

Detect invisible or control Unicode characters in outbound HTTP request bodies.

CustomPolicyConfig

Attach OPA/Rego policy — a built-in governance pack via PolicyRef, or your own rules via InlineRego/InlineModules. Custom rules are evaluated at the enforcement layer alongside the platform defaults and can only tighten policy, never relax it.
See Custom Policy and Governance Packs for the full guides.

ContentGateConfig

Run the content.scan OPA gate (e.g. an LLM model allowlist / cross-signal rules) on the listed domains. Opts a sandbox into content-gate enforcement without requiring an ML scanner to be enabled.
See Custom Policy for details.

NetworkPolicy

Network allowlist and denylist for outbound traffic from the sandbox.

TransformationRule

Regex-based text transformation applied to outbound request bodies, inbound response bodies, or both.

AuditConfig

Toggle audit logging for sandbox activity.

EnvSecurityConfig

Control how environment variable values are masked in audit logs.

Full policy example