Skip to content

feat: add --exclude-env flag to exclude specific vars from --env-all passthrough#1482

Merged
lpcox merged 5 commits intomainfrom
copilot/fix-one-shot-token-list
Mar 28, 2026
Merged

feat: add --exclude-env flag to exclude specific vars from --env-all passthrough#1482
lpcox merged 5 commits intomainfrom
copilot/fix-one-shot-token-list

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

--env-all passes all host environment variables into the agent container with no runtime way to exclude specific secrets (e.g. GITHUB_MCP_SERVER_TOKEN, GH_AW_GITHUB_TOKEN). The only exclusion mechanism was the hardcoded EXCLUDED_ENV_VARS set.

Changes

  • src/types.ts — added excludeEnv?: string[] to WrapperConfig
  • src/cli.ts — added --exclude-env <name> as a repeatable option adjacent to --env-all; wired into WrapperConfig
  • src/docker-manager.ts — merges config.excludeEnv entries into EXCLUDED_ENV_VARS before the envAll loop
  • src/docker-manager.test.ts — 5 new unit tests covering single/multiple exclusions, no-op without --env-all, and GITHUB_TOKEN exclusion
  • docs-site/…/cli-reference.md — added --exclude-env to options table

Usage

awf --env-all \
  --exclude-env GITHUB_MCP_SERVER_TOKEN \
  --exclude-env GH_AW_GITHUB_TOKEN \
  -- claude ...

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Copilot AI changed the title [WIP] Fix incomplete one-shot token list for environment secrets feat: add --exclude-env flag to exclude specific vars from --env-all passthrough Mar 28, 2026
Copilot AI requested a review from lpcox March 28, 2026 14:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 28, 2026

Documentation Preview

Documentation build failed for this PR. View logs.

Built from commit e2558f0

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 82.72% 82.81% 📈 +0.09%
Statements 82.38% 82.47% 📈 +0.09%
Functions 81.50% 81.22% 📉 -0.28%
Branches 76.19% 76.08% 📉 -0.11%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/cli.ts 61.2% → 61.1% (-0.10%) 61.6% → 61.5% (-0.10%)
src/docker-manager.ts 86.0% → 86.5% (+0.48%) 85.5% → 86.0% (+0.47%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions

This comment has been minimized.

…hub.com (#1483)

* Initial plan

* fix: recompile smoke-codex with gh-aw v0.64.2 to add github.com to allowed domains

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 82.72% 82.81% 📈 +0.09%
Statements 82.38% 82.47% 📈 +0.09%
Functions 81.50% 81.22% 📉 -0.28%
Branches 76.19% 76.08% 📉 -0.11%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/cli.ts 61.2% → 61.1% (-0.10%) 61.6% → 61.5% (-0.10%)
src/docker-manager.ts 86.0% → 86.5% (+0.48%) 85.5% → 86.0% (+0.47%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions
Copy link
Copy Markdown
Contributor

Smoke test results (run 23688357079)

✅ GitHub MCP — Last 2 merged PRs: #1483 "fix: recompile smoke-codex workflow with gh-aw v0.64.2 to unblock github.com", #1470 "rename awf-issue-auditor → firewall-issue-dispatcher and prefix created issues with [awf]"
✅ Playwright — https://github.com title contains "GitHub"
✅ File write — /tmp/gh-aw/agent/smoke-test-copilot-23688357079.txt created and verified
✅ Bash — cat confirmed file contents

Overall: PASS

PR author: @Copilot · Assignees: @lpcox @Copilot

📰 BREAKING: Report filed by Smoke Copilot for issue #1482

@github-actions
Copy link
Copy Markdown
Contributor

Smoke test results — PASS

Test Result
GitHub MCP: #1483 fix: recompile smoke-codex workflow
GitHub MCP: #1470 rename awf-issue-auditor → firewall-issue-dispatcher
Playwright: github.com title contains "GitHub"
File write/read: smoke-test-claude-23688357068.txt

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude for issue #1482

@github-actions
Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3 ❌ NO
Node.js v24.14.0 v20.20.1 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall: ❌ FAILED — Python and Node.js versions differ between host and chroot.

Tested by Smoke Chroot for issue #1482

@github-actions

This comment has been minimized.

@github-actions github-actions bot mentioned this pull request Mar 28, 2026
* Initial plan

* fix: postprocess regex to match gh-aw v0.64.2 install path

Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/2fc9b7aa-85e8-4db2-99c3-53b5e7c5c9b9

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 82.72% 82.81% 📈 +0.09%
Statements 82.38% 82.47% 📈 +0.09%
Functions 81.50% 81.22% 📉 -0.28%
Branches 76.19% 76.08% 📉 -0.11%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/cli.ts 61.2% → 61.1% (-0.10%) 61.6% → 61.5% (-0.10%)
src/docker-manager.ts 86.0% → 86.5% (+0.48%) 85.5% → 86.0% (+0.47%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

GitHub MCP — Last 2 merged PRs: "[WIP] Fix failing GitHub Actions workflow agent" (#1484), "fix: recompile smoke-codex workflow with gh-aw v0.64.2 to unblock github.com" (#1483)
Playwright — github.com title contains "GitHub"
File Write/tmp/gh-aw/agent/smoke-test-claude-23688803164.txt created
Bash Verify — File contents confirmed

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude for issue #1482

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results — Copilot Engine

Test Result
GitHub MCP (last 2 merged PRs) #1484 "[WIP] Fix failing GitHub Actions workflow agent", #1483 "fix: recompile smoke-codex workflow with gh-aw v0.64.2 to unblock github.com"
Playwright (github.com title) ✅ "GitHub · Change is constant. GitHub keeps you ahead. · GitHub"
File write + read back /tmp/gh-aw/agent/smoke-test-copilot-23688803209.txt created
Bash tool

Overall: PASS — PR by @Copilot, assignees: @lpcox @Copilot

📰 BREAKING: Report filed by Smoke Copilot for issue #1482

@github-actions
Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.14.0 v20.20.1
Go go1.22.12 go1.22.12

Overall: ❌ FAILED — Python and Node.js versions differ between host and chroot.

Tested by Smoke Chroot for issue #1482

@github-actions
Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #1482 ·

@lpcox lpcox marked this pull request as ready for review March 28, 2026 16:23
@lpcox lpcox requested a review from Mossaka as a code owner March 28, 2026 16:23
Copilot AI review requested due to automatic review settings March 28, 2026 16:23
@lpcox lpcox merged commit dc2d477 into main Mar 28, 2026
57 of 61 checks passed
@lpcox lpcox deleted the copilot/fix-one-shot-token-list branch March 28, 2026 16:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a user-configurable exclusion list for --env-all so callers can prevent specific sensitive host environment variables from being passed into the agent container, beyond the built-in hardcoded exclusions.

Changes:

  • Introduces --exclude-env <name> (repeatable) and plumbs it through WrapperConfig.excludeEnv.
  • Applies excludeEnv during Docker Compose env construction and adds unit tests + CLI docs.
  • Regenerates/updates the smoke-codex workflow (plus a small CI postprocess script tweak).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/types.ts Adds WrapperConfig.excludeEnv?: string[] and documents intended behavior.
src/cli.ts Adds --exclude-env CLI option and maps it into WrapperConfig.
src/docker-manager.ts Incorporates excludeEnv into env passthrough exclusion behavior.
src/docker-manager.test.ts Adds unit tests validating env exclusion behavior with --env-all.
docs-site/src/content/docs/reference/cli-reference.md Documents --exclude-env in CLI reference table.
scripts/ci/postprocess-smoke-workflows.ts Updates install-step matching and replacement logging for smoke workflows.
.github/workflows/smoke-codex.md Removes the prior sandbox MCP stanza from the workflow markdown.
.github/workflows/smoke-codex.lock.yml Large regenerated lock workflow update (new versions/structure/jobs/steps).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 15 to +32
@@ -30,7 +29,7 @@
# - shared/mcp/tavily.md
# - shared/reporting.md
#
# gh-aw-metadata: {"schema_version":"v2","frontmatter_hash":"4e90f52021e1c90e79dd139075b622e6533a4d7555cf9340fa36415e3412c288","compiler_version":"v0.58.2","strict":true}
# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"c67bf3be0932087b7113808cd5143f5bf3bf6a4c7dc510c6bda41972642fb37e","compiler_version":"v0.64.2","strict":true,"agent_id":"codex"}
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is described as adding --exclude-env, but it also includes a large regeneration/behavior change of the smoke-codex workflow (new gh-aw compiler/schema version, new jobs/steps, changed action sources/paths, etc.). Please confirm this broad workflow change is intentional and in-scope for this PR; otherwise it would be better split into a separate PR to keep review and rollback risk manageable.

Copilot uses AI. Check for mistakes.
Comment on lines +596 to +601
// If --exclude-env names were specified, add them to the excluded set
if (config.excludeEnv && config.excludeEnv.length > 0) {
for (const name of config.excludeEnv) {
EXCLUDED_ENV_VARS.add(name);
}
}
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excludeEnv is added to EXCLUDED_ENV_VARS unconditionally, which means it also affects --env-file injection (and can have effects even when envAll is false), despite the WrapperConfig.excludeEnv docs stating it only applies to --env-all. Consider scoping excludeEnv to the envAll passthrough only (e.g., use a separate exclusion set for the env-all loop, or only add these names inside the if (config.envAll) block).

See below for a potential fix:

  // If --env-all is specified, pass through all host environment variables (except excluded ones)
  if (config.envAll) {
    // Build a local exclusion set for env-all passthrough:
    // start with the global excluded vars, then apply any --exclude-env names.
    const envAllExcludedVars = new Set(EXCLUDED_ENV_VARS);
    if (config.excludeEnv && config.excludeEnv.length > 0) {
      for (const name of config.excludeEnv) {
        envAllExcludedVars.add(name);
      }
    }

    for (const [key, value] of Object.entries(process.env)) {
      if (
        value !== undefined &&
        !envAllExcludedVars.has(key) &&
        !Object.prototype.hasOwnProperty.call(environment, key)
      ) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: --env-all passes unprotected secrets; one-shot token list incomplete

3 participants