Skip to content

Commit 1c43b8d

Browse files
committed
Show warning regardless of case
1 parent dc84199 commit 1c43b8d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalTool.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ const telemetryIgnoredSequences = [
119119
'\x1b[O', // Focus out
120120
];
121121

122-
const promptInjectionWarningCommands = [
122+
const promptInjectionWarningCommandsLower = [
123123
'curl',
124124
'wget',
125125
];
126-
const promptInjectionWarningCommandsPwshOnly = [
127-
'Invoke-RestMethod',
128-
'Invoke-WebRequest',
126+
const promptInjectionWarningCommandsLowerPwshOnly = [
127+
'invoke-restmethod',
128+
'invoke-webrequest',
129129
'irm',
130130
'iwr',
131131
];
@@ -247,10 +247,10 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
247247
// Add a disclaimer warning about prompt injection for common commands that return
248248
// content from the web
249249
let disclaimer: IMarkdownString | undefined;
250-
const subCommandsFirstWordOnly = subCommands.map(command => command.split(' ')[0]);
250+
const subCommandsLowerFirstWordOnly = subCommands.map(command => command.split(' ')[0].toLowerCase());
251251
if (!isAutoApproved && (
252-
subCommandsFirstWordOnly.some(command => promptInjectionWarningCommands.includes(command)) ||
253-
(isPowerShell(shell, os) && subCommandsFirstWordOnly.some(command => promptInjectionWarningCommandsPwshOnly.includes(command)))
252+
subCommandsLowerFirstWordOnly.some(command => promptInjectionWarningCommandsLower.includes(command)) ||
253+
(isPowerShell(shell, os) && subCommandsLowerFirstWordOnly.some(command => promptInjectionWarningCommandsLowerPwshOnly.includes(command)))
254254
)) {
255255
disclaimer = new MarkdownString(`$(${Codicon.info.id}) ` + localize('runInTerminal.promptInjectionDisclaimer', 'Web content may contain malicious code or attempt prompt injection attacks.'), { supportThemeIcons: true });
256256
}

0 commit comments

Comments
 (0)