Skip to main content
See Secrets for how placeholder substitution works and usage examples. Secrets never enter the VM. The Go SDK passes each SecretEntry to the runtime, which exposes a placeholder string inside the guest (e.g. $MSB_SERVICE_API_KEY) and substitutes the real value at the network layer only when traffic reaches an allowed host.

Host matching

Go does not expose the Rust HostPattern enum directly. Exact and wildcard host patterns are represented with the AllowHosts and AllowHostPatterns fields on SecretEntry and SecretEnvOptions. These fields decide where the real secret value may be substituted. A host that is not matched by either field is disallowed for that secret, so sending its placeholder there triggers the configured ViolationAction. Allow-list entries are pinned to observed DNS answers and TLS identity. At least one exact or wildcard host is required.

Functions

WithSecrets()

Append credential secrets to the sandbox. Each call appends, so multiple calls accumulate. Secrets never enter the VM; the network proxy substitutes them at the transport layer. Pass to CreateSandbox alongside the other options.

Parameters

Secret entries to attach, usually built with Secret.Env.

Returns

SandboxOption
Functional option for CreateSandbox.

Methods

The Secret factory is a package-level value. Call its methods to build SecretEntry values without populating struct literals by hand.

Secret.Env()

Build a SecretEntry that maps an environment variable to a real value. The guest sees a placeholder; the real value is substituted by the TLS proxy only when traffic goes to an allowed host. Pass an empty SecretEnvOptions{} when no extra tuning is needed.

Parameters

envVarstring
Environment variable name holding the placeholder inside the sandbox. Must be non-empty and cannot contain = or NUL; shell-identifier syntax is not required.
valuestring
The real secret value. Never crosses the FFI into the guest.
Allowed hosts, placeholder override, TLS requirement, and violation action.

Returns

Types

SecretEntrystruct

accepted by WithSecrets() · returned by Secret.Env()

A single credential the network proxy substitutes at the transport layer. The value never reaches the guest VM. Usually produced by Secret.Env; exported for callers that prefer struct literals.

SecretEnvOptionsstruct

accepted by Secret.Env()

Tunes Secret.Env beyond the required envVar and value.

ViolationActionstring enum

field of SecretEntry · NetworkConfig

What happens when a secret placeholder is detected going to a host the secret isn’t allowed to talk to. Configure the sandbox-wide default on NetworkConfig.OnSecretViolation; override per-secret with SecretEntry.OnViolation.