-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix(cli): harden ask and plan modes #9556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
eae081a
fix(cli): harden ask and plan permissions
alex-alecu 2277e3d
fix(cli): prevent ask plan permission bypass
alex-alecu 2f8f6a2
fix(cli): inline ask plan permission guards
alex-alecu b873691
fix(cli): deny sort output flag
alex-alecu 3732e95
fix(cli): deny shell operators
alex-alecu e02deb7
merge main
alex-alecu d15da9c
chore: fix checks after main merge
alex-alecu 7c12e06
fix(cli): block shell separators
alex-alecu 281bb5d
Merge branch 'main' into fix/kimi-ask-n-plan-edits
alex-alecu 0556e68
Merge branch 'main' into fix/kimi-ask-n-plan-edits
alex-alecu a35905c
Merge branch 'main' into fix/kimi-ask-n-plan-edits
alex-alecu 4b24254
Merge branch 'main' into fix/kimi-ask-n-plan-edits
alex-alecu 00cb019
Merge branch 'main' into fix/kimi-ask-n-plan-edits
alex-alecu f57c65a
refactor(cli): share mode list
alex-alecu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@kilocode/cli": patch | ||
| --- | ||
|
|
||
| Prevent Ask and Plan modes, including saved or allow-all approvals, from editing files before an explicit implementation step. |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { Session } from "@/session" | |
| import { Flag } from "@/flag/flag" | ||
| import { PlanFollowup } from "@/kilocode/plan-followup" | ||
| import { KiloSession } from "@/kilocode/session" | ||
| import { Permission } from "@/permission" | ||
| import { environmentDetails, type EditorContext } from "@/kilocode/editor-context" | ||
| import { Identifier } from "@/id/id" | ||
| import { Filesystem } from "@/util" | ||
|
|
@@ -54,6 +55,20 @@ export namespace KiloSessionPrompt { | |
| return PlanFollowup.abort(sessionID) | ||
| } | ||
|
|
||
| export function guardPermissions(input: { | ||
| agent: { name: string; permission: Permission.Ruleset } | ||
| session: Pick<Session.Info, "permission"> | ||
| }) { | ||
| const rules = input.session.permission ?? [] | ||
| if (!["ask", "plan"].includes(input.agent.name)) return rules | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider moving this to a const at the top, and use it here and in hardPermissions()
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in f57c65a. |
||
| return Permission.merge(rules, input.agent.permission, rules.filter((rule) => rule.action === "deny")) | ||
| } | ||
|
|
||
| export function hardPermissions(input: { agent: { name: string; permission: Permission.Ruleset } }) { | ||
| if (!["ask", "plan"].includes(input.agent.name)) return | ||
| return input.agent.permission | ||
| } | ||
|
|
||
| /** | ||
| * Mutable cache for environment details, keyed by user message ID | ||
| * so it recomputes when a new user message arrives. | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.