SecretBuilder
Builder for configuring a secret’s placeholder, allowed hosts, and injection scopes. Obtained throughSandboxBuilder::secret(|s| s...). Each secret maps an environment variable to a real value that is only revealed when traffic goes to an allowed host via the TLS proxy.
allow_any_host_dangerous()
| Name | Type | Description |
|---|---|---|
| i_understand_the_risk | bool | Must be true to take effect |
allow_host()
| Name | Type | Description |
|---|---|---|
| host | impl Into<String> | Exact hostname (e.g. "api.openai.com") |
allow_host_pattern()
* matches any subdomain prefix.
Parameters
| Name | Type | Description |
|---|---|---|
| pattern | impl Into<String> | Wildcard pattern (e.g. "*.googleapis.com") |
env()
$MSB_<var> (or a custom placeholder) - never the real value. Required.
Parameters
| Name | Type | Description |
|---|---|---|
| var | impl Into<String> | Environment variable name (e.g. "OPENAI_API_KEY") |
inject_basic_auth()
Authorization header lines. When inject_headers is true, this has no additional effect since all headers are already covered.
Parameters
| Name | Type | Description |
|---|---|---|
| enabled | bool | Default: true |
inject_body()
Content-Length header to match the new body size after substitution.
Parameters
| Name | Type | Description |
|---|---|---|
| enabled | bool | Default: false |
inject_headers()
Authorization: Bearer $MSB_... and similar patterns.
Parameters
| Name | Type | Description |
|---|---|---|
| enabled | bool | Default: true |
inject_query()
?key=value portion of the request line).
Parameters
| Name | Type | Description |
|---|---|---|
| enabled | bool | Default: false |
placeholder()
$MSB_<env_var>. Use this when you need a specific format or when the placeholder must match a particular byte length.
Parameters
| Name | Type | Description |
|---|---|---|
| placeholder | impl Into<String> | Custom placeholder string |
require_tls_identity()
true, the secret is only substituted on TLS-intercepted connections where the proxy has verified it is performing MITM. When false, substitution also happens on non-intercepted (bypass) connections. Disable only if you know the traffic is safe.
Parameters
| Name | Type | Description |
|---|---|---|
| enabled | bool | Default: true |
value()
| Name | Type | Description |
|---|---|---|
| value | impl Into<String> | The actual credential or token |
Shorthand
secret_env()
SandboxBuilder. Equivalent to .secret(|s| s.env(env_var).value(value).allow_host(allowed_host)). Uses default injection scopes (headers enabled, body disabled).
Parameters
| Name | Type | Description |
|---|---|---|
| env_var | impl Into<String> | Environment variable name |
| value | impl Into<String> | Secret value |
| allowed_host | impl Into<String> | Allowed destination host |
Types
ViolationAction
Configured viaNetworkBuilder::on_secret_violation(). Determines what happens when the guest sends a request containing a secret placeholder to a host that is not in the secret’s allow list.
| Value | Description |
|---|---|
Block | Silently drop the request. The guest sees a connection reset. This is the default. |
BlockAndLog | Drop the request and emit a warning log on the host side. |
BlockAndTerminate | Drop the request, log an error, and shut down the entire sandbox. |