Repository navigation
Check PowerShell and every command input field (T196) - #85
Merged
Merged
Conversation
erickb336
commented
Oct 7, 2026
erickb336
left a comment
Owner
Author
There was a problem hiding this comment.
Codex review result for 92618e4c27ad4fa739fcf032b12335d50694cdb3: two clean cycles.
| Cycle | Code/security | QA |
|---|---|---|
| 1 | No remaining findings after nested-input and approval-target repairs | 7/7 T196 tests and 5/5 adjacent regressions; generated hook matches source |
| 2 | Different reviewer independently traced all-field handling, PowerShell rules, terminal cwd, fallback refusal, and approval precedence; no findings | Independently ran 7/7 T196 tests; checked exact main-red names and both before-fix regression failures |
Both cycles reviewed this same commit. Full suite: 650 pass, 0 fail. On detached main 86c8b2f, all seven new named tests fail with only the test file copied over. Existing assertions are unchanged. No native PowerShell execution or real GitHub write was performed; limitations remain in the PR body.
erickb336
marked this pull request as ready for review
October 7, 2026 23:14
This was referenced Oct 8, 2026
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.
Closes #69
Sage task T196
The hook now checks merge and push commands in every string field, including nested inputs. Terminal commands use the tool's working directory for the check that refuses pushes from main.
For PowerShell, the hook refuses backticks or parentheses when the text names gh, git, pr, merge, or push. It removes backticks only for word detection. This conservative choice avoids treating PowerShell expansion as Bash syntax. Plain commands and ordinary unprotected expressions retain their behavior.
The change lives in
packages/sage-claude/hooks/sage-hook.mjs; shared core policy APIs are unchanged. The plugin hook is regenerated by the build.Review repairs
Initial review found two issues, both reproduced before repair:
Two clean code/security and QA cycles passed on
92618e4c27ad4fa739fcf032b12335d50694cdb3after the repairs. Cycle 2 used a different code/security reviewer and independently reran all seven T196 groups. No commit followed either clean cycle.Validation
Fake ps, pgrep, and kill were first on PATH for every test. First-upload tests used fake gh responses. Attack strings reached only hook JSON inputs; no test ran a real merge, push, or attack command.
npm run buildnpm run checknode --test --test-name-pattern=T196 scripts/sage-hook.test.mjsnpm testgit diff --checkOn detached main
86c8b2f, only the updated hook test file was copied over. The same T196 command ran all seven new named tests: 0 pass, 7 fail. They cover the main session and an agent, the three reported PowerShell forms, nested fields, terminal directory selection, and first-upload approval ambiguity. Existing test assertions are unchanged.Not verified / seen, not fixed
No live Claude session, native PowerShell execution, or real GitHub write was tested. This task does not provide a complete PowerShell parser. Existing agent parsing can still reject escaped-quote PowerShell text; that behavior predates this change. The existing SDK dependency advisory is unchanged.