Skip to content

Repair Squid log ownership in-container before reading logs and teardown - #8251

Merged
lpcox merged 3 commits into
mainfrom
copilot/fix-squid-log-permissions
Sep 7, 2026
Merged

Repair Squid log ownership in-container before reading logs and teardown#8251
lpcox merged 3 commits into
mainfrom
copilot/fix-squid-log-permissions

Conversation

Copilot AI commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Squid writes its logs as UID 13, but AWF only repaired permissions inside the container at shutdown. Post-run diagnostics that read access.log therefore failed with EACCES, and host-side chmod during artifact preservation failed with Operation not permitted — masking the fact that the logs had actually been preserved:

[DEBUG] Could not check Squid logs: Error: EACCES: permission denied, open '/tmp/awf-.../squid-logs/access.log'
[DEBUG] Could not preserve squid logs: Error: Command failed with exit code 1: chmod -R a+rX /tmp/squid-logs-...

Changes

  • src/container-stop.tsfixSquidLogPermissionsBeforeShutdown() is now the exported, reusable fixSquidLogPermissions(). It also chowns to the runner UID/GID (passed via docker exec -e, mirroring fixArtifactPermissionsForRootless()), not just chmod:

    chown -R "$TUID:$TGID" /var/log/squid 2>/dev/null; chmod -R a+rX /var/log/squid

    Ownership transfer is what makes the later host-side chmod viable; chmod alone left files owned by UID 13.

  • src/container-lifecycle.tsrunAgentCommand() invokes the repair before checkSquidLogs(), while Squid is still running, so blocked-domain diagnostics can read access.log. The call is best-effort and non-throwing, so a failed repair cannot alter the agent exit code.

  • src/artifact-preservation.ts — the post-rename chmod for preserved Squid logs moved out of the rename's try block. Preservation is now reported accurately, and a denied chmod is classified through the existing isBenignArtifactPermissionError() path and logged at debug.

  • Docs/comments — layer 3 of the squid-log permission defense in docs/logging_quickref.md and src/log-directory-setup.ts updated to reflect the chown+chmod repair and its two call sites.

Tests

Updated the existing container-stop suites for the new command shape, plus new cases: the repair runs before access.log is read, the agent exit code survives a failed repair, and Squid logs are still reported as preserved when the host-side chmod is denied.

Copilot AI changed the title [WIP] Fix Squid log permissions for integration-test diagnostics Repair Squid log ownership in-container before reading logs and teardown Sep 7, 2026
Copilot AI requested a review from lpcox September 7, 2026 14:53
@lpcox
lpcox marked this pull request as ready for review September 7, 2026 14:57
Copilot AI balanced review requested due to automatic review settings September 7, 2026 14:57

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 currently prove that permission repair occurs before access.log is read.

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

Pull request overview

Repairs Squid log ownership and permissions before diagnostics and teardown, improving log access and artifact preservation.

Changes:

  • Adds reusable in-container chown/chmod repair.
  • Runs repair before log inspection and shutdown.
  • Makes post-preservation chmod best-effort.
  • Updates related tests and documentation.
File summaries
File Description
src/run-agent-command.test.ts Tests lifecycle repair behavior; ordering assertion must verify repair precedes log reads.
src/log-directory-setup.ts Updates permission-layer comments.
src/container-stop.ts Implements reusable permission repair.
src/container-stop.test.ts Updates shutdown repair tests.
src/container-stop-coverage.test.ts Updates branch coverage expectations.
src/container-lifecycle.ts Repairs logs before inspection.
src/artifact-preservation.ts Makes post-rename permission repair best-effort.
src/artifact-preservation-errors.test.ts Tests preservation despite denied chmod.
docs/logging_quickref.md Documents both permission-repair points.
Review details
  • Files reviewed: 9/9 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 thread src/run-agent-command.test.ts Outdated
Comment on lines +385 to +397
expect(mockExecaFn).toHaveBeenCalledWith(
'docker',
expect.arrayContaining([
'exec',
'--user',
'root',
SQUID_CONTAINER_NAME,
'sh',
'-c',
'chown -R "$TUID:$TGID" /var/log/squid 2>/dev/null; chmod -R a+rX /var/log/squid',
]),
expect.objectContaining({ reject: false }),
);
@lpcox

lpcox commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Addressed in e4478f7: the "repairs squid log permissions...before reading access.log" test now makes access.log genuinely unreadable (chmod 000) until the mocked docker exec repair runs, so it fails if the repair is moved after the read.

@github-actions

github-actions Bot commented Sep 7, 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 7, 2026

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation build failed for this PR. View logs.

Built from commit 7078f70

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

Generated by Build Test Suite for #8251

@github-actions

github-actions Bot commented Sep 7, 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 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini reports failed. Facets need polishing...

💎 Faceted by Smoke Gemini

@github-actions

github-actions Bot commented Sep 7, 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 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Contribution Check failed. Please review the logs for details.

Generated by Contribution Check for #8251

@github-actions

github-actions Bot commented Sep 7, 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 7, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

🔌 Service connectivity validated by Smoke Services

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

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

📡 OTel tracing validated by Smoke OTel Tracing

@lpcox
lpcox deployed to aoai-model September 7, 2026 15:26 — with GitHub Actions Active
@github-actions

github-actions Bot commented Sep 7, 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 7, 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 #8251

@github-actions github-actions Bot added the smoke-copilot-network-isolation Copilot network-isolation egress smoke test label Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

EGRESS_RESULT allow=pass deny=pass

✅ Allowed domain (api.github.com): reachable (HTTP 200)
✅ Blocked domain (example.com): blocked (CONNECT tunnel 403)

Overall: PASS

cc @Copilot

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 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test Results@lpcox

Overall: PASS

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

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test Results: GitHub Actions Services Connectivity

  • Redis: ❌ Could not connect to Redis at host.docker.internal:6379: Temporary failure in name resolution
  • PostgreSQL pg_isready: ❌ host.docker.internal:5432 - no response
  • PostgreSQL SELECT 1: ❌ could not translate host name "host.docker.internal" to address: Temporary failure in name resolution

Overall: FAIL — DNS resolution for host.docker.internal failed inside the AWF sandbox.

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

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@lpcox @Copilot

🔑 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 7, 2026

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 93.97% 93.95% 📉 -0.02%
Statements 92.62% 92.59% 📉 -0.03%
Functions 93.25% 93.20% 📉 -0.05%
Branches 86.45% 86.35% 📉 -0.10%
📁 Per-file Coverage Changes (5 files)
File Lines (Before → After) Statements (Before → After)
src/enclave/dynamic-registry.ts 95.7% → 92.6% (-3.18%) 94.3% → 90.9% (-3.36%)
src/artifact-preservation.ts 95.2% → 94.6% (-0.59%) 95.2% → 94.7% (-0.58%)
src/container-lifecycle.ts 96.7% → 96.7% (+0.02%) 96.3% → 96.3% (+0.02%)
src/enclave/manager.ts 87.8% → 87.8% (+0.08%) 86.2% → 86.3% (+0.09%)
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 7, 2026

Copy link
Copy Markdown
Contributor

Chroot Runtime Version Comparison

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

Result: Not all tests passed — Node.js version differs between host and chroot environment, so the smoke-chroot label was not applied.

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

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: API Proxy OpenTelemetry Tracing — Results

Scenario Result
1. Module Loading otel.js loads successfully; exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled, plus internal helpers (_ProxyAwareOtlpExporter, _FileSpanExporter, _FanOutSpanExporter, etc.)
2. Test Suite otel.test.js, otel-fanout.test.js, otel-workload-identity.test.js — 3 suites, 68 tests, all passed
3. Env Var Forwarding env-passthrough.ts forwards GITHUB_AW_OTEL_TRACE_ID/GITHUB_AW_OTEL_PARENT_SPAN_ID (+ COPILOT_OTEL_FILE_EXPORTER_PATH) into the agent; api-proxy-env-config.ts's buildOtelEnv() forwards OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID, and OTEL_SERVICE_NAME into the api-proxy container
4. Token Tracker Integration token-tracker-http.js accepts an onUsage(normalizedUsage, model) callback as the OTEL hook point, invoked after usage normalization
5. OTEL Diagnostics /tmp/gh-aw/otel.jsonl present with 1 exported span (gh-aw.agent.setup), containing full resource attributes (service.name, workflow, run id, gen_ai.system, episode/hop ids) — export path confirmed functional

Overall: All 5 scenarios passed. No unexpected failures found; OTEL tracing integration in the api-proxy sidecar is working end-to-end (module → tests → env propagation → hook point → export).

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

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) Mode ✅ PASS

All smoke tests passed. BYOK credential path confirmed working.

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

@github-actions

github-actions Bot commented Sep 7, 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, output "Hello, World!") ✅ PASS
.NET json-parse N/A (ran, output correct JSON) ✅ 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 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:

  • Java required configuring ~/.m2/settings.xml with the Squid HTTP/HTTPS proxy (squid-proxy:3128) and a writable local repo path (-Dmaven.repo.local), since the default ~/.m2 directory was root-owned.
  • All other ecosystems worked out of the box through the firewall's proxy configuration (Bun, Deno, npm, cargo, go, cmake/make, dotnet all resolved dependencies and ran tests successfully through Squid egress control).

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

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Repair Squid log ownership in-container before reading logs and teardown
GitHub MCP testing: ❌
GitHub.com connectivity: ✅
File write/read test: ✅
BYOK inference test: ✅
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) authenticated via Microsoft Entra
Overall: FAIL
@Copilot @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.

Fix Squid log permissions for integration-test diagnostics

3 participants