Skip to content

test: expand credential hiding tests to all 14 protected paths#1163

Open
Mossaka wants to merge 1 commit intomainfrom
fix/052-credential-hiding-tests
Open

test: expand credential hiding tests to all 14 protected paths#1163
Mossaka wants to merge 1 commit intomainfrom
fix/052-credential-hiding-tests

Conversation

@Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Mar 5, 2026

Summary

  • Adds integration tests for the 11 previously untested credential file paths (out of 14 total)
  • Tests cover SSH keys (id_rsa, id_ed25519, id_ecdsa, id_dsa), AWS credentials/config, Kube config, Azure credentials, GCloud credentials.db, Cargo credentials, and Composer auth.json
  • Verifies each path returns 0 bytes at both direct home path and /host chroot path

Test plan

  • npm run build passes
  • npm test passes (831 tests)
  • npm run lint passes (0 errors)
  • CI integration tests verify all 14 paths are hidden

Fixes #761

🤖 Generated with Claude Code

Add integration tests for the 11 previously untested credential paths:
SSH keys (id_rsa, id_ed25519, id_ecdsa, id_dsa), AWS credentials/config,
Kube config, Azure credentials, GCloud credentials.db, Cargo credentials,
and Composer auth.json.

Tests verify each path returns 0 bytes (hidden via /dev/null mount) at
both the direct home path and /host chroot path.

Fixes #761

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 5, 2026 20:02
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 82.27% 82.41% 📈 +0.14%
Statements 82.17% 82.30% 📈 +0.13%
Functions 82.60% 82.60% ➡️ +0.00%
Branches 74.12% 74.21% 📈 +0.09%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 83.0% → 83.6% (+0.55%) 82.4% → 82.9% (+0.53%)

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

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

Expands the integration test suite to verify credential-hiding behavior across all 14 protected credential paths (home and /host chroot), ensuring the files are effectively empty when mounted from /dev/null.

Changes:

  • Updates the existing “Test 4” to more explicitly target the original 3 credential paths and adjusts its shell check.
  • Adds a new test group that covers the 11 previously untested credential file paths.
  • Verifies 0-byte size for direct home paths and /host paths, plus a cat-content check.

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

Comment on lines +250 to +251
const homeDir = os.homedir();
const paths = untestedPaths.map(p => `${homeDir}/${p.path}`).join(' ');
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

Building a shell command by interpolating paths directly into sh -c '...' is unsafe and can break when homeDir contains spaces or shell-special characters (and is also an injection risk since this runs with sudo). Prefer passing file paths as positional args to sh -c and iterating over "$@" (or otherwise robustly quoting/escaping each path) so the loop receives the exact paths regardless of characters.

Suggested change
const homeDir = os.homedir();
const paths = untestedPaths.map(p => `${homeDir}/${p.path}`).join(' ');
const paths = untestedPaths.map(p => `"$HOME/${p.path}"`).join(' ');

Copilot uses AI. Check for mistakes.
// Check all credential files in a single container run for efficiency.
// wc -c reports byte count; /dev/null-mounted files should be 0 bytes.
const result = await runner.runWithSudo(
`sh -c 'for f in ${paths}; do wc -c "$f" 2>/dev/null; done' 2>&1 | grep -v "^\\["`,
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

Building a shell command by interpolating paths directly into sh -c '...' is unsafe and can break when homeDir contains spaces or shell-special characters (and is also an injection risk since this runs with sudo). Prefer passing file paths as positional args to sh -c and iterating over "$@" (or otherwise robustly quoting/escaping each path) so the loop receives the exact paths regardless of characters.

Copilot uses AI. Check for mistakes.

// cat all files and concatenate output - should be empty
const result = await runner.runWithSudo(
`sh -c 'for f in ${paths}; do cat "$f" 2>/dev/null; done' 2>&1 | grep -v "^\\["`,
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

This test can produce a false pass if one or more files don’t exist or aren’t mounted: cat errors are suppressed (2>/dev/null), so the combined stdout can be empty even when paths are missing. To make the assertion meaningful, ensure each file is actually present/checked (e.g., fail the loop if a path is missing, or emit/validate per-file markers), or remove this test and rely on the wc -c tests that already validate counts.

Suggested change
`sh -c 'for f in ${paths}; do cat "$f" 2>/dev/null; done' 2>&1 | grep -v "^\\["`,
`sh -c 'for f in ${paths}; do cat "$f"; done' 2>&1 | grep -v "^\\["`,

Copilot uses AI. Check for mistakes.
const lines = result.stdout.split('\n').filter(l => l.match(/^\s*\d+/));
// Each file should be 0 bytes (hidden via /dev/null)
lines.forEach(line => {
const size = parseInt(line.trim().split(/\s+/)[0]);
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

parseInt should be called with an explicit radix to avoid edge-case parsing issues. Use parseInt(value, 10) here (and in the similar parsing block in the /host test) to make the intent unambiguous.

Copilot uses AI. Check for mistakes.
Comment on lines +102 to +107
test('Test 4: Original 3 credential files are mounted from /dev/null', async () => {
const homeDir = os.homedir();

// Check multiple credential files in one command
// Check the originally-tested credential files in one command
const result = await runner.runWithSudo(
`sh -c 'for f in ${homeDir}/.docker/config.json ${homeDir}/.npmrc ${homeDir}/.config/gh/hosts.yml; do if [ -f "$f" ]; then wc -c "$f"; fi; done' 2>&1 | grep -v "^\\["`,
`sh -c 'for f in ${homeDir}/.docker/config.json ${homeDir}/.npmrc ${homeDir}/.config/gh/hosts.yml; do wc -c "$f" 2>/dev/null; done' 2>&1 | grep -v "^\\["`,
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

With 2>/dev/null added and no follow-up assertion that all three files produced output, this test can now silently skip missing/unmounted files (no wc output) and potentially still pass depending on downstream expectations. To preserve the “mounted from /dev/null” guarantee, parse the wc output and assert you got exactly 3 size lines and that each is 0 (or make the shell loop fail if any file is missing).

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

github-actions bot commented Mar 5, 2026

🧪 Build Test: Bun

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

Overall: ✅ PASS

Bun v1.3.10 — all tests passed

Generated by Build Test Bun for issue #1163

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Build Test: Node.js Results ✅

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

Overall: PASS

Generated by Build Test Node.js for issue #1163

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Go Build Test Results

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

Overall: PASS

Generated by Build Test Go for issue #1163

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

C++ Build Test Results

Project CMake Build Status
fmt PASS
json PASS

Overall: PASS

Generated by Build Test C++ for issue #1163

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Smoke test results for @Mossaka's PR:

✅ GitHub MCP: #1159 fix(security): eliminate TOCTOU race conditions in ssl-bump.ts, #1158 fix(security): stop logging partial token values
✅ Playwright: github.com title contains "GitHub"
✅ File write: /tmp/gh-aw/agent/smoke-test-copilot-22734391352.txt created
✅ Bash: file verified via cat

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot for issue #1163

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Build Test: Deno ✅

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

Overall: PASS

Generated by Build Test Deno for issue #1163

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Java Build Test Results ✅

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

Overall: PASS

Generated by Build Test Java for issue #1163

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Test results:

  1. GitHub MCP merged PRs: ✅ fix(security): eliminate TOCTOU race conditions in ssl-bump.ts; fix(security): stop logging partial token values
  2. Safeinputs GH PR list: ✅ test: expand credential hiding tests to all 14 protected paths; test: add chroot escape vector test coverage
  3. Playwright github title: ✅
  4. Tavily search: ❌ (Tavily MCP unavailable)
  5. File write: ✅
  6. Bash cat: ✅
  7. Discussion query+comment: ✅ (discussion 1149)
  8. Build: ✅
    Overall: FAIL

🔮 The oracle has spoken through Smoke Codex for issue #1163

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

.NET Build Test Results

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

Overall: PASS

Run output

hello-world:

Hello, World!
```

**json-parse:**
```
{
  "Name": "AWF Test",
  "Version": 1,
  "Success": true
}
Name: AWF Test, Success: True

Generated by Build Test .NET for issue #1163

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

🦀 Rust Build Test Results

Project Build Tests Status
fd 1/1 PASS
zoxide 1/1 PASS

Overall: ✅ PASS

Generated by Build Test Rust for issue #1163

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Smoke Test Results

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude for issue #1163

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.

[Testing] Credential hiding integration tests only cover 3 of 14 protected paths

2 participants