feat(classifiers): optional classifyBashCommand behind /classifiers subpath#382
Merged
Conversation
…rs subpath Ships an opt-in, dependency-free shell risk classifier for the onToolCall gate (#377). classifyBashCommand(command) returns safe | review | high so users get the taxonomy from #96 without writing regex tables by hand. - safe: read-only inspection (ls, cat, grep/rg with a path, git status/log/diff) - review: context bombs and unknowns (ls -R, find / without -maxdepth, grep -r / rg -r without scope, tree, du, unrecognised commands) - high: destructive/sensitive (rm, sudo, curl | bash, dd, mkfs, chmod 777/-R, git push --force, npm publish) Compound commands are segmented on shell separators and the highest risk wins; quoted strings are stripped so patterns inside a string do not match. Convenience heuristic, not a security boundary. Exported only via @open-multi-agent/core/classifiers so pattern tables never load unless imported. Closes #379
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.
Implements #379 (the second split of #96). The per-call
onToolCallgate landedin #377; this adds the optional shell risk classifier that pairs with it.
What
classifyBashCommand(command): { level, reason }, levelsafe | review | high.Pure, dependency-free; no code copied from temodar-agent.
@open-multi-agent/core/classifierssubpath so thepattern tables never load unless imported (answers Optional shell risk classifier for the onToolCall gate #379's packaging question:
core subpath, not a separate package).
Classification
ls,cat,pwd,grep/rgwith a path,git status|log|diff|show).ls -R,find //find ~without-maxdepth,grep -r/rg -rwithout a scopedpath,
tree,du, and any unrecognised command ("don't run blind").rm,sudo,curl | bash,dd,mkfs,chmod 777/-R,git push --force,npm publish, writes to system paths.Compound commands are segmented on
&&/||/;/|/newlines plus one level ofsubstitution, and the highest risk wins, so a safe prefix cannot smuggle a
destructive suffix (
ls && rm -rf /becomes high). Quoted spans are strippedfirst, so
echo "rm -rf /"stays safe. Shallow heuristic, not a securityboundary; the tables are meant to be extended or replaced.
Pairs with the
onToolCallgate from #377:Scope
Classifier only. Docs and a runnable example are tracked separately in #380. No
change to the gate, tool grant, or existing behavior.
Tests
Core
npm run lintandnpm testare green (1312 tests). Adds table-drivenclassifier tests (per level, compound-command escalation, false-positive guards,
return shape) and a subpath import smoke test.
Closes #379