Skip to content

test(app): resolve env(1) absolutely so the scrub probe survives a pinned PATH - #1633

Merged
jhrozek merged 1 commit into
mainfrom
fix-command-runner-env-probe-resolution
Sep 17, 2026
Merged

jhrozek merged 1 commit into
mainfrom
fix-command-runner-env-probe-resolution

Conversation

@blkt

@blkt blkt commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

TestCommandRunnerEnvironment_Scenario2_DefaultScrub pins PATH=/bin as a sentinel to
prove the secret scrub passes a benign variable through verbatim — but the probe ran as a
bare env, so that same sentinel also had to be a directory containing env(1). On macOS
it is not, so the probe exited 127 and the test failed as a scrub failure with a blank
environment dump.

Resolve env(1) at package init, before any t.Setenv can narrow PATH, and invoke it by
absolute path. Init-time is deliberate: a lazy lookup could run after the pinning test.

Not a GOOS skip — this is the Finding B scrub oracle, and skipping it on darwin puts the
hole on the platform much of the development happens on.

  • Work classification: Routine
  • Decision record: None
  • Human waiver of spine: Yes — directed by @michelangelomori

Type of change

  • Bug fix (test-only)

Test plan

  • All six TestCommandRunnerEnvironment_* scenarios pass; full internal/app green
  • task lint — 0 issues

User-facing change

None — test-only.

TestCommandRunnerEnvironment_Scenario2_DefaultScrub pins PATH to /bin as a
sentinel, to prove the secret scrub passes a benign variable through
verbatim. But commandRunnerEnv invoked the probe as a bare `env`, so the
same pinned PATH also had to be a directory where env(1) actually lives.
On darwin it is not (/usr/bin/env), so the probe exited 127 with empty
stdout and the test failed with "did not preserve default scrub:" and a
blank environment dump -- blaming the scrub for a probe that never ran.

Resolve env(1) once at package init, before any t.Setenv can narrow PATH,
and invoke it by absolute path. The sentinel is now purely a value under
assertion and need not be a usable PATH at all, which is the property the
test actually means to pin.

Init-time resolution is deliberate: a lazy sync.OnceValue would be too
late, since the PATH-pinning test can be the first caller.

Not a runtime.GOOS skip: this is the Finding B secret-scrub oracle, and
skipping it on darwin would put the hole on the platform much of the
development happens on.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@jhrozek
jhrozek merged commit 58c620e into main Sep 17, 2026
35 checks passed
@jhrozek
jhrozek deleted the fix-command-runner-env-probe-resolution branch September 17, 2026 10:42
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Sep 21, 2026
2 tasks
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.

2 participants