Skip to content

Commit 3044028

Browse files
committed
Add workspace trust checks to agentic search and CLI invocation
- Update `agentic-search.ts` and `invoke-agentic-cli.ts` to enforce VS Code Workspace Trust by checking `vscode.workspace.isTrusted`, preventing execution vulnerabilities that trigger when using the 'Search' feature in a malicious repository. - translate newly introduced warning strings [Changes] └── apps └── editor └── src ├── commands │ └── agentic-search-command │ └── agentic-search-command.ts ├── features │ └── agentic-search │ ├── agentic-search.ts │ └── index.ts ├── i18n │ ├── index.ts │ └── translations │ ├── features │ │ ├── agentic-search.ts │ │ └── index.ts │ ├── utils │ │ ├── agentic-cli-invocation.ts │ │ └── index.ts │ └── views │ └── prompt │ └── handlers │ ├── handle-agentic-search.ts │ └── handle-invoke-agentic-cli.ts ├── utils │ └── agentic-cli-invocation │ ├── index.ts │ └── invoke-agentic-cli.ts └── views └── prompt └── backend └── message-handlers ├── handle-agentic-search.ts └── handle-invoke-agentic-cli.ts
1 parent 8111071 commit 3044028

5 files changed

Lines changed: 57 additions & 1 deletion

File tree

‎apps/editor/src/features/agentic-search/agentic-search.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ export const agentic_search = async (params: {
2929
| undefined
3030
| 'back'
3131
> => {
32+
if (!vscode.workspace.isTrusted) {
33+
vscode.window.showWarningMessage(
34+
t('features.agentic-search.error.workspace-not-trusted')
35+
)
36+
return undefined
37+
}
38+
3239
const roots = params.workspace_provider.get_workspace_roots()
3340

3441
if (roots.length == 0) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const translations = {
2+
'features.agentic-search.error.workspace-not-trusted': {
3+
en: 'Workspace is not trusted. Agentic search is disabled.',
4+
pl: 'Obszar roboczy nie jest zaufany. Wyszukiwanie agentowe jest wyłączone.',
5+
'zh-cn': '工作区不受信任。智能体搜索已被禁用。',
6+
ja: 'ワークスペースは信頼されていません。エージェント検索は無効になっています。',
7+
'zh-tw': '工作區不受信任。智能體搜尋已被停用。',
8+
de: 'Der Arbeitsbereich ist nicht vertrauenswürdig. Die agentische Suche ist deaktiviert.',
9+
es: 'El espacio de trabajo no es de confianza. La búsqueda de agentes está deshabilitada.',
10+
fr: "L'espace de travail n'est pas approuvé. La recherche d'agents est désactivée.",
11+
'pt-br':
12+
'O espaço de trabalho não é confiável. A pesquisa de agentes está desativada.',
13+
ru: 'Рабочая область не является доверенной. Агентный поиск отключен.',
14+
ko: '작업 공간을 신뢰할 수 없습니다. 에이전트 검색이 비활성화되었습니다.',
15+
it: "L'area di lavoro non è attendibile. La ricerca agenti è disabilitata.",
16+
tr: 'Çalışma alanı güvenilir değil. Aracı araması devre dışı bırakıldı.',
17+
cs: 'Pracovní prostor není důvěryhodný. Agentní vyhledávání je zakázáno.',
18+
hu: 'A munkaterület nem megbízható. Az ügynökkeresés le van tiltva.',
19+
bg: 'Работното пространство не е надеждно. Агентното търсене е деактивирано.'
20+
}
21+
} as const
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { translations as search_files } from './search-files'
22
import { translations as checkpoints } from './checkpoints'
33
import { translations as context_restoration } from './context-restoration'
4+
import { translations as agentic_search } from './agentic-search'
45

56
export const translations = {
67
...search_files,
78
...checkpoints,
8-
...context_restoration
9+
...context_restoration,
10+
...agentic_search
911
}

‎apps/editor/src/i18n/translations/utils/agentic-cli-invocation.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,25 @@ export const translations = {
215215
hu: 'A {agent} CLI nincs telepítve ezen a számítógépen.',
216216
bg: 'CLI {agent} не е инсталиран на този компютър.'
217217
},
218+
'utils.agentic-cli-invocation.error.workspace-not-trusted': {
219+
en: 'Workspace is not trusted. Agentic CLI invocation is disabled.',
220+
pl: 'Obszar roboczy nie jest zaufany. Wywoływanie agenta z CLI jest wyłączone.',
221+
'zh-cn': '工作区不受信任。智能体 CLI 调用已被禁用。',
222+
ja: 'ワークスペースは信頼されていません。エージェント CLI の呼び出しは無効になっています。',
223+
'zh-tw': '工作區不受信任。智能體 CLI 呼叫已被停用。',
224+
de: 'Der Arbeitsbereich ist nicht vertrauenswürdig. Der Aufruf der Agenten-CLI ist deaktiviert.',
225+
es: 'El espacio de trabajo no es de confianza. La invocación del CLI del agente está deshabilitada.',
226+
fr: "L'espace de travail n'est pas approuvé. L'invocation du CLI de l'agent est désactivée.",
227+
'pt-br':
228+
'O espaço de trabalho não é confiável. A invocação do CLI do agente está desativada.',
229+
ru: 'Рабочая область не является доверенной. Вызов агентного CLI отключен.',
230+
ko: '작업 공간을 신뢰할 수 없습니다. 에이전트 CLI 호출이 비활성화되었습니다.',
231+
it: "L'area di lavoro non è attendibile. L'invocazione della CLI dell'agente è disabilitata.",
232+
tr: 'Çalışma alanı güvenilir değil. Aracı CLI çağrısı devre dışı bırakıldı.',
233+
cs: 'Pracovní prostor není důvěryhodný. Vyvolání agentního CLI je zakázáno.',
234+
hu: 'A munkaterület nem megbízható. Az ügynök CLI hívása le van tiltva.',
235+
bg: 'Работното пространство не е надеждно. Извикването на агентния CLI е деактивирано.'
236+
},
218237
'utils.agentic-cli-invocation.error.failed': {
219238
en: 'Agent execution failed: {error}',
220239
pl: 'Wykonywanie agenta nie powiodło się: {error}',

‎apps/editor/src/utils/agentic-cli-invocation/invoke-agentic-cli.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ export const invoke_agentic_cli = async (params: {
4545
}): Promise<
4646
{ agent_output: string; selected_root: string } | undefined | 'back'
4747
> => {
48+
if (!vscode.workspace.isTrusted) {
49+
vscode.window.showWarningMessage(
50+
t('utils.agentic-cli-invocation.error.workspace-not-trusted')
51+
)
52+
return undefined
53+
}
54+
4855
const roots = params.workspace_provider.get_workspace_roots()
4956

5057
if (roots.length == 0) {

0 commit comments

Comments
 (0)