fix(registry): resolve paren/brace wraps and env-then-sudo in command safety - #5606
Conversation
… safety
Skip leading (/ { /whitespace in resolveSegmentCommand so (rm -rf /) still
resolves to rm, and loop sudo/env prefix stripping so env VAR=x sudo <cmd>
is handled the same as sudo env.
Closes JSONbored#5585
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-27 20:22:56 UTC
Review summary Nits — 4 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5606 +/- ##
=======================================
Coverage 96.42% 96.43%
=======================================
Files 529 529
Lines 16321 16334 +13
Branches 3734 3734
=======================================
+ Hits 15738 15751 +13
Misses 195 195
Partials 388 388
🚀 New features to boost your workflow:
|
Summary
resolveSegmentCommandso leading(/{/whitespace are skipped before reading the command word —(rm -rf /)resolves torminstead of"".sudo/envprefix stripping until stable soenv VAR=x sudo <cmd>is handled the same assudo env VAR=x <cmd>.hasRecursiveForceRemove,hasWorldWritableChmod,hasPipeToShellInstall,hasBase64DecodedShell) benefits without per-detector changes.Closes #5585
Submission Source
No visual impactare included when relevant.Schema and Quality Checks
viewCount,copyCount,popularityScore)Quality Evidence
Changed surface:
packages/registry/src/command-safety-lib.js—resolveSegmentCommandgrouping skip + sudo/env looptests/command-safety-lib.test.ts— fix: resolveSegmentCommand returns an empty command for paren/brace-wrapped commands, bypassing shell-safety detectors #5585 regression casesResolver change: skip leading
(/{/whitespace on each prefix-loop iteration and before the final command read; re-checksudo/envafter each strip instead of a fixed sudo-then-env order.Expected behavior / before→after:
resolveSegmentCommand→hasRecursiveForceRemove)(rm -rf /)""→ falserm→ trueenv FOO=bar sudo rm -rf /sudo→ falserm→ truesudo env FOO=bar rm -rf /rm→ truerm→ true (unchanged)rm -rf /rm→ truerm→ true (unchanged)Invariants: individual detector logic untouched; only the shared resolver changed (per issue scope).
Screenshots: No visual impact — registry command-safety correctness only; no routes/UI.
Validation
pnpm exec vitest run tests/command-safety-lib.test.ts tests/command-safety.test.ts tests/command-safety-posix-shell.test.ts— 98 passedpnpm exec vitest run tests/submission-risk-invariants.test.ts— 72 passedpnpm build— passedpnpm validate:clean— passedpnpm exec prettier --checkon touched files — cleantrunk check --upstream origin/main— no issuesgit diff --check/node --check packages/registry/src/command-safety-lib.js— cleanNotes
required-pr-gateauto-close), fix(registry): detect PEM, Slack, and Stripe secrets in submissions #5566 (LoopOver reject). This PR: two-file focused diff, one-shot commit, local trunk + build + focused tests green before open, no post-open pushes.