mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat(shell): Include disallowed commands in block reason (#6278)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -38,7 +38,9 @@ describe('isCommandAllowed', () => {
|
|||||||
config.getCoreTools = () => ['ShellTool(ls -l)'];
|
config.getCoreTools = () => ['ShellTool(ls -l)'];
|
||||||
const result = isCommandAllowed('rm -rf /', config);
|
const result = isCommandAllowed('rm -rf /', config);
|
||||||
expect(result.allowed).toBe(false);
|
expect(result.allowed).toBe(false);
|
||||||
expect(result.reason).toBe(`Command(s) not in the allowed commands list.`);
|
expect(result.reason).toBe(
|
||||||
|
`Command(s) not in the allowed commands list. Disallowed commands: "rm -rf /"`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should block a command if it is in the blocked list', () => {
|
it('should block a command if it is in the blocked list', () => {
|
||||||
@@ -157,7 +159,7 @@ describe('checkCommandPermissions', () => {
|
|||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
allAllowed: false,
|
allAllowed: false,
|
||||||
disallowedCommands: ['git status'],
|
disallowedCommands: ['git status'],
|
||||||
blockReason: `Command(s) not in the allowed commands list.`,
|
blockReason: `Command(s) not in the allowed commands list. Disallowed commands: "git status"`,
|
||||||
isHardDenial: false,
|
isHardDenial: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -301,7 +301,9 @@ export function checkCommandPermissions(
|
|||||||
return {
|
return {
|
||||||
allAllowed: false,
|
allAllowed: false,
|
||||||
disallowedCommands,
|
disallowedCommands,
|
||||||
blockReason: `Command(s) not on the global or session allowlist.`,
|
blockReason: `Command(s) not on the global or session allowlist. Disallowed commands: ${disallowedCommands
|
||||||
|
.map((c) => JSON.stringify(c))
|
||||||
|
.join(', ')}`,
|
||||||
isHardDenial: false, // This is a soft denial; confirmation is possible.
|
isHardDenial: false, // This is a soft denial; confirmation is possible.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -322,7 +324,7 @@ export function checkCommandPermissions(
|
|||||||
return {
|
return {
|
||||||
allAllowed: false,
|
allAllowed: false,
|
||||||
disallowedCommands,
|
disallowedCommands,
|
||||||
blockReason: `Command(s) not in the allowed commands list.`,
|
blockReason: `Command(s) not in the allowed commands list. Disallowed commands: ${disallowedCommands.map((c) => JSON.stringify(c)).join(', ')}`,
|
||||||
isHardDenial: false, // This is a soft denial.
|
isHardDenial: false, // This is a soft denial.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user