Repository navigation
[Test Quality] test: reject path-separator binary names in usr-local-bin shim test - #11893
Conversation
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]>
There was a problem hiding this comment.
🟢 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/localfixture 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)
|
✅ Copilot review passed with no inline comments. @github-actions[bot] Add the |
✅ Coverage Check PassedOverall Coverage
Coverage comparison generated by |
|
@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]>
Merged |
Contract
containers/agent/entrypoint.shensure_usr_local_bin_shims()readsAWF_ENSURE_USR_LOCAL_BINand must reject any name that fails^[A-Za-z0-9_][A-Za-z0-9_.-]*$withIgnoring 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../evilorsub/evilfrom escaping that directory.Previous weakness and missed regression
Case 5 of
tests/usr-local-bin-shim.test.shtested 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 ofentrypoint.shoutside 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, andcopilot;evil. For each, it asserts the exact rejection message and that the/usr/localtree 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)
entrypoint.sh, beforeentrypoint.sh, after/in names, original test/in names, new testcopilot/../evil,sub/evil), exit 1., new test../evil,copilot/../evil,sub/evil), exit 1Mutants 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 0shellcheck -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) runsbash tests/usr-local-bin-shim.test.sh.Limitations
/usroverlay fallback needs mount privileges and is out of scope, as the file header already states.Removed or consolidated tests
None removed. Case 5 was replaced with a stricter case that keeps the original
../evilassertion, so the protection it provided is retained.