Skip to content

test: cover denied executable relocation through the broker - #201

Closed
kevin-orellana wants to merge 3 commits into
mainfrom
feature/denied-executable-rename-tests
Closed

kevin-orellana wants to merge 3 commits into
mainfrom
feature/denied-executable-rename-tests

Conversation

@kevin-orellana

@kevin-orellana kevin-orellana commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Human readable section

Problem. Box already refuses execution after a denied directory changes identity, but the complete workload route lacks regression coverage.
A test must show that the denied program never writes its marker after relocation.

Solution. Add six tests that invoke production Box through its shell and Python aliases.
They cover an empty replacement directory, a missing original name, symbolic-link replacement, invocation through a symbolic link, and scripts with listed or unlisted interpreters.
Controls verify permitted execution, interpreter selection, and unrelated directory renames.
Named executable and invocation variants describe each case.
Each test contains its replacement and interpreter assertions.
Shared assertions check exit statuses, marker contents, and file identities outside the workload.

Trade-off. This change adds tests only.
It preserves the existing refusal of further program launches when a denied path changes identity.
Hosts that cannot run the Linux namespace launcher print an explicit prerequisite skip.
Such skips do not establish execution coverage.

Description

The tests exercise the broker route after a permitted rename moves a denied directory within an executable directory grant.
They verify that the relocated program stays refused, even when an empty directory replaces the original name.

filesystem::require_judged_identities already checks the identities that the run recorded at startup before launching a program.
No production code, grants, policy rules, or public interfaces change.
The new platform prerequisite check follows the existing fixture convention.

Earlier mutation validation used the original test body on e0af331d457222d7fb189f9548653b92492eaa15.
Disabling only the denial identity check caused three variants to execute and write markers: replacement directory, linked binary, and listed-interpreter script.
The other three variants retained overlapping refusals.
The investigation restored production source byte-for-byte after that experiment.

Related Issues

Regression coverage for existing denied-executable behavior. This pull request does not close an issue or establish deployment qualification.

Type of Change

Other: regression tests for existing execution refusals.

Testing

Readability revision

Revision: 032773d78e558d370aa3f4ab261f2b97f0e37497.
The refactor changes only crates/box/tests/denied_executable.rs.
The six test names, generated workload, evidence fields, and prior assertions remain unchanged.
Two added assertions check the existing post-mutation control: status 126 and no execution marker.
The result retains the fixture until each test finishes its filesystem assertions.

Local validation used Linux ARM64 and Rust 1.98.1, with EXPERIMENTAL_LINUX_SUPPORT=TRUE, four build jobs, and four workspace test threads.

Check Result
Focused regression suite All six tests executed and passed. No prerequisite skips or denied-execution markers.
Full workspace suite Passed at 31ec426: 4,517 reported passes and 17 ignored tests, plus the custom box_library target. Zero failures.
Build with all features Passed for Box and containment at 31ec426. The focused run rebuilt the changed test for this revision.
Formatting cargo fmt --all --check passed.
Workspace lint Passed with zero warnings and the exact allowances from just clippy.
Local review Completed. Confirmed the six case configurations, all moved assertions, and fixture lifetime.
Hosted Linux workspace suite Passed. All six regression cases executed and passed, with six evidence records and no prerequisite skips in that test target.
Hosted macOS workspace suite Passed. All six regression cases report success.
Required CI gate Passed. Both containment jobs, native macOS checks, lint, and packaging also passed.
Automated review No remaining findings on 032773d. Maintainer approval remains required.

The focused command was cargo test -p strands-box --all-features --test denied_executable -- --show-output --test-threads=1.
The workspace command was cargo test --workspace --all-features --no-fail-fast -- --show-output.
Counts use the final result from each Cargo target and exclude nested child results.
The custom box_library target does not emit a test count.
The final revision adds only the two control assertions after the full workspace run. All six focused tests, formatting, and workspace lint passed again.
Workspace logs also report prerequisite skips for the absent credential daemon, a missing adjacent alias binary, and unsupported execute-without-read enforcement.
Those skipped assertions do not establish coverage.

Hosted checks used merge commit 5060ce2887f0ded15a9298fa524de6596e9378da, which combines 032773d with main at e4ca8b8.
The macOS workspace log suppresses successful test output, so it does not support a complete audit of prerequisite skips across that suite.

Original test revision

The results below cover 3323c483d77e343c6ce13ca037e9229c6fc943b0.
They remain as historical evidence and do not validate the readability revision.

Local validation uses Amazon Linux 2023 ARM64 with EXPERIMENTAL_LINUX_SUPPORT=TRUE. Hosted validation also covers macOS.
The original candidate starts from 6418aad and contains only the added regression test file.
Commit: 3323c483d77e343c6ce13ca037e9229c6fc943b0.
The required CI gate passed.

The final Linux execution command was:

EXPERIMENTAL_LINUX_SUPPORT=TRUE CARGO_BUILD_JOBS=1 cargo test -p strands-box --all-features --test denied_executable -- --nocapture --test-threads=1
Check Result
Build with all features Passed on the original base plus the test file.
Six production regression cases All six final tests executed and passed on Linux ARM64, with zero skips and no denied-execution markers.
Workspace lint Passed with the exact allowances from just clippy, with zero warnings.
Formatting cargo fmt --all passed.
Independent review Complete. The missing platform prerequisite check was corrected.
Local workspace tests Build failed before execution: the linker terminated with signal 9. This is not a completed test run.
Hosted Linux workspace tests Passed, with the workflow’s documented platform skips. The new tests skip on Linux x86_64 and execute separately on ARM64.
Local deterministic suite 118 passed, one failed, one errored, and nine skipped. The recorder self-test timed out; the Git identity case hit a path-prefix assertion.
Hosted Linux deterministic suite GREEN: 120 passed, zero failures/errors, nine platform skips.
Hosted macOS deterministic suite GREEN: 121 passed, zero failures/errors, eight skips.
macOS workspace tests Passed. All six new tests executed and passed without skips. The separate native macOS build and unit check also passed.
Build without default features Passed. Existing containment warnings remain in this configuration.
Scripted examples No scripted examples remain, so the script reported a skip. No live SDK tutorial was run.

The hosted runs linked above cover the original revision. Both local deterministic failures occur in unchanged test code.
The local failures remain recorded above; successful hosted runs do not erase them.
The original automated review completed with nonblocking readability feedback. This revision addresses that feedback and the maintainer's follow-up comments.

  • I ran the relevant suites (just check, or cargo test --workspace --all-features)
  • If I touched Rust, I ran cargo fmt --all and cargo clippy --workspace --all-targets --all-features -- -D warnings

The repository's just clippy recipe permits specific vendored lints after -D warnings.
The checked lint item uses that documented recipe, including its exact allowances. It does not claim an unrestricted strict lint run.

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

No documentation update is necessary because the change preserves all documented production behavior and test commands.

AI disclosure: Codex prepared these tests and this description at the contributor’s request.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

## Problem

The complete workload route lacks regression tests for execution after a denied directory moves.
Existing identity checks already refuse that route.

## Solution

Add six production tests for directory replacement, missing names, symbolic links, and scripts with listed or unlisted interpreters.
Check execution markers, file identities, permitted execution, and unrelated renames.
Use the existing prerequisite probe to report unsupported Linux execution platforms explicitly.
Production code and public interfaces remain unchanged.

## Tests

All six denied_executable tests executed and passed on Amazon Linux 2023 ARM64 before the prerequisite probe addition.
Workspace lint passed with the repository's vendored allowances, and cargo fmt --all passed.
Independent review found and verified the prerequisite probe correction.
The full workspace suite and deterministic suite are running for the final source.
macOS execution remains pending hosted validation.
Earlier mutation evidence on e0af331 showed three actual executions when the denial identity check was disabled.
The other three variants retained overlapping refusals.
@kevin-orellana
kevin-orellana marked this pull request as ready for review October 28, 2026 05:38
Comment thread crates/box/tests/denied_executable.rs Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Comment (non-blocking)

Solid, well-constructed regression coverage for the denied-executable relocation route. The suite exercises production Box through its aliases, asserts exit status, marker contents, and file identities together, and attaches a JSON evidence blob to every assertion — matching the "assert both status and effect" guidance in box/AGENTS.md. The platform prerequisite check uses the existing namespace_launcher_is_usable() fixture with a loud skipping: message, consistent with CONTRIBUTING.md. No production code changes.

Review Categories
  • Maintainability: The shared relocation helper takes three positional booleans, which are opaque at the six call sites and permit meaningless flag combinations. One inline suggestion to encapsulate them.
  • Testing: Coverage, assertion style (status + content + identity), and skip behavior all align with repository conventions. The asserted "was replaced" / "cannot be read" strings are the real messages from require_judged_identities, so the regression intent is genuinely pinned.
  • Scope: Test-only, single file, focused.

Nicely scoped regression work.

@kevin-orellana
kevin-orellana enabled auto-merge (squash) October 28, 2026 16:09
Comment thread crates/box/tests/denied_executable.rs Resolved
Comment thread crates/box/tests/denied_executable.rs Resolved
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Assessment: Comment (non-blocking)

I re-reviewed head 31ec426. The named Replacement / Executable(Interpreter) / Invocation variants and the per-test assertions resolve both earlier readability threads. Holding fixture::Configured in Relocation keeps the fixture alive until each test's assertions finish. One coverage gap remains, in the inline comment.

Checks that held
  • Positional-boolean concern: resolved. Invalid combinations (an interpreter choice without a script) are no longer representable.
  • DENIED_AFTER=126 and an absent blocked-after marker are asserted for all six cases.
  • Each case's stderr substring (was replaced / cannot be read) matches the denial loop in filesystem::require_judged_identities.
  • Unlisted-interpreter case: the 126 status alone has two causes (the SCRIPT_CONTROL=126 control shows that the interpreter refusal is enough). The was replaced assertion still ties the test to the identity check, as the description acknowledges.
  • Skip uses namespace_launcher_is_usable() with a skipping: message, per CONTRIBUTING.md.
  • Test-only change; no frozen surface in AGENTS.md / crates/box/AGENTS.md is touched.

I could not run the suite: this host is x86_64, where these tests skip.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Assessment: Approve

I re-reviewed head 032773d. The only change since 31ec426 is in the shared helper: it now requires PERMITTED_AFTER_MUTATION=126 and checks that no allowed-after-mutation marker was written. The refusal of later launches that the description promises is now pinned, which resolves the line-170 thread. I have no further findings.

Checks that held
  • New assertion: in all six cases, every launch after the change is refused. require_judged_identities checks every deny entry on each host spawn. In the Directory, Symlink and linked/script cases, that check fails with "was replaced". In the Missing case, it fails with "cannot be read". So the permitted program is refused the same way as the denied one.
  • Earlier checks from the last two summaries still hold. The helper and the per-test assertions are otherwise unchanged.

I could not run the suite here, because it skips on x86_64. I'm relying on the author's report that all six cases pass on Linux ARM64.

@kevin-orellana

Copy link
Copy Markdown
Collaborator Author

Consolidated into #264 at a25b98d.

The merge preserves all three commits and imports the six tests unchanged, including the readability fixes and post-relocation control assertions. All eight regression cases passed together on Linux ARM64. The combined workspace suite passed with 4,619 reported passes, zero failures, and 17 ignored tests, plus the custom harness target. Hosted validation continues on #264.

Closing this PR as superseded so review continues in one place: #264.

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