Skip to content

Conversation

@Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Feb 12, 2026

Summary

Implements review recommendations from the PR #720 code review:

  • Remove legacy one-shot-token.c: The Rust port (src/lib.rs) is complete and the C file was only kept "for reference". Removes the file and updates README.md to reflect the current file list.
  • Add -v to fallback docker rm -f: The stopContainers fallback path (when docker-compose.yml is missing) used docker rm -f without -v, which could leave orphaned volumes. Now matches the behavior of docker compose down -v in the normal path.
  • Fix pre-existing test failures: Updates test expectations to match the PR's stdio: ['ignore', 'ignore', 'inherit'] pattern, creates docker-compose.yml in stopContainers test so the compose-down path is properly exercised, and adds a new test for the fallback (missing compose file) path.

Test plan

  • All 747 unit tests pass (npm test)
  • ESLint passes with 0 errors (263 pre-existing warnings)
  • TypeScript build succeeds (npm run build)
  • CI passes

🤖 Generated with Claude Code

- Remove one-shot-token.c (legacy C impl kept "for reference" after Rust
  port). The Rust implementation in src/lib.rs is the sole implementation.
- Add -v flag to fallback `docker rm -f` in stopContainers to clean
  orphaned volumes, matching the `docker compose down -v` normal path.
- Fix pre-existing test failures: update stdio expectations to match the
  PR's ['ignore', 'ignore', 'inherit'] pattern, create docker-compose.yml
  in stopContainers test so the normal path is exercised, and add a new
  test for the fallback (missing compose file) path.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings February 12, 2026 19:55
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

💫 TO BE CONTINUED... Smoke Claude failed! Our hero faces unexpected challenges...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions github-actions bot mentioned this pull request Feb 12, 2026
Copy link
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

This PR implements code review recommendations from PR #720 (one-shot-token Rust port), addressing three main concerns: removing legacy code, fixing volume cleanup inconsistency, and correcting test expectations.

Changes:

  • Removes legacy C implementation of one-shot-token library (replaced by Rust in PR #720)
  • Adds -v flag to fallback docker rm -f command to match docker compose down -v volume cleanup behavior
  • Updates test expectations to match the stdio: ['ignore', 'ignore', 'inherit'] pattern and adds docker-compose.yml creation in tests

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/docker-manager.ts Adds -v flag to docker rm -f in stopContainers fallback path
src/docker-manager.test.ts Updates test expectations for stdio configuration and adds compose file creation for proper path testing
containers/agent/one-shot-token/one-shot-token.c Removes 362-line legacy C implementation (replaced by Rust)
containers/agent/one-shot-token/README.md Removes reference to deleted C file from documentation

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

Comment on lines +1798 to 1807
// Mock docker ps returning empty (no containers found)
mockExecaFn.mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 } as any);
mockExecaFn.mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 } as any);

await stopContainers(testDir, false);

expect(mockExecaFn).toHaveBeenCalledWith(
'docker',
['ps', '-aq', '-f', 'name=^awf-agent$'],
);
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The new test for the fallback path doesn't actually verify that the -v flag is included in the docker rm -f -v command. The test currently mocks docker ps to return empty stdout (no containers found), which means the docker rm command is never called. To properly test the fix from this PR, the test should mock docker ps to return a container ID so that the docker rm -f -v command is executed and can be verified.

Suggested change
// Mock docker ps returning empty (no containers found)
mockExecaFn.mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 } as any);
mockExecaFn.mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 } as any);
await stopContainers(testDir, false);
expect(mockExecaFn).toHaveBeenCalledWith(
'docker',
['ps', '-aq', '-f', 'name=^awf-agent$'],
);
// Mock docker ps returning a container ID so docker rm is executed
mockExecaFn.mockResolvedValueOnce({ stdout: '12345\n', stderr: '', exitCode: 0 } as any);
// Mock docker rm -f -v succeeding
mockExecaFn.mockResolvedValueOnce({ stdout: '', stderr: '', exitCode: 0 } as any);
await stopContainers(testDir, false);
expect(mockExecaFn).toHaveBeenNthCalledWith(
1,
'docker',
['ps', '-aq', '-f', 'name=^awf-agent$'],
);
expect(mockExecaFn).toHaveBeenNthCalledWith(
2,
'docker',
['rm', '-f', '-v', '12345'],
expect.anything(),
);

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

Go Build Test Results

Project Download Tests Status
color 1/1 PASS
env 1/1 PASS
uuid 1/1 PASS

Overall: PASS

All Go projects successfully downloaded dependencies and passed tests.

AI generated by Build Test Go

@github-actions
Copy link
Contributor

Smoke Test Results

Last 2 Merged PRs:

Test Results:
✅ GitHub MCP - Retrieved PR data successfully
✅ Playwright - Page title verified: "GitHub · Change is constant. GitHub keeps you ahead. · GitHub"
✅ File Write - Created test file at /tmp/gh-aw/agent/smoke-test-copilot-21962056524.txt
✅ Bash Tool - File verified successfully

Overall Status: PASS

cc: @Mossaka

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

Build Test: Rust - FAILED ❌

Error: Rust toolchain not available in test environment.

Project Build Tests Status
fd ⚠️ N/A N/A ERROR
zoxide ⚠️ N/A N/A ERROR

Overall: FAILED

Error Details

The cargo command was not found in the container environment. The Rust toolchain (rustup/cargo/rustc) must be installed before running Rust build tests.

Required Action: Add Rust installation step to the workflow before invoking this agent (e.g., using dtolnay/rust-toolchain action or installing via rustup).

AI generated by Build Test Rust

@github-actions
Copy link
Contributor

Node.js Build Test Results

Project Install Tests Status
clsx PASS PASS
execa PASS PASS
p-limit PASS PASS

Overall: PASS

All Node.js projects successfully installed dependencies and passed their test suites.

AI generated by Build Test Node.js

@github-actions
Copy link
Contributor

Bun Build Test Results

Project Install Tests Status
elysia 1/1 PASS
hono 1/1 PASS

Overall: PASS

All Bun projects built and tested successfully.

AI generated by Build Test Bun

@github-actions
Copy link
Contributor

Deno Build Test Results

Project Tests Status
oak 1/1 ✅ PASS
std 1/1 ✅ PASS

Overall: ✅ PASS

All Deno tests completed successfully.

AI generated by Build Test Deno

@github-actions
Copy link
Contributor

.NET Build Test Results

Project Restore Build Run Status
hello-world PASS
json-parse PASS

Overall: PASS

All .NET projects successfully restored, built, and ran:

  • hello-world: Output "Hello, World!"
  • json-parse: Successfully parsed JSON and output structured data

AI generated by Build Test .NET

@github-actions
Copy link
Contributor

Java Build Test Results ✅

Project Compile Tests Status
gson 1/1 PASS
caffeine 1/1 PASS

Overall: PASS

All Java projects successfully compiled and passed their tests through the AWF firewall with Maven proxy configuration.

AI generated by Build Test Java

@github-actions
Copy link
Contributor

Chroot Version Comparison Test Results

The chroot mode was tested to verify that host package manager binaries are accessible from within the container.

Runtime Host Version Chroot Version Match?
Python 3.12.12 3.12.3 ❌ NO
Node.js v24.13.0 v20.20.0 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall Status:FAILED - Not all versions match

Analysis

  • Python: Minor version mismatch (3.12.12 vs 3.12.3)
  • Node.js: Major version mismatch (v24 vs v20) - container is using older Node.js
  • Go: ✅ Versions match perfectly

The test validates that AWF's chroot mode can transparently access host binaries. Version mismatches indicate the container may not be properly accessing the host installation.

AI generated by Smoke Chroot

@github-actions
Copy link
Contributor

fix: eliminate nested bash layer in chroot command execution for Java/.NET ✅
fix: hide workDir from agent container to prevent secrets exposure ✅
fix: review recommendations for PR #720
fix: cherry-pick commit 8cf2cea to claude/create-sidecar-container-envoy ✅
Playwright GitHub title contains "GitHub" ✅
Tavily search "GitHub Agentic Workflows Firewall" ❌
File write + cat ✅
Discussion comment ✅
Build (npm ci && npm run build) ❌
Overall status: FAIL

AI generated by Smoke Codex

@Mossaka
Copy link
Collaborator Author

Mossaka commented Feb 12, 2026

Review Results

Two independent review agents analyzed PR #720 (which this PR targets). Here are the findings:


Functional Comparison: C vs Rust

All critical functionality is preserved. The Rust port is a faithful translation with improvements:

Aspect Verdict
Default token list (11 tokens) Identical
Custom tokens (AWF_ONE_SHOT_TOKENS) Identical parsing, edge cases
getenv interception Same cache-and-unset semantics
secure_getenv interception Same fallback behavior
Thread safety Improved (Mutex with poisoning recovery)
Memory management Same intentional never-free pattern
Logging format Same [one-shot-token] prefix, all to stderr

Improvements in Rust version:

  • Code deduplication via shared handle_getenv_impl()
  • Fixed thread safety inconsistency (C checked token sensitivity outside mutex in secure_getenv)
  • Explicit malloc failure check for token allocation
  • New check_task_environ_exposure() verification feature
  • Included unit tests

No functional regressions identified.


Security Stance Review

Overall: The PR reduces attack surface.

Finding Severity Notes
/proc/self/environ kernel exposure High (pre-existing) unsetenv() doesn't modify kernel's mm->env_start; documented limitation
~/.cargo hidden in non-full-access Medium tmpfs hides ~/.cargo/bin too; may break Rust workflows
check_task_environ_exposure naming Medium Checks userspace environ pointer, not /proc files
curl-to-shell Rust install in Dockerfile Medium Standard practice but no hash verification
Cargo.lock not committed Medium Non-deterministic dependency resolution
tmpfs credential hiding Info (positive) Net improvement over /dev/null approach
Selective home mounting Info (positive) $HOME no longer fully exposed
docker-compose.yml deletion Info (positive) Correctly implemented, race window negligible
docker rm -f -v fallback Info (positive) Matches docker compose down -v behavior
All unsafe code in Rust Low Necessary and correctly scoped for LD_PRELOAD

CI Status

All checks pass except "Smoke Claude" which timed out (10-minute limit for Claude API e2e test). This is a known flaky test unrelated to these changes — the one-shot-token library initialized and cached tokens correctly.

@Mossaka Mossaka merged commit 0ec5481 into lpcox/port-one-shot-token-rust Feb 12, 2026
74 of 75 checks passed
@Mossaka Mossaka deleted the review/pr720-recommendations branch February 12, 2026 20:15
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.

1 participant