feat(knowledge): treat informational invocations as safe (1.3.0)#5
Merged
Conversation
Add an informational-form safety gate so commands that are risky-by-default (dart, flutter, node, python, go, cargo, …) classify as read-only/safe when *every* argument is a purely informational token (--version/--help/--usage, plus per-command forms like java -version, python -V, go version/env). - New top-level `defaultInformationalTokens` (global) and per-command `CommandKnowledge.informationalTokens` field. - Gate runs at the top of `_collect`, before base caps/risk and at every recursion depth, so wrapped forms (`sudo node --version`) are handled. - Case-sensitive matching (-V ≠ -v); a payload token defeats the gate (`dart --version x.dart`, `go env -w K=V` still execute). - Adds a dedicated test group; bumps version to 1.3.0 and updates docs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Context
Many commands are risky-by-default in the knowledge base —
dart,flutter, and the interpreters inshell_knowledge.dart(node,python,ruby,java, …) pluscargo/gocarrybaseCapabilities: {executePrograms}. The analysis pipeline only ever adds capabilities and raises risk, so harmless invocations likedart --version,node --version,python --versionwere wrongly reported asexecutePrograms.This adds a new mechanism — an informational-form gate — that recognizes purely informational invocations as read-only/safe, only when every argument is informational (so
dartcan still run arbitrary code with other parameters).What changed
defaultInformationalTokens(--version,--help,--usage) applied to all known commands.CommandKnowledge.informationalTokensfield for tool-specific forms: java-version, python-V, node/php/ruby-v, perl-v/-V, deno/cargo-V, goversion/env, dotnet--info/--list-sdks/--list-runtimes._collect, before base caps/risk and at every recursion depth → wrapped forms likesudo node --versionare handled (andsudostill reportsprivilegeEscalation).-V≠-v); a single payload token defeats the gate (dart --version x.dart,go env -w K=Vstill reportexecutePrograms).Behavior change
Bare
--version/--help/--usage(and the per-command short forms) on execute-by-default tools now classify as read-only/safe instead ofexecutePrograms.npm --versionmoves from an empty capability set toreadFilesystem(risk stayssafe).Verification
dart format— cleandart analyze— No issues founddart test— 404/404 pass (13 new gate tests)Bumps version to 1.3.0 and updates
CHANGELOG.md+doc/architecture.md.🤖 Generated with Claude Code