Skip to content

Add regression test for AWF_HOST_PATH recovery across the sudo secure_path boundary - #8173

Merged
lpcox merged 4 commits into
mainfrom
copilot/awf-entrypoint-sudo-path-fix
Sep 5, 2026
Merged

Add regression test for AWF_HOST_PATH recovery across the sudo secure_path boundary#8173
lpcox merged 4 commits into
mainfrom
copilot/awf-entrypoint-sudo-path-fix

Conversation

Copilot AI commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Under docker-sudo-iptables, AWF is invoked via sudo -E awf, and sudoers' secure_path can silently overwrite the runner's $GITHUB_PATH-augmented PATH before AWF ever observes process.env.PATH. This was reported causing ruby/setup-ruby-selected versions to be shadowed by /usr/bin/ruby inside the agent container.

Investigation showed the fix already exists on main: readGitHubPathEntries() reads $GITHUB_PATH straight from disk (unaffected by secure_path), and recoverHostPaths() merges those entries into AWF_HOST_PATH ahead of the (possibly stripped) PATH, recovering toolchain vars like GOROOT/JAVA_HOME from $GITHUB_ENV as well. What was missing was a regression test covering this composed behavior end-to-end — recoverHostPaths() was fully mocked in the existing environment-builder tests, leaving only its lower-level primitives unit-tested in isolation.

Changes

  • New test file src/services/agent-environment/host-path-recovery.test.ts exercising recoverHostPaths() directly against a simulated sudo boundary:
    • process.env.PATH set to a secure_path-style value (/usr/local/sbin:...:/bin) with a real $GITHUB_PATH file containing a hosted-toolcache Ruby bin dir — asserts the toolcache path is prepended ahead of /usr/bin in AWF_HOST_PATH.
    • Simulated sudo context (getuid() === 0 + SUDO_USER) recovering GOROOT from $GITHUB_ENV when absent from process.env.
    • Confirms $GITHUB_ENV recovery is skipped outside of a sudo context.
    • Confirms AWF_HOST_PATH falls back to the stripped PATH unchanged when $GITHUB_PATH is unset.

No production code changes were required — this closes the test coverage gap called out in the issue's proposed solution and guards against regressions in this path-recovery logic going forward.

Copilot AI changed the title [WIP] Fix docker-sudo-iptables losing setup-ruby PATH in AWF Add regression test for AWF_HOST_PATH recovery across the sudo secure_path boundary Sep 5, 2026
Copilot AI requested a review from lpcox September 5, 2026 15:46
@lpcox
lpcox marked this pull request as ready for review September 5, 2026 16:43
Copilot AI balanced review requested due to automatic review settings September 5, 2026 16:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The test does not exercise the real sudo entrypoint boundary claimed by the regression.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds regression tests for host-path and toolchain-variable recovery under simulated sudo environment stripping.

Changes:

  • Tests $GITHUB_PATH precedence over secure_path.
  • Covers $GITHUB_ENV recovery and fallback behavior.
  • Does not yet test the actual sudo -E awf boundary.
File summaries
File Description
src/services/agent-environment/host-path-recovery.test.ts Adds simulated recovery tests; integration coverage through sudo -E with controlled secure_path is still required.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +59 to +62
process.env.PATH = SECURE_PATH;

const environment: Record<string, string> = {};
recoverHostPaths(environment);
@lpcox

lpcox commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

@copilot rebase onto main and address review feedback

Copilot AI added 2 commits September 5, 2026 17:02
…t-sudo-path-fix

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

Copilot AI commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

@copilot rebase onto main and address review feedback

Merged latest main into the branch (3c58623) rather than rebasing — a rebase would need a force push, which I can't do; end state is the same.

Review feedback addressed in e1e58e6: added tests/integration/sudo-secure-path.test.ts, which launches the built CLI through sudo -E env PATH=<secure_path> GITHUB_PATH=<file> node dist/cli.js --legacy-security ... and asserts on the PATH observed inside the agent container (a stub binary from the $GITHUB_PATH dir executes, and that dir precedes /usr/bin), plus a control case with $GITHUB_PATH unset. Registered it in the container & ops group of test-integration-suite.yml and documented it in tests/README.md.

Verified locally: both tests pass, and the first one fails (exit 127, stub unresolvable) when mergeGitHubPathEntries() is stubbed out of the built CLI.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 93.99% 94.00% 📈 +0.01%
Statements 92.62% 92.63% ➡️ +0.01%
Functions 93.33% 93.33% ➡️ +0.00%
Branches 86.38% 86.40% 📈 +0.02%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)

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

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

🔮 The oracle has spoken through Smoke Codex

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

Generated by Build Test Suite for #8173

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude failed

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • api.anthropic.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.anthropic.com"

See Network Configuration for more information.

Generated by Smoke Claude for #8173

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • example.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"

See Network Configuration for more information.

🛡️ Egress verdict from Smoke Copilot Network Isolation

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

🔌 Service connectivity validated by Smoke Services

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@lpcox
lpcox deployed to aoai-model September 5, 2026 17:40 — with GitHub Actions Active
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

Tested by Smoke Chroot

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

PR #8173 follows the contribution guidelines: it adds regression tests for the new behavior, updates test documentation, keeps new files in the correct src/ and tests/ locations, and the PR description clearly explains the change and links the related issue. No contribution-guideline issues found.

Generated by Contribution Check for #8173

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot Engine

Overall: PASS

cc @lpcox

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) ✅ PASS

  • ✅ MCP connectivity verified
  • ✅ GitHub.com HTTP 200 OK
  • ✅ File write/read confirmed
  • ✅ BYOK inference working (direct BYOK mode via api-proxy → api.githubcopilot.com)

Running in direct BYOK mode with COPILOT_PROVIDER_API_KEY from sidecar. All systems nominal.

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions github-actions Bot added smoke-copilot-byok smoke-copilot-network-isolation Copilot network-isolation egress smoke test labels Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@lpcox Network isolation egress smoke test results:

EGRESS_RESULT allow=pass deny=pass

✅ Allowed domain (api.github.com) reachable — allowed=200
✅ Non-allowed domain (example.com) blocked — CONNECT tunnel failed 403

Overall: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • example.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"

See Network Configuration for more information.

🛡️ Egress verdict from Smoke Copilot Network Isolation
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Services Connectivity

  • Redis PING: ❌ (name resolution failure)
  • PostgreSQL pg_isready: ❌ (no response)
  • PostgreSQL SELECT 1: ❌ (name resolution failure)

Overall: FAILhost.docker.internal could not be resolved from the sandbox (Temporary failure in name resolution).

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

✅ PR #8166: Upgrade gh-aw to latest pre-release
✅ PR #8147: fix: support GPT-6 Astra model
✅ GitHub.com connectivity
✅ File I/O
✅ BYOK inference

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)

Overall PASS
cc @Copilot @lpcox

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.14 Python 3.12.14 ✅ YES
Node.js v24.20.0 v2.98.0 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall: ❌ FAILED — Node.js version mismatch between host and chroot environment. smoke-chroot label not applied.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Sep 5, 2026

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 (ran ok) ✅ PASS
.NET json-parse N/A (ran ok) ✅ PASS
Go color ok ✅ PASS
Go env ok ✅ PASS
Go uuid ok ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx passed ✅ PASS
Node.js execa passed ✅ PASS
Node.js p-limit passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — PASS

Notes: All repositories cloned successfully. Java builds required setting -Dmaven.repo.local to a writable path (/tmp/gh-aw/agent/m2repo) because ~/.m2/repository was not creatable in this sandbox (pre-existing ~/.m2/settings.xml owned by root); this is an environment quirk unrelated to the firewall/proxy config and did not affect build/test correctness.

Generated by Build Test Suite for #8173 · copilot · auto · 53.4 AIC · ⊞ 12K ·
Add label ready-for-aw to run again

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📡 OTEL Tracing Smoke Test Results

  • Scenario 1 (Module Loading): otel.js loaded successfully, isEnabled()true. Exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled, plus internal helpers.
  • Scenario 2 (Test Suite): 3 suites / 68 tests passed (otel.test.js, otel-fanout.test.js, otel-workload-identity.test.js).
  • Scenario 3 (Env Var Forwarding): src/services/agent-environment/env-passthrough.ts forwards GITHUB_AW_OTEL_TRACE_ID and GITHUB_AW_OTEL_PARENT_SPAN_ID; src/services/api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, plus the trace/parent-span IDs.
  • Scenario 4 (Token Tracker Integration): onUsage callback present in token-tracker-http.js as the OTEL hook point.
  • Scenario 5 (OTEL Diagnostics): Spans were exported during this run — /tmp/gh-aw/otel.jsonl (workflow-level trace) contains a gh-aw.agent.setup span with proper resource attributes. No api-proxy-side otel.jsonl was produced in /tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs/ this run (only token-usage.jsonl/token-tracker-audit.jsonl), consistent with no LLM API calls being proxied through api-proxy during this smoke test — expected, not a regression.

Overall: All 5 scenarios pass.

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@lpcox
lpcox deployed to aoai-model September 5, 2026 17:50 — with GitHub Actions Active
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Recent PRs:

  • Upgrade gh-aw to latest pre-release
  • fix: support GPT-6 Astra model

MCP Connectivity: ❌
GitHub.com Connectivity: ✅
File Write/Read Test: ✅
BYOK Inference: ✅

Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)

Overall: FAIL

cc @lpcox

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)
Add label ready-for-aw to run again

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.

[awf] entrypoint/sudo-path: docker-sudo-iptables loses setup-ruby PATH before reaching AWF

3 participants