Skip to content

feat: rust one-shot-token library#791

Merged
pelikhan merged 10 commits intomainfrom
claude/extract-rust-one-shot-token-lib
Feb 13, 2026
Merged

feat: rust one-shot-token library#791
pelikhan merged 10 commits intomainfrom
claude/extract-rust-one-shot-token-lib

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Feb 13, 2026

No description provided.

@Claude Claude AI changed the title [WIP] Extract rust one-shot-token library implementation feat: port one-shot-token library from C to Rust Feb 13, 2026
@Claude Claude AI requested a review from lpcox February 13, 2026 00:25
@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 82.66% 83.04% 📈 +0.38%
Statements 82.66% 83.03% 📈 +0.37%
Functions 82.74% 82.74% ➡️ +0.00%
Branches 74.92% 74.97% 📈 +0.05%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 83.9% → 85.3% (+1.43%) 83.3% → 84.8% (+1.42%)

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

@github-actions
Copy link
Contributor

✅ Deno Build Test Results

All tests passed successfully!

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

Overall: ✅ PASS

All Deno test projects compiled and ran successfully.

AI generated by Build Test Deno

@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 built and tested successfully.

AI generated by Build Test Go

@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

Smoke Test Results

Last 2 Merged PRs:

Tests:

  • ✅ GitHub MCP: Retrieved PR data successfully
  • ✅ Playwright: Navigated to github.com, title contains "GitHub"
  • ✅ File Writing: Created /tmp/gh-aw/agent/smoke-test-copilot-21969640314.txt
  • ✅ Bash Tool: File verified with cat

Overall Status: PASS

cc @Claude @Mossaka @lpcox

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

Smoke Test Results

PRs: #751, #775

✅ GitHub MCP - Retrieved PRs
✅ Playwright - Page title verified
✅ File Write - Created test file
✅ Bash Tool - Read file successfully

Status: PASS

AI generated by Smoke Claude

@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 built and ran successfully.

AI generated by Build Test .NET

@github-actions
Copy link
Contributor

C++ Build Test Results

Project CMake Build Status
fmt PASS
json PASS

Overall: PASS

All C++ projects built successfully.

AI generated by Build Test C++

@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 compiled successfully and all tests passed through the AWF firewall with Maven proxy configuration.

AI generated by Build Test Java

@github-actions
Copy link
Contributor

Smoke Test Results ✅ PASS

Last 2 merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved PR data
  • ✅ Playwright: Verified GitHub page title
  • ✅ File Write: Created test file
  • ✅ Bash: Read file back successfully

cc @lpcox

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

Smoke Test Results

Last 2 Merged PRs:

  • fix: add Rust installation step when runtime specified in workflow
  • feat: port one-shot-token from C to Rust and improve container security

Tests:

  • ✅ GitHub MCP: Successfully fetched PR data
  • ✅ Playwright: Page title verified ("GitHub · Change is constant. GitHub keeps you ahead. · GitHub")
  • ✅ File Write: Created /tmp/gh-aw/agent/smoke-test-claude-21973717768.txt
  • ✅ Bash: File content verified

Status: PASS

AI generated by Smoke Claude

@github-actions
Copy link
Contributor

C++ Build Test Results

Project CMake Build Status
fmt PASS
json PASS

Overall: PASS

All C++ projects built successfully.

AI generated by Build Test C++

@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

.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 with expected output.

AI generated by Build Test .NET

@github-actions
Copy link
Contributor

Chroot Version Comparison Test Results

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: ❌ Tests Failed

Only Go versions match between host and chroot environments. Python and Node.js versions differ, which means chroot mode is not providing transparent access to host runtimes for all tools.

AI generated by Smoke Chroot

@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 compiled and tested successfully through the AWF proxy.

AI generated by Build Test Java

@github-actions
Copy link
Contributor

Smoke test results:
Merged PRs reviewed: fix: add Rust installation step when runtime specified in workflow; fix: correct exit code success detection in test runner
safeinputs-gh pr list ✅
playwright GitHub title ✅
tavily search ❌ (tool unavailable)
file write + cat ✅
discussion comment ✅
npm ci && npm run build ✅
Overall: FAIL

AI generated by Smoke Codex

…age manager tests (#797)

* Initial plan

* fix: add explicit toolchain to rust setup in test workflow

Co-authored-by: lpcox <[email protected]>

* feat: add RUSTUP_HOME environment variable support for Rust toolchain

Co-authored-by: lpcox <[email protected]>

---------

Co-authored-by: anthropic-code-agent[bot] <[email protected]>
Co-authored-by: lpcox <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

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

@github-actions
Copy link
Contributor

C++ Build Test Results

Project CMake Build Status
fmt PASS
json PASS

Overall: PASS

All C++ projects built successfully.

AI generated by Build Test C++

@github-actions
Copy link
Contributor

Smoke Test Results - Claude Engine

Last 2 PRs:

✅ GitHub MCP - PRs retrieved
✅ Playwright - GitHub homepage loaded
✅ File Write - Test file created
✅ Bash - File verified

Status: PASS

AI generated by Smoke Claude

@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

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

Node.js Build Test Results

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

Overall: PASS

All Node.js test projects built and tested successfully.

AI generated by Build Test Node.js

@github-actions
Copy link
Contributor

Smoke Test Results for Copilot Engine

✅ GitHub MCP: #797, #794 retrieved
✅ Playwright: GitHub homepage title verified
✅ File Write: Test file created at /tmp/gh-aw/agent/smoke-test-copilot-21974237710.txt
✅ Bash Tool: File content verified

Status: PASS

cc: @lpcox

AI generated by Smoke Copilot

@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 their tests.

AI generated by Build Test Go

@github-actions
Copy link
Contributor

✅ Java Build Test Results

All Java build tests PASSED successfully!

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

Overall: PASS

Details

  • gson: Compiled successfully, 1 test passed (0 failures, 0 errors, 0 skipped)
  • caffeine: Compiled successfully, 1 test passed (0 failures, 0 errors, 0 skipped)
  • Maven proxy configuration: 172.30.0.10:3128 (awf Squid proxy)
  • All dependencies downloaded successfully through firewall

AI generated by Build Test Java

@github-actions
Copy link
Contributor

Chroot Version Comparison Test Results

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 Result: ❌ Tests Failed - Not all runtime versions match

The chroot mode successfully accessed host binaries for Go, but Python and Node.js versions differ between the host and chroot environment. This indicates that the chroot is using container-installed versions rather than host binaries for these runtimes.

AI generated by Smoke Chroot

@github-actions
Copy link
Contributor

Smoke test results
[WIP] Fix failing GitHub Actions workflow for test examples
feat(cli): enable API proxy by default
GitHub MCP merged PRs review ✅
safeinputs-gh PR list ✅
Playwright title ✅
Tavily search ❌ (tool missing)
File write+cat ✅; Discussion comment ✅
Build npm ci && npm run build ✅
Overall: FAIL

AI generated by Smoke Codex

@pelikhan pelikhan marked this pull request as ready for review February 13, 2026 04:38
Copilot AI review requested due to automatic review settings February 13, 2026 04:38
@pelikhan pelikhan merged commit 9ec87c6 into main Feb 13, 2026
92 of 93 checks passed
@pelikhan pelikhan deleted the claude/extract-rust-one-shot-token-lib branch February 13, 2026 04:38
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 migrates the one-shot-token LD_PRELOAD library from C to Rust while also adding RUSTUP_HOME environment variable support for Rust toolchain discovery. The one-shot-token library is a security component that intercepts getenv() calls to sensitive environment variables, caching their values in memory and clearing them from the process environment to prevent token exposure via /proc/self/environ.

Changes:

  • Rewrites one-shot-token library in Rust with equivalent functionality to the C version
  • Adds RUSTUP_HOME environment variable passthrough to support Rust toolchain in chroot mode
  • Updates Docker build to use multi-stage build with official Rust image for supply chain security
  • Fixes exit code handling in test runner to properly normalize undefined exit codes

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/fixtures/awf-runner.ts Fixes exit code normalization by using ?? 0 before deriving success field
src/docker-manager.ts Adds RUSTUP_HOME passthrough to container environment for Rust toolchain support
containers/agent/one-shot-token/src/lib.rs New Rust implementation of one-shot-token library with getenv/secure_getenv interception
containers/agent/one-shot-token/build.sh Updates build script to use Cargo instead of GCC
containers/agent/one-shot-token/README.md Updates documentation to reflect Rust implementation and adds environment verification details
containers/agent/one-shot-token/Cargo.toml Adds Rust package configuration with libc and once_cell dependencies
containers/agent/one-shot-token/.gitignore Updates to ignore Rust build artifacts (target/, Cargo.lock)
containers/agent/entrypoint.sh Adds RUSTUP_HOME support and fallback Cargo detection for Rust in chroot mode
containers/agent/Dockerfile Implements multi-stage build using official rust:1.77-slim image for security
.github/workflows/test-chroot.yml Adds RUSTUP_HOME capture and preservation for Rust toolchain tests
.github/workflows/build-test-rust.md Adds crates.io to allowed network domains
.github/workflows/build-test-rust.lock.yml Auto-generated workflow updates with version bumps and domain additions

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

Comment on lines +13 to +14
libc = "0.2"
once_cell = "1.19"
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The Cargo.toml specifies libc = "0.2" and once_cell = "1.19" without patch versions. While this is common practice for Rust libraries, consider pinning to more specific versions (e.g., "0.2.150" and "1.19.0") for reproducible builds, especially since this is a security-critical component that intercepts environment variable access. This would make builds more deterministic and easier to audit for security vulnerabilities.

Suggested change
libc = "0.2"
once_cell = "1.19"
libc = "0.2.150"
once_cell = "1.19.0"

Copilot uses AI. Check for mistakes.
@@ -157,6 +157,8 @@ jobs:

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The dtolnay/rust-toolchain action reference is missing a version pin or SHA. While the with: toolchain: stable configuration is present, the action itself should be pinned to a specific commit SHA for security and reproducibility, consistent with the convention used for other actions in this workflow (e.g., actions/checkout, actions/setup-node, etc. are all pinned to SHAs).

Suggested change
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@4f6abf093ee4c743c3c1e811ce0cfe4631d14d1f # stable

Copilot uses AI. Check for mistakes.

# Rust build artifacts
target/
Cargo.lock
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

Cargo.lock is excluded from version control for this library. While this is appropriate for Rust library crates (cdylib), the project uses the library in a Docker multi-stage build. For reproducible builds and supply chain security, consider committing Cargo.lock. This ensures the exact same dependency versions are used across all builds and makes it easier to track dependency updates for security vulnerabilities.

Suggested change
Cargo.lock

Copilot uses AI. Check for mistakes.
Comment on lines +310 to +315
// Allocate memory that will never be freed (must persist for caller's use)
let cached = libc::malloc(value_bytes.len()) as *mut c_char;
if cached.is_null() {
eprintln!("[one-shot-token] ERROR: Failed to allocate memory for token value");
std::process::abort();
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

Memory allocated via libc::malloc at line 311 is never freed (by design, as noted in the comment). However, this could lead to memory accumulation if the same token is accessed multiple times before caching. Consider verifying that the cache check at line 291 prevents duplicate allocations. The current implementation appears correct since the cache check happens before allocation, but it would be helpful to add a debug assertion or comment confirming this invariant.

Copilot uses AI. Check for mistakes.
# Fallback: detect Cargo from default location if CARGO_HOME not provided
# This ensures Rust binaries work even when CARGO_HOME env var is not set
echo "# Add Cargo bin for Rust if it exists (fallback when CARGO_HOME not provided)" >> "/host${SCRIPT_FILE}"
echo "[ -d \"\$HOME/.cargo/bin\" ] && export PATH=\"\$HOME/.cargo/bin:\$PATH\"" >> "/host${SCRIPT_FILE}"
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The fallback logic adds $HOME/.cargo/bin to PATH when CARGO_HOME is not provided. However, this fallback doesn't set RUSTUP_HOME, which means rustc and cargo may not find the Rust toolchain even if the binaries are in PATH. Consider adding a similar fallback for RUSTUP_HOME (e.g., [ -d "$HOME/.rustup" ] && export RUSTUP_HOME="$HOME/.rustup") to ensure Rust tools work correctly in the fallback scenario.

Suggested change
echo "[ -d \"\$HOME/.cargo/bin\" ] && export PATH=\"\$HOME/.cargo/bin:\$PATH\"" >> "/host${SCRIPT_FILE}"
echo "[ -d \"\$HOME/.cargo/bin\" ] && export PATH=\"\$HOME/.cargo/bin:\$PATH\"" >> "/host${SCRIPT_FILE}"
echo "[ -d \"\$HOME/.rustup\" ] && export RUSTUP_HOME=\"\$HOME/.rustup\"" >> "/host${SCRIPT_FILE}"

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.

3 participants