Guard basename against a login shell's leading-dash argv[0] in the browser reaper #393
No reviewers
Labels
No labels
Agent
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No assignees
2 participants
Notifications
Total time spent: 15 seconds
Due date
igor
15 seconds
No due date set.
Dependencies
No dependencies set
Reference
joshtronic/igor!393
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/reaper-basename-dash"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
During the maintenance/recovery tick,
basenamewas fed an argument starting with a dash and parsed it as an option:basename: invalid option -- 'b'(igor#392). It fired repeatedly right after the recovery sweep.Root cause
lib/browser-reap.sh(the #389 stale-headless-browser reaper) takes the first whitespace token of eachpsline as the binary path:A login shell appears in
pswith a leading-dash argv[0] (-bash), so${cmd%% *}is-bashandbasenamereads-bas an option. Because every harness lib runs underset -euo pipefail, that non-zerobasenameaborted the wholebrowser_reap_select_victimsread loop mid-scan — so any genuine stale-browser victims listed after a login-shell row were never selected. The tick continued (the sweep is called tolerantly), which is why it looked non-fatal while the reaping it added in #389 was silently defeated.Fix
Add the
--end-of-options guard:Test
bin/test-browser-reap.shgains a case for a-bashargv[0]: it asserts the predicate emits no basename/option error (fails without the guard — reproducesinvalid option -- 'b'— passes with it) and that a login shell is spared.make testgreen;shellcheckclean on both files.Closes #392
A login shell appears in `ps` as `-bash`, so `${cmd%% *}` is `-bash` and `basename` parsed the `-b` as an option ("basename: invalid option -- 'b'"). Under the harness's `set -euo pipefail`, that error aborted the whole browser_reap_select_victims loop mid-scan, so any real stale-browser victims listed after such a row were never selected — silently defeating the #389 reaper. Add the `--` end-of-options guard. Regression test asserts a leading-dash argv[0] emits no basename/option error (fails without the guard, passes with it) and that the login shell is spared. Closes #392 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4YUVfbfUWdUwifGJ2TvkP🤖 Review —
APPROVE(automated)CI for
b7b275b4: successOne-line: Adds
basename --to stop a login shell's leading-dash argv[0] (-bash) from being parsed as an option and aborting the reaper's selection loop — correct, focused, and tested.Findings:
lib/browser-reap.sh:66—basename -- "${cmd%% *}"is the right fix.--terminates option parsing so-bashis treated as a literal path; the resulting base is-bash, which is neither protected nor a browser binary, so it's correctly spared. This resolves theinvalid option -- 'b'abort underset -euo pipefail.bin/test-browser-reap.sh:65-78— new case genuinely exercises the bug: asserts no error on stderr for-bashargv[0] (would fail pre-fix) and that the login shell is spared. Good regression coverage.make testgreen, shellcheck clean) are consistent with CIsuccess.No security, correctness, or scope concerns. Nothing blocking.
Independent review by the harness on
claude-opus-4-8(effort: high). The human reviewer is requested once Igor has reviewed; a human still merges.