Re-enable backticks in shell tool usage. (#3360)
This commit is contained in:
parent
48ebd728b3
commit
17dfa267d5
|
@ -350,17 +350,14 @@ describe('ShellTool', () => {
|
|||
expect(result.allowed).toBe(true);
|
||||
});
|
||||
|
||||
it('should block a command with command substitution using backticks', async () => {
|
||||
it('should allow a command with command substitution using backticks', async () => {
|
||||
const config = {
|
||||
getCoreTools: () => ['run_shell_command(echo)'],
|
||||
getExcludeTools: () => [],
|
||||
} as unknown as Config;
|
||||
const shellTool = new ShellTool(config);
|
||||
const result = shellTool.isCommandAllowed('echo `rm -rf /`');
|
||||
expect(result.allowed).toBe(false);
|
||||
expect(result.reason).toBe(
|
||||
'Command substitution using backticks is not allowed for security reasons',
|
||||
);
|
||||
expect(result.allowed).toBe(true);
|
||||
});
|
||||
|
||||
it('should block a command with command substitution using $()', async () => {
|
||||
|
|
|
@ -123,13 +123,6 @@ Process Group PGID: Process group started or \`(none)\``,
|
|||
'Command substitution using $() is not allowed for security reasons',
|
||||
};
|
||||
}
|
||||
if (command.includes('`')) {
|
||||
return {
|
||||
allowed: false,
|
||||
reason:
|
||||
'Command substitution using backticks is not allowed for security reasons',
|
||||
};
|
||||
}
|
||||
|
||||
const SHELL_TOOL_NAMES = [ShellTool.name, ShellTool.Name];
|
||||
|
||||
|
|
Loading…
Reference in New Issue