Skip to content

[Test Quality] test: reject path-separator binary names in usr-local-bin shim test - #11893

Merged
lpcox merged 2 commits into
mainfrom
test-quality/usr-local-bin-unsafe-name-path-separators-d77d2d07d45377f1
Nov 21, 2026
Merged

lpcox merged 2 commits into
mainfrom
test-quality/usr-local-bin-unsafe-name-path-separators-d77d2d07d45377f1

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Contract

containers/agent/entrypoint.sh ensure_usr_local_bin_shims() reads AWF_ENSURE_USR_LOCAL_BIN and must reject any name that fails ^[A-Za-z0-9_][A-Za-z0-9_.-]*$ with Ignoring invalid AWF_ENSURE_USR_LOCAL_BIN entry: <name>, creating nothing. Names must stay confined to /usr/local/bin. This is the boundary that stops a path such as ../evil or sub/evil from escaping that directory.

Previous weakness and missed regression

Case 5 of tests/usr-local-bin-shim.test.sh tested only ../evil. That name is rejected by the leading-character rule (. is not allowed first), so the test never exercised the separator handling inside a name. A validator that allowed / anywhere after the first character still passed all 9 cases. I confirmed this with a mutant copy of entrypoint.sh outside the workspace: the original test reported 9/9 passing against it.

Change

Case 5 now loops over four unsafe names: ../evil, copilot/../evil, sub/evil, and copilot;evil. For each, it asserts the exact rejection message and that the /usr/local tree is unchanged. Path separators and shell metacharacters are covered. The test layer is unchanged: it runs the real entrypoint functions against a writable fixture root, as the rest of the file does. No production code, workflow, or dependency changes.

Regression sensitivity (validated)

Run Result
Real entrypoint.sh, before 9 passed, 0 failed
Real entrypoint.sh, after 9 passed, 0 failed
Mutant allowing / in names, original test 9 passed (regression missed)
Mutant allowing / in names, new test 8 passed, 2 failed (copilot/../evil, sub/evil), exit 1
Mutant allowing a leading ., new test 8 passed, 3 failed (../evil, copilot/../evil, sub/evil), exit 1

Mutants were temporary copies in a scratch directory. The workspace contains only the test change.

Commands

  • bash tests/usr-local-bin-shim.test.sh → Results: 9 passed, 0 failed, exit 0
  • shellcheck -x -S error tests/usr-local-bin-shim.test.sh → no error-level findings. The warning count is unchanged at 7 (existing SC2034 style, also present before this change).

CI discovery

.github/workflows/build.yml → job "Run shell unit tests" (Node 20 matrix entry) runs bash tests/usr-local-bin-shim.test.sh.

Limitations

  • Only the name validator is covered here. The read-only /usr overlay fallback needs mount privileges and is out of scope, as the file header already states.
  • Docker/chroot end-to-end runs were not performed; this environment has no Docker. Evidence is process-level only.

Removed or consolidated tests

None removed. Case 5 was replaced with a stricter case that keeps the original ../evil assertion, so the protection it provided is retained.

Generated by Test Quality Improver · copilot · routed: haiku55 xhigh · ~16 AIC · ⌖ ~2 AIC · ⊞ 5.4K · ◷

  • expires on Dec 21, 2026, 12:39 PM UTC

The unsafe-name case only exercised '../evil', which the leading-character
check rejects on its own, so a validator that accepted '/' inside names
passed the suite. Cover path separators and shell metacharacters, and
assert that no /usr/local tree entries are created for any rejected name.

Co-authored-by: Copilot <[email protected]>
@lpcox
lpcox marked this pull request as ready for review November 21, 2026 16:23
Copilot AI adaptive review requested due to automatic review settings November 21, 2026 16:23

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.

🟢 Approval recommended

The review found no active issues, and the changes are limited to expanded regression coverage for unsafe names while verifying rejection and fixture integrity.

No open issues 🎉

What changed in this PR

This pull request strengthens the /usr/local/bin shim regression test by covering unsafe binary names containing path separators and shell metacharacters, without changing production code.

Changes:

  • Expands the invalid-name cases to include path traversal, nested separators, and shell metacharacters.
  • Verifies rejection behavior and confirms the /usr/local fixture remains unchanged.
  • Preserves the existing shell test and CI integration.
File Description
tests/​usr-local-bin-shim.test.sh Expands regression coverage for unsafe binary names, including path separators and shell metacharacters, while checking for unintended filesystem changes.

Review effort: Lite (adaptive)

@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Copilot review passed with no inline comments.

@github-actions[bot] Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 94.40% 94.40% ➡️ +0.00%
Statements 93.01% 93.01% ➡️ +0.00%
Functions 93.61% 93.61% ➡️ +0.00%
Branches 87.31% 87.31% ➡️ +0.00%

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

@lpcox

lpcox commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main, resolve conflicts, and address review feedback

…l-bin-unsafe-name-path-separators-d77d2d07d45377f1

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

@copilot merge main, resolve conflicts, and address review feedback

Merged main without conflicts; merge commit 4ae4e9a is published. The review has no active issues. The prior PR Title Check still fails because the title does not start with a conventional release type; it will need a title update.

Copilot AI requested a review from lpcox November 21, 2026 17:49
@lpcox
lpcox merged commit ccfc8ff into main Nov 21, 2026
35 of 37 checks passed
@lpcox
lpcox deleted the test-quality/usr-local-bin-unsafe-name-path-separators-d77d2d07d45377f1 branch November 21, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants