Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/auto-unanalyzable-command-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

Stop blocking Bash commands that cannot be statically analyzed in auto permission mode.
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,7 @@ export class DangerousCommandAskPermissionPolicyService implements PermissionPol
}
return { kind: 'ask', reason: { dangerous_command: verdict.command } };
}
if (auto) {
return {
kind: 'deny',
reason: { unanalyzable_command: true },
message:
'This Bash command could not be analyzed and is blocked in auto permission mode. Rewrite it with a literal command name and arguments, or ask the user to run it themselves.',
};
}
if (auto) return undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Continue scanning after an unanalyzable command

In auto mode, a command list such as $CMD --force; shutdown is now approved: analyzeSource returns immediately on the first command's unanalyzable verdict, this line abstains, and the next policy (auto-mode-approve) approves the entire Bash invocation without inspecting the known-dangerous shutdown. Preserve the unanalyzable verdict while scanning the remaining commands and prioritize any dangerous verdict before allowing the policy chain to continue.

Useful? React with 👍 / 👎.

return { kind: 'ask', reason: { unanalyzable_command: true } };
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,16 @@ describe('AgentPermissionPolicyService chain', () => {
});

it.each(['$CMD --force', 'bash -c "echo $HOME"', 'env $FLAGS'])(
'denies unanalyzable command `%s` in auto mode',
'approves unanalyzable command `%s` in auto mode',
async (command) => {
mode = 'auto';

await expect(evaluate({
toolName: 'Bash',
args: { command, timeout: 60 },
})).resolves.toMatchObject({
policyName: 'dangerous-command-ask',
result: { kind: 'deny', reason: { unanalyzable_command: true } },
policyName: 'auto-mode-approve',
result: { kind: 'approve' },
});
},
);
Expand Down
Loading