feat(permissions): add kiro-scoped override for shell auto-trust flags, aws services, and web_fetch domain trust - #2195
Merged
Conversation
…s, aws services, and web_fetch domain trust Kiro's agent config (.kiro/agents/<name>.json) exposes per-tool toolsSettings knobs with no canonical allow/ask/deny category. Add a tool-scoped kiro override (per #2127) authoring the ones that live in the agent config this permissions translator already writes: - shell auto-trust flags: toolsSettings.shell.autoAllowReadonly / denyByDefault - aws built-in tool: toolsSettings.aws.allowedServices / deniedServices (+ autoAllowReadonly) - web_fetch domain trust: toolsSettings.web_fetch.trusted / blocked (regex host patterns; documented for web_fetch only, so web_search is not modeled) Wiring: - Generate: deep-merge the override per toolsSettings key (override wins at the leaf) so authoring shell.autoAllowReadonly keeps the canonical-generated shell.allowedCommands. Non-canonical shell flags already in the file are also preserved across regenerate even without an override. Prototype-pollution keys are guarded before being used as object keys. - Import: lift the kiro-specific surfaces into the kiro override so they round-trip and become authorable; canonical shell command lists / read / write / grep / glob / web allowedTools toggles are unchanged. All shapes were verified against Kiro's primary docs (built-in-tools and configuration-reference, rendered via a browser since kiro.dev is a SPA). Out of scope (deferred): Kiro's MCP autoApprove / disabledTools live in a separate file (.kiro/settings/mcp.json, under mcpServers.<name>), not the agent config this translator writes, and reconciling them with the canonical mcp__* model is a distinct design question. Item 1 of the issue (grep/glob mapping) already shipped in #2170. Closes #2132 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lists Review finding (low, footgun): applyKiroOverride merged EVERY override toolsSettings key after the canonical generation, so a user could author kiro.toolsSettings.read.deniedPaths: [] (or shell.deniedCommands: []) and silently weaken a canonical-generated deny — contradicting the override's documented 'non-canonical keys only' contract. - Reject fully-canonical toolsSettings keys (read/write/grep/glob) in the override with a warning (their paths are owned by the canonical permission block). - For shell (partly canonical), strip the canonical command-list leaves (allowed/deniedCommands) from the override value so only the auto-trust flags merge. - Add the same prototype-pollution guard to the import-side extractKiroOverride for symmetry with the generate side. - Add a regression test asserting the override cannot clobber shell.deniedCommands or read.deniedPaths while a legitimate non-canonical flag still applies. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
@dyoshikawa Thank you! |
Merged
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
Implements item 2 of #2132: a tool-scoped
kiropermissions override namespace (per #2127) for Kiro's agent-configtoolsSettingsknobs that have no canonical allow/ask/deny category. (Item 1 — mapping the canonicalgrep/globcategories — already shipped in #2170.)Scope
The override authors the Kiro-specific surfaces that live in the agent config (
.kiro/agents/<name>.json) this permissions translator already writes:toolsSettings.shell.autoAllowReadonly/denyByDefaultawsbuilt-in tool —toolsSettings.aws.allowedServices/deniedServices(+autoAllowReadonly)web_fetchdomain trust —toolsSettings.web_fetch.trusted/blocked(regex host patterns; Kiro documents these forweb_fetchonly —web_searchhas no domain-trust surface)Example:
{ "permission": { "bash": { "git *": "allow" } }, "kiro": { "toolsSettings": { "shell": { "autoAllowReadonly": true }, "aws": { "allowedServices": ["s3"], "deniedServices": ["eks"] }, "web_fetch": { "trusted": [".*github\\.com.*"] } } } }Behavior
toolsSettingskey (override wins at the leaf), so authoringshell.autoAllowReadonlykeeps the canonical-generatedshell.allowedCommands. Non-canonicalshellflags already present in the file are preserved across regenerate even without an override (previously a regenerate clobbered the wholeshellobject). Prototype-pollution keys are guarded before being used as object keys.kirooverride so they round-trip and become authorable; the canonicalshell.{allowed,denied}Commands,read/write/grep/globpaths, andweb_fetch/web_searchallowedToolstoggles are unchanged.looseObjectat every level, so future KirotoolsSettingsfields pass through verbatim.Primary-source verification
All shapes were verified against Kiro's official docs (rendered via a browser since kiro.dev is a SPA):
awsservices &web_fetchtrusted/blocked: https://kiro.dev/docs/cli/reference/built-in-tools/Notable corrections vs. the issue's inferred shapes: the web domain arrays are regex patterns, not plain domains, and exist for
web_fetchonly.Design decision (out of scope, deferred)
Kiro's MCP
autoApprove/disabledToolslists — listed among the issue's proposed override keys — are not modeled here. They live in a separate file (.kiro/settings/mcp.json, undermcpServers.<name>), not the agent config this translator writes, and reconciling them with the canonicalmcp__*allow/ask/deny model is a distinct design question (also flagged by the maintainer on the issue). Bundling a second-file write into the permissions override would be scope creep; it can be re-filed as its own focused issue.Tests & docs
New tests cover authoring from the override, extraction on import, omission when absent, shell-flag preservation across regenerate, and a full round-trip.
docs/reference/file-formats.md(+ syncedskills/rulesync/) gains a "Kiro-only override" note including the MCP out-of-scope rationale.Closes #2132
🤖 Generated with Claude Code