[Test Coverage] Add security-critical test coverage: excluded-vars and shell-utils#3928
Conversation
- excluded-vars.test.ts: Tests for buildExclusionSet() which controls which env vars are passed to the agent container. Covers: - Base exclusions always present (PATH, sudo, GH Actions tokens, proxy vars) - API key exclusion when enableApiProxy=true (OPENAI, ANTHROPIC, COPILOT, GEMINI) - API keys NOT excluded when enableApiProxy=false - GITHUB_TOKEN/GH_TOKEN excluded when DIFC proxy is configured - Custom excludeEnv entries - shell-utils.test.ts: Tests for shell argument escaping (injection prevention). Covers: - Safe characters pass through unquoted - Shell metacharacters (spaces, $, ;, |, &, >, <) get single-quoted - Single-quote injection prevention via the '\'' pattern - Complex injection strings with mixed metacharacters - joinShellArgs edge cases Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Adds Jest unit tests for two security-sensitive pure utilities: environment-variable exclusion logic used when building the agent container environment, and shell-argument escaping used to prevent shell injection.
Changes:
- Add unit tests for
buildExclusionSetcovering baseline exclusions, API-proxy key isolation, DIFC token isolation, andexcludeEnvhandling. - Add unit tests for
escapeShellArg/joinShellArgscovering safe pass-through, quoting of metacharacters, and correct escaping of embedded single quotes.
Show a summary per file
| File | Description |
|---|---|
| src/services/agent-environment/excluded-vars.test.ts | New test suite validating env-var exclusion behavior across security-relevant config combinations. |
| src/parsers/shell-utils.test.ts | New test suite validating shell argument escaping and joining for injection prevention scenarios. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Smoke Test: Claude Engine
Result: PASS
|
🧪 Smoke Test Results
Overall: PASS — authored by
|
Smoke Test: Copilot BYOK — PASS
Running in BYOK offline mode ( PR by Overall: PASS (core BYOK path verified ✅)
|
Smoke Test: Gemini Engine Validation\n\n- GitHub MCP Testing: ❌ (Tools missing)\n- GitHub.com Connectivity: ❌ (SSL error 35)\n- File Writing Testing: ✅\n- Bash Tool Testing: ✅\n\nOverall status: FAILWarning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
Chroot Version Comparison — Smoke Test Results
Result: ❌ Not all runtimes match — Python and Node.js versions differ between host and chroot.
|
Smoke Test Results
Overall: FAIL —
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
|
Smoke test results
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Summary
Adds test coverage for two security-critical, previously untested files:
Files Added
src/services/agent-environment/excluded-vars.test.tssrc/parsers/shell-utils.test.tsbuildExclusionSet— API Key Isolation (excluded-vars.ts)This function controls exactly which environment variables are blocked from reaching the agent container. A bug here could leak API keys to the agent when
--enable-api-proxyis active.Coverage added:
PATH,SUDO_*,ACTIONS_RUNTIME_TOKEN,ACTIONS_RESULTS_URL,AWF_*, all proxy varsenableApiProxy=true:OPENAI_API_KEY,OPENAI_KEY,CODEX_API_KEY,ANTHROPIC_API_KEY,CLAUDE_API_KEY,COPILOT_GITHUB_TOKEN,COPILOT_API_KEY,COPILOT_PROVIDER_API_KEY,GEMINI_API_KEY,GOOGLE_GEMINI_BASE_URL,GEMINI_API_BASE_URLenableApiProxy=false(passthrough works correctly)GITHUB_TOKEN/GH_TOKENexcluded when DIFC proxy (difcProxyHost) is configuredexcludeEnventries respectedundefinedexcludeEnvapiProxy + difc + excludeEnvscenarioescapeShellArg/joinShellArgs— Shell Injection Prevention (shell-utils.ts)These functions escape arguments before they appear in shell commands. Incorrect escaping could allow shell injection attacks.
Coverage added:
-,.,/,=,:) pass through unquoted$,;,&&,|,>,<,!, newlines) get single-quoted'\''shell escape pattern'+ metacharacters neutralized''joinShellArgsempty array, single arg, mixed args$SECRETprevented from expandingNo Bugs Found
No bugs were discovered during test authoring. The exclusion set logic and shell escaping implementations are correct.
Before/After Coverage
These two files had 0% coverage before this PR. Both are pure functions with no external dependencies, so tests run in-memory with no mocking required.