Skip to content

test(sandbox): pin the two documented boundaries - #1261

Merged
Chemaclass merged 1 commit into
mainfrom
test/sandbox-boundary
Aug 14, 2026
Merged

test(sandbox): pin the two documented boundaries#1261
Chemaclass merged 1 commit into
mainfrom
test/sandbox-boundary

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1260

--sandbox had 9 acceptance tests and none for either boundary the docs draw — both security-adjacent, both able to regress silently:

  • A child process cannot resolve an unmocked command. sh -c 'command -v probe' returns empty under --sandbox: the narrowed PATH is inherited, so the command is unreachable rather than merely unreported. That is what makes sh -c 'curl …' useless as an escape off Windows.
  • An absolute path bypasses the sandbox — documented as a limitation, now pinned so it stays deliberate.

💡 Changes

  • Two acceptance tests plus their fixture entries

The mechanism is not what it looks like

Removing export PATH from src/runner/sandbox.sh changes nothingPATH is exported already, so that mutation is a no-op and every test still passes. My first version of the comment claimed the property depended on it.

It actually holds because the sandbox replaces PATH rather than prepending:

PATH="$_BASHUNIT_SANDBOX_DIR"        ->  PATH="$_BASHUNIT_SANDBOX_DIR:$PATH"

fails the child-process test and nothing else. Both facts are recorded in the comment — a comment naming the wrong dependency is worse than none, since the next person mutates what it names, sees green, and concludes the test is worthless.

Fixture safety checked: every test in the file filters, so the two added fixture entries are only reached via their own filters, and the fixture is not collected by the suite (does not match *[tT]est.sh, and fixtures/ is excluded by path).

--sandbox had 9 tests and none for either boundary the docs draw.

A child process cannot resolve an unmocked command: `sh -c 'command -v probe'`
returns empty, so the command is unreachable rather than merely unreported.
That is what makes `sh -c 'curl …'` useless as an escape off Windows. An
absolute path does bypass the sandbox, which is documented, and nothing kept it
a deliberate boundary.

The mechanism is not what it looks like. Removing `export PATH` from
sandbox.sh changes nothing -- PATH is exported already, so that mutation is a
no-op. The property holds because the sandbox *replaces* PATH rather than
prepending to it; mutating it to "$_BASHUNIT_SANDBOX_DIR:$PATH" fails the
child-process test and nothing else. Both facts are in the comment, because a
comment naming the wrong dependency is worse than none.

Closes #1260
@Chemaclass Chemaclass added the pure testing Pure testing related label Aug 14, 2026
@Chemaclass Chemaclass self-assigned this Aug 14, 2026
@Chemaclass
Chemaclass merged commit 414373b into main Aug 14, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the test/sandbox-boundary branch August 14, 2026 17:36
Chemaclass added a commit that referenced this pull request Aug 14, 2026
Narrowing PATH is not workable under Git Bash, so a command reached from a
child process is not blocked there -- docs/test-doubles.md documents that
exception and ADR-012 records the mechanism. The test added in #1261 asserted
the non-Windows behaviour unconditionally and failed windows-acceptance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pure testing Pure testing related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant