Repository navigation
feat(agent): add [config_env] for non-sensitive agent environment - #73
Merged
Merged
Conversation
Profiles can now set plaintext config variables for the sandboxed agent.
Both backends apply them; the Docker backend previously had no way to set
any. Values may be strings, numbers or booleans.
Names the sandbox owns (proxy/CA vars, HOME, TMPDIR, FORCE_COLOR,
STASHBASE_*) or that a [secrets]/[personal_credentials] binding provides
are rejected. Values that look like credentials (name, known token
prefix, URL password, high entropy) warn in `agent validate`, and
`agent run` asks to confirm them, failing when it can't ask. A value is
acknowledged with `{ value = "...", not_secret = true }`.
Each NAME=value may be up to 64 KiB and the whole table up to 256 KiB, well within the spawn limits (128 KiB per string on Linux, ~1 MB for arguments and environment on macOS). NUL bytes can't be held by an environment variable and are rejected with a clear error. Errors name the variable and size, never the value.
config_env is set on the native launcher (bwrap, systemd-run) before any confinement exists, and the launcher is found through the child's PATH. A repository profile setting PATH or LD_PRELOAD could therefore run its own code outside the sandbox. Reject those names in validation, and skip reserved names when building the child env as a backstop.
Sets or overrides a [config_env] variable for one run. Values go through the same name, size and reserved-name validation as the profile's; the credential check is skipped since the person running the agent typed them.
Windows treats environment variable names case-insensitively, so github_token in [config_env] would shadow a binding exposed as GITHUB_TOKEN.
Runs that differ only in [config_env] (or --config-env) can now be told apart in the audit log. Only names are recorded, never values.
Flag values reach the agent in plaintext like the profile's, so they get the same confirm-or-fail check.
…es show Flagged values without not_secret = true are shown as <hidden: looks like a credential> in both TOML and JSON output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Agent profiles can now set plaintext, non-sensitive config for the sandboxed agent with a
[config_env]table. Before this, the Docker backend had no way to set any variables (the container starts with an empty environment), and the native backend only had whatever happened to be in the user's shell.--config-env NAME=VALUEonagent runsets or overrides a value for one run.Guardrails
HOME,TMPDIR,FORCE_COLOR,STASHBASE_*, andPATH/LD_*/DYLD_*. The last group matters:[config_env]is applied to the native launcher (bwrap,systemd-run) before confinement, and the launcher is found through the child'sPATH, so a repository profile could otherwise run its own code outside the sandbox. Reserved names are also skipped when building the child env, as a backstop.[secrets]/[personal_credentials]binding provides (itsenv, or a renamedfrom) is rejected, case-insensitively.NAME=value, 256 KiB total; NUL bytes rejected.agent validate;agent runasks for confirmation and fails when it can't ask (non-interactive or--silent). Applies to--config-envvalues too.not_secret = trueacknowledges a false positive. Values are never printed, andagent profiles showdisplays flagged values as<hidden: looks like a credential>.session_startedevent recordsconfig_env_names(names only).Also: a commented
[config_env]example in theagent inittemplate, docs indocs/agent-profiles.md, a short README section, and an example profile atdocs/agent-profiles/examples/config-env.toml.Testing
cargo test: all pass (615 unit + integration suites), with new tests for detection, validation (reserved/invalid/conflicting names, limits, NUL), value parsing, the flag parser, env merging, audit field, masking and the init template.not_secretacknowledgement, values reaching the agent,HTTPS_PROXYnot overridable,PATH/LD_PRELOADrejected,--config-env(incl. values containing=), audit event contents, maskedprofiles show(TOML and JSON).