feat: implement core tool categories and granular sub-constraints#1101
Merged
feat: implement core tool categories and granular sub-constraints#1101
Conversation
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
Implements #1034 (core tool categories) and #220 (granular tool access sub-constraints) as a single cohesive change. Adds 6 new tools across 3 categories, a shared SSRF prevention layer, and a granular sub-constraint enforcement pipeline integrated into the existing tool invoker.
Tool Categories (#1034)
Web tools (
tools/web/)NetworkPolicy, IP blocklist, DNS validation). Redirects disabled to prevent SSRF bypass. Response truncation at configurable max bytes.WebSearchProviderprotocol -- no concrete implementation shipped (inject via MCP bridge or custom provider).html.parser. Strips script/style tags. Operates on pre-fetched content (no HTTP).Database tools (
tools/database/)?mode=ro. Query timeout viaasyncio.wait_for. Table name validation regex for PRAGMA queries.list_tables(sqlite_master) +describe_table(PRAGMA table_info with safe identifier validation).Terminal tools (
tools/terminal/)SandboxBackenddelegation. Command allow/blocklist. Working directory support. Output truncation. Returns error when no sandbox configured.Shared infrastructure
network_validator.py: Extracted SSRF blocklist and DNS validation fromgit_url_validator(backward compatible).NetworkPolicymodel reusable across tool categories. Case-insensitive scheme validation.Granular Sub-Constraints (#220)
Models (
sub_constraints.py)FileSystemScope,NetworkMode,GitAccess,CodeExecutionIsolation,TerminalAccessToolSubConstraintsfrozen Pydantic model with per-level defaults matching operations.md section 11.2get_sub_constraints()resolution with custom override supportEnforcement (
sub_constraint_enforcer.py)SubConstraintEnforcerchecks network (blocks WEB when NONE), terminal (blocks TERMINAL when NONE), git (blocks push for LOCAL_ONLY/READ_AND_BRANCH, blocks clone for LOCAL_ONLY), and requires_approval (escalation for matching action type prefixes)ToolPermissionChecker(optionalsub_constraintsparam)ToolInvokerpipeline between permission check and param validationAgent model
ToolPermissionsgainssub_constraints: ToolSubConstraints | Nonefield for per-agent overridesIntegration
_build_web/database/terminal_toolsbuildersRootConfiggains optionalweb,database,terminalconfig fieldshttpx==0.28.1(async HTTP client)Security Highlights
Test Plan
Review Coverage
Closes #1034
Closes #220