fix(stibbons): harden labels sync arg handling and subprocess safety#721
Merged
Conversation
Deferred hardening follow-ups from the adversarial review of #289 / PR #693, all confined to crates/stibbons/src/labels/ and shipped together. Arg-injection hardening (#694): - LabelDef::validate() rejects name/color/description beginning with `-` (which gh/glab could parse as a flag) and enforces a 6-hex-digit color. - Backends build argv with `=`-form flags (--color=..., --description=...) and, for gh, a `--` terminator before the positional name, so a leading-dash value can never be parsed as an option even if validation is bypassed. Reliability guards (#695): - New exec::run_with_timeout wraps gh/glab/git in a std-only deadline (spawn + thread-drained pipes + try_wait poll + kill), so a wedged interactive re-auth or stalled network fails the run instead of hanging. backend::run() and platform::origin_remote_url() route through it. - find_metadata_files tracks canonicalized visited dirs and caps recursion depth, terminating on directory symlink cycles instead of exhausting fds/stack; oversized metadata.yml is skipped with a warning before parsing. Test coverage (#696): - gh/glab create/update arg construction asserted (incl. GitLab --label-id update path and the gh `--` terminator); validate() accept/reject cases. - classify_remote bare-substring fallback branch; resolve_skill_roots empty-roots error and default_skill_roots existence; exec timeout/success. - Hermetic integration tests for `stibbons setup` real execution and the orphaned-reference warning reaching CLI stderr. No new dependency (Cargo.lock untouched); no behavior change for well-formed metadata. Closes #694 Closes #695 Closes #696 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Combined hardening of
stibbons labels sync, addressing three deferredfollow-ups from the adversarial review of #289 / PR #693. All changes are
confined to
crates/stibbons/src/labels/, so they ship as one PR.#694 — arg-injection hardening
LabelDef::validate()rejectsname/color/descriptionvalues beginningwith
-(whichgh/glabcould otherwise parse as a flag) and enforces a6-hex-digit
color.=-form flags (--color=…,--description=…) and,for
gh, a--terminator before the positional name — so a leading-dashvalue can never be parsed as an option even if validation were bypassed.
#695 — subprocess timeouts + walk/size guards
exec::run_with_timeoutwrapsgh/glab/gitin a std-only deadline(spawn + thread-drained pipes +
try_waitpoll +kill), so a wedgedinteractive re-auth or a stalled network call fails the run instead of hanging
forever (fatal in CI).
backend::run()andplatform::origin_remote_url()route through it. No new dependency —
Cargo.lockis untouched.find_metadata_filestracks canonicalized visited directories and capsrecursion depth, terminating on directory symlink cycles instead of exhausting
fds/stack. Oversized
metadata.ymlfiles are skipped with a warning beforeparsing.
#696 — test coverage
gh/glabcreate/update arg construction asserted (incl. the GitLab--label-idupdate path and thegh--terminator);validate()accept/reject cases.
classify_remotebare-substring fallback branch;resolve_skill_rootsempty-roots error +
default_skill_roots()existence;exectimeout/success/spawn-failure/large-output.
stibbons setupreal execution and theorphaned-reference warning reaching CLI stderr.
No behavior change for well-formed label metadata.
Test plan
cargo test -p stibbons— 164 unit + 28 labels integration (+ others) pass.cargo clippy --workspace --all-targets -- -D warningsclean;cargo fmtclean.metadata.ymlwith a leading-dashcolornow errors clearly atvalidate()before any mutatinggh label editcall (exit 1), instead ofshelling a bad flag.
Closes #694
Closes #695
Closes #696