fix(normalizer): word-boundary check in classifyShellRisk β closes #63#88
Merged
fix(normalizer): word-boundary check in classifyShellRisk β closes #63#88
Conversation
Replace strings.HasPrefix(trimmed, prefix) with an exact-match-or-space check: trimmed == cmd || strings.HasPrefix(trimmed, cmd+" "). This prevents commands like "catalog_tool", "finder.sh --purge", or "echo 'rm -rf /' | bash" from being misclassified as RiskReadOnly because they happen to start with "cat", "find", or "echo". The fix preserves all legitimate matches (bare commands and commands with arguments) while closing the false read-only classification gap. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jpleva91
added a commit
that referenced
this pull request
Mar 30, 2026
Sprint goal ACHIEVED: all P0/P1 governance bugs closed. - PR #86 merged: P1 #28 (timeout override) closed - PR #88 merged: P1 #63 (classifyShellRisk word-boundary) closed - PR #89 open: P1 #68 (test coverage) + P2 #66 (dead code), CI green 5/5 Remaining blocker: PR #89 requires human review (@jpleva91). Dogfood (#76) blocked on setup.sh remote Ollama gap. Next sprint proposal: dogfood readiness + P2 batch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jpleva91
added a commit
that referenced
this pull request
Mar 30, 2026
Sprint goal ACHIEVED: all P0/P1 governance bugs closed. - PR #86 merged: P1 #28 (timeout override) closed - PR #88 merged: P1 #63 (classifyShellRisk word-boundary) closed - PR #89 open: P1 #68 (test coverage) + P2 #66 (dead code), CI green 5/5 Remaining blocker: PR #89 requires human review (@jpleva91). Dogfood (#76) blocked on setup.sh remote Ollama gap. Next sprint proposal: dogfood readiness + P2 batch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jpleva91
added a commit
that referenced
this pull request
Mar 30, 2026
Sprint goal ACHIEVED: all P0/P1 governance bugs closed. - PR #86 merged: P1 #28 (timeout override) closed - PR #88 merged: P1 #63 (classifyShellRisk word-boundary) closed - PR #89 open: P1 #68 (test coverage) + P2 #66 (dead code), CI green 5/5 Remaining blocker: PR #89 requires human review (@jpleva91). Dogfood (#76) blocked on setup.sh remote Ollama gap. Next sprint proposal: dogfood readiness + P2 batch. Co-Authored-By: Claude Sonnet 4.6 <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
strings.HasPrefix(trimmed, prefix)withtrimmed == cmd || strings.HasPrefix(trimmed, cmd+" ")inclassifyShellRiskcatalog_tool --delete,finder.sh --purge, orecho 'rm -rf /' | bashno longer match read-only prefixescat,find,echoRoot cause
strings.HasPrefixmatches any string sharing a prefix byte-for-byte, regardless of word boundaries. A command namedcatalog_toolis notcat, but the old code classified it asRiskReadOnlybecause"catalog_tool"starts with"cat".The most dangerous false positive:
echo 'rm -rf /' | bashclassified as read-only, reducing governance fidelity (though policy enforcement would still catch thermin destructive scan).Fix
Test plan
go build ./...passescatalog_tool --deleteβRiskMutating(notRiskReadOnly)cat file.txtβRiskReadOnly(still correct)go test ./...βRiskReadOnly(space-separated multi-word command preserved)π€ Generated with Claude Code