Skip to content

feat: env var injection + per-service scrub toggle (Plan 7)#208

Merged
erans merged 2 commits intomainfrom
plan7-env-injection
Apr 10, 2026
Merged

feat: env var injection + per-service scrub toggle (Plan 7)#208
erans merged 2 commits intomainfrom
plan7-env-injection

Conversation

@erans
Copy link
Copy Markdown
Collaborator

@erans erans commented Apr 10, 2026

Summary

  • Wire service fake credentials into spawned agent environments via inject.env policy config, with collision detection against operator env_inject
  • Make response body scrubbing conditional per-service via scrub_response flag in CredsSubHook
  • Validate inject.env names at policy load time (empty, invalid chars, cross-service duplicates, reserved AGENTSH_ prefix with case-insensitive check)
  • Inject service env vars in all three exec paths (exec, streaming exec, PTY) bypassing policy filtering since vars like GITHUB_TOKEN are in the default-deny list

Test plan

  • Unit tests for BuildServiceEnvVars (happy path, unknown service, empty input, duplicate name, OS-aware case folding, nil table, invalid name)
  • Unit tests for CheckEnvCollisions (no collision, single/multiple collisions, both nil, case-insensitive on Windows)
  • Unit tests for ValidateSecrets inject.env validation (empty name, invalid char, duplicate, valid, reserved prefix case-insensitive)
  • Unit tests for CredsSubHook scrub toggle (disabled, enabled, nil map backward compat)
  • Unit tests for Session.ServiceEnvVars (nil, set, deep copy)
  • Composition test for full injection + collision detection + scrub flow
  • go test ./... passes
  • GOOS=windows go build ./... cross-compile passes

🤖 Generated with Claude Code

erans and others added 2 commits April 10, 2026 07:18
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire service fake credentials into the spawned agent's environment via
inject.env, with collision detection against env_inject, and make response
scrubbing conditional per service via scrub_response.

Changes:
- Extend resolver to extract inject.env and scrub_response from policy YAML
- BuildServiceEnvVars maps service fakes to env var names (OS-aware case folding)
- Validate inject.env names in ValidateSecrets (empty, invalid chars, duplicates,
  reserved AGENTSH_ prefix)
- CheckEnvCollisions detects env_inject vs service env var conflicts
- Wire env vars through Session + StartLLMProxy with collision detection
- Inject service fake credentials into all exec paths (exec, streaming, PTY)
- Per-service scrub_response toggle in CredsSubHook (nil=scrub all for
  backward compat, empty map=scrub none, populated=selective)
- Composition test covering full injection + collision + scrub flow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@erans erans merged commit 7212fda into main Apr 10, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant