Repository navigation
fix: opencode auto-approve — token-exact --force match + test coverage - #25
Merged
Merged
Conversation
…, spec contract The permission.ask handler parsed the subcommand by token but fell back to a whole-string substring match for the sync --force guard, so any argument containing "--force" (a future --forceful flag, a value with the word embedded) tripped the destructive-command prompt. Conservative direction only — a consistency hygiene issue, not a hole. - Extract the decision into allowsOrbitCommand (pure, attached to the default export like invokesOrbitCli) with token-exact matching. - Cover it with tests: safe tiers allow, tier-3/chained/non-orbit prompt, sync --force prompts, --forceful allows, quoted --force word conservatively prompts (parity with the shell hook's padded match). - spec-hooks: contract the token-exact rule so future ports don't reintroduce substring matching. Signed-off-by: zheng-weihao <zheng-weihao@outlook.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.
Problem
The
permission.askhandler parsed the subcommand by token but guardedsync --forcewith a whole-string substring match (cmd.includes("--force")), so any argument containing that substring — a future--forcefulflag, or a value with--forceembedded — tripped the destructive-command prompt. Conservative direction only (an extra prompt, never a wrongly-allowed command): a consistency hygiene issue, not a security hole. The shell hook (hooks/auto-approve.sh) already matches with token boundaries (space-padded--force).Fix
allowsOrbitCommand— a pure helper attached to the default export (same pattern asinvokesOrbitCli), matching--forcetoken-exactly, consistent with how the subcommand itself is parsed.doneprunecloneconfignew) prompt / chained, substituted, and non-orbit commands prompt /sync --forceprompts /--forcefulallows / a whitespace-delimited--forceinside quotes conservatively prompts (parity with the shell hook, fail-safe direction). 14/14 pass.Test
npm testin.opencode-plugin/— 14/14. No runtime behavior change beyond removing the false-positive prompts.