feat(allowlist): require HTTPS and validate redirects, block on policy failure (#12619)

Co-authored-by: Jasper Hugo <jasper@spiral.xyz>
This commit is contained in:
Abhijay Jain
2026-10-24 12:41:47 +00:00
committed by GitHub
parent c3bfc5f7b0
commit 0276d567aa
23 changed files with 535 additions and 40 deletions
+1 -1
View File
@@ -169,7 +169,7 @@ const mockElectron = {
on: vi.fn(),
off: vi.fn(),
reactReady: vi.fn(),
getAllowedExtensions: vi.fn().mockResolvedValue([]),
getAllowedExtensions: vi.fn().mockResolvedValue(null),
platform: 'darwin',
createChatWindow: vi.fn(),
getSetting: vi.fn().mockResolvedValue(null),
+231
View File
@@ -0,0 +1,231 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { EventEmitter } from 'events';
import type { IncomingMessage, ClientRequest, RequestOptions } from 'node:http';
type GetFn = (
url: string | URL,
options: RequestOptions,
cb: (res: IncomingMessage) => void
) => ClientRequest;
const { mockHttpsGet } = vi.hoisted(() => ({ mockHttpsGet: vi.fn<GetFn>() }));
vi.mock('node:https', () => ({
default: { get: mockHttpsGet },
}));
import { fetchAllowlistContent, parseAllowlistCommands } from './allowlistFetcher';
type MockResponse = EventEmitter & {
statusCode: number;
headers: Record<string, string>;
setEncoding: ReturnType<typeof vi.fn>;
resume: ReturnType<typeof vi.fn>;
};
function mockResponse(statusCode: number, headers: Record<string, string> = {}): MockResponse {
const res = new EventEmitter() as MockResponse;
res.statusCode = statusCode;
res.headers = headers;
res.setEncoding = vi.fn();
res.resume = vi.fn();
return res;
}
function mockRequest(): EventEmitter {
return new EventEmitter();
}
describe('fetchAllowlistContent', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('rejects an HTTP initial URL without making a network request', async () => {
await expect(fetchAllowlistContent('http://example.com/policy.yaml')).rejects.toThrow(
'GOOSE_ALLOWLIST must use HTTPS'
);
expect(mockHttpsGet).not.toHaveBeenCalled();
});
it('rejects a redirect to HTTP before contacting the redirect target', async () => {
const req = mockRequest();
mockHttpsGet.mockImplementation((_url, _options, cb) => {
const res = mockResponse(301, { location: 'http://evil.com/policy.yaml' });
cb(res as unknown as IncomingMessage);
return req as unknown as ClientRequest;
});
await expect(fetchAllowlistContent('https://example.com/policy.yaml')).rejects.toThrow(
'GOOSE_ALLOWLIST must use HTTPS'
);
expect(mockHttpsGet).toHaveBeenCalledTimes(1);
expect(mockHttpsGet).toHaveBeenCalledWith(
'https://example.com/policy.yaml',
expect.objectContaining({ signal: expect.any(AbortSignal) }),
expect.any(Function)
);
});
it('returns body content for a valid HTTPS 200 response', async () => {
const req = mockRequest();
mockHttpsGet.mockImplementation((_url, options, cb) => {
expect(options.headers).toEqual({ 'accept-encoding': 'identity' });
const res = mockResponse(200);
cb(res as unknown as IncomingMessage);
setTimeout(() => {
res.emit('data', 'extensions:\n');
res.emit('data', ' - id: x\n command: npx x\n');
res.emit('end');
}, 0);
return req as unknown as ClientRequest;
});
const content = await fetchAllowlistContent('https://example.com/policy.yaml');
expect(content).toContain('extensions:');
expect(content).toContain('npx x');
});
it('propagates certificate and network errors', async () => {
const req = mockRequest();
mockHttpsGet.mockImplementation((_url, _options, _cb) => {
setTimeout(() => req.emit('error', new Error('certificate has expired')), 0);
return req as unknown as ClientRequest;
});
await expect(fetchAllowlistContent('https://example.com/policy.yaml')).rejects.toThrow(
'certificate has expired'
);
});
it('aborts the active request after a terminal response', async () => {
const req = mockRequest();
const res = mockResponse(404);
let signal: AbortSignal | undefined;
mockHttpsGet.mockImplementation((_url, options, cb) => {
signal = options.signal as AbortSignal;
setTimeout(() => cb(res as unknown as IncomingMessage), 0);
return req as unknown as ClientRequest;
});
await expect(fetchAllowlistContent('https://example.com/policy.yaml')).rejects.toThrow(
'Allowlist fetch failed: HTTP 404'
);
expect(signal?.aborted).toBe(true);
});
it('follows HTTPS-to-HTTPS redirects and aborts remaining streams', async () => {
let callCount = 0;
let signal: AbortSignal | undefined;
mockHttpsGet.mockImplementation((_url, options, cb) => {
signal = options.signal as AbortSignal;
const req = mockRequest();
callCount++;
if (callCount === 1) {
const res = mockResponse(301, { location: 'https://cdn.example.com/policy.yaml' });
cb(res as unknown as IncomingMessage);
} else {
const res = mockResponse(200);
cb(res as unknown as IncomingMessage);
setTimeout(() => {
res.emit('data', 'extensions: []');
res.emit('end');
}, 0);
}
return req as unknown as ClientRequest;
});
const content = await fetchAllowlistContent('https://example.com/policy.yaml');
expect(content).toBe('extensions: []');
expect(signal?.aborted).toBe(true);
expect(mockHttpsGet).toHaveBeenCalledTimes(2);
expect(mockHttpsGet).toHaveBeenNthCalledWith(
2,
'https://cdn.example.com/policy.yaml',
expect.objectContaining({ signal: expect.any(AbortSignal) }),
expect.any(Function)
);
});
it('rejects a malformed redirect URL', async () => {
const req = mockRequest();
const res = mockResponse(301, { location: 'http://[' });
mockHttpsGet.mockImplementation((_url, _options, cb) => {
setTimeout(() => cb(res as unknown as IncomingMessage), 0);
return req as unknown as ClientRequest;
});
await expect(fetchAllowlistContent('https://example.com/policy.yaml')).rejects.toThrow(
'Invalid allowlist redirect URL'
);
expect(mockHttpsGet).toHaveBeenCalledTimes(1);
expect(res.resume).toHaveBeenCalledOnce();
});
it('rejects after too many redirects', async () => {
mockHttpsGet.mockImplementation((_url, _options, cb) => {
const req = mockRequest();
const res = mockResponse(301, { location: 'https://example.com/loop' });
cb(res as unknown as IncomingMessage);
return req as unknown as ClientRequest;
});
await expect(fetchAllowlistContent('https://example.com/policy.yaml')).rejects.toThrow(
'Too many redirects'
);
});
it('aborts when the total fetch duration expires', async () => {
vi.useFakeTimers();
try {
const req = mockRequest();
let signal: AbortSignal | undefined;
mockHttpsGet.mockImplementation((_url, options, _cb) => {
signal = options.signal as AbortSignal;
return req as unknown as ClientRequest;
});
const rejection = expect(
fetchAllowlistContent('https://example.com/policy.yaml')
).rejects.toThrow('Allowlist fetch timed out');
await vi.advanceTimersByTimeAsync(30_000);
await rejection;
expect(signal?.aborted).toBe(true);
} finally {
vi.useRealTimers();
}
});
it('rejects when https.get throws synchronously', async () => {
mockHttpsGet.mockImplementation(() => {
throw new Error('Invalid URI');
});
await expect(fetchAllowlistContent('https://example.com/policy.yaml')).rejects.toThrow(
'Invalid URI'
);
});
});
describe('parseAllowlistCommands', () => {
it('returns commands from a valid policy', () => {
expect(
parseAllowlistCommands('extensions:\n - id: example\n command: npx example\n')
).toEqual(['npx example']);
});
it('preserves a configured empty policy as deny-all', () => {
expect(parseAllowlistCommands('extensions: []')).toEqual([]);
});
it.each([
['', 'expected an extensions array'],
['name: login-page', 'expected an extensions array'],
['extensions: invalid', 'expected an extensions array'],
['extensions:\n - id: missing-command', 'requires a command'],
['extensions:\n - command: ""', 'requires a command'],
])('rejects an invalid policy', (content, message) => {
expect(() => parseAllowlistCommands(content)).toThrow(message);
});
});
+120
View File
@@ -0,0 +1,120 @@
import https from 'node:https';
import * as yaml from 'yaml';
const ALLOWLIST_FETCH_TIMEOUT_MS = 30_000;
export function parseAllowlistCommands(content: string): string[] {
const parsed: unknown = yaml.parse(content);
if (
!parsed ||
typeof parsed !== 'object' ||
!Array.isArray((parsed as { extensions?: unknown }).extensions)
) {
throw new Error('Invalid GOOSE_ALLOWLIST policy: expected an extensions array');
}
return (parsed as { extensions: unknown[] }).extensions.map((extension, index) => {
if (
!extension ||
typeof extension !== 'object' ||
typeof (extension as { command?: unknown }).command !== 'string' ||
(extension as { command: string }).command.trim() === ''
) {
throw new Error(`Invalid GOOSE_ALLOWLIST policy: extension ${index} requires a command`);
}
return (extension as { command: string }).command;
});
}
export function fetchAllowlistContent(url: string): Promise<string> {
return new Promise((resolve, reject) => {
const controller = new AbortController();
let settled = false;
const finishResolve = (content: string) => {
if (settled) return;
settled = true;
clearTimeout(timeout);
resolve(content);
controller.abort();
};
const finishReject = (error: Error) => {
if (settled) return;
settled = true;
clearTimeout(timeout);
reject(error);
controller.abort();
};
const timeout = setTimeout(() => {
finishReject(new Error('Allowlist fetch timed out'));
}, ALLOWLIST_FETCH_TIMEOUT_MS);
const follow = (currentUrl: string, depth: number) => {
if (settled) return;
if (depth > 10) {
finishReject(new Error('Too many redirects fetching allowlist'));
return;
}
let parsed: URL;
try {
parsed = new URL(currentUrl);
} catch {
finishReject(new Error(`Invalid allowlist URL: ${currentUrl}`));
return;
}
if (parsed.protocol !== 'https:') {
finishReject(new Error(`GOOSE_ALLOWLIST must use HTTPS: ${currentUrl}`));
return;
}
try {
https
.get(
currentUrl,
{ signal: controller.signal, headers: { 'accept-encoding': 'identity' } },
(res) => {
if (settled) {
res.resume();
return;
}
const { statusCode } = res;
if (statusCode && statusCode >= 300 && statusCode < 400) {
const location = res.headers.location;
if (!location) {
finishReject(new Error('Allowlist redirect missing Location header'));
return;
}
res.resume();
let redirectUrl: string;
try {
redirectUrl = new URL(location, currentUrl).href;
} catch {
finishReject(new Error(`Invalid allowlist redirect URL: ${location}`));
return;
}
follow(redirectUrl, depth + 1);
} else if (statusCode && statusCode >= 200 && statusCode < 300) {
let data = '';
res.setEncoding('utf8');
res.on('data', (chunk: string) => {
if (!settled) data += chunk;
});
res.on('end', () => finishResolve(data));
res.on('error', finishReject);
} else {
res.resume();
finishReject(new Error(`Allowlist fetch failed: HTTP ${statusCode}`));
}
}
)
.on('error', finishReject);
} catch (error) {
finishReject(error instanceof Error ? error : new Error(String(error)));
}
};
follow(url, 0);
});
}
@@ -53,9 +53,11 @@ describe('ExtensionInstallModal', () => {
describe('Extension Request Handling', () => {
it('should handle trusted extension (default behaviour, no allowlist)', async () => {
mockElectron.getAllowedExtensions.mockResolvedValue([]);
mockElectron.getAllowedExtensions.mockResolvedValue(null);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(
<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />
);
const eventHandler = getAddExtensionEventHandler();
@@ -72,7 +74,9 @@ describe('ExtensionInstallModal', () => {
it('should handle trusted extension (from allowlist)', async () => {
mockElectron.getAllowedExtensions.mockResolvedValue(['npx test-extension']);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(
<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />
);
const eventHandler = getAddExtensionEventHandler();
@@ -90,7 +94,9 @@ describe('ExtensionInstallModal', () => {
});
mockElectron.getAllowedExtensions.mockResolvedValue(['uvx allowed-package']);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(
<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />
);
const eventHandler = getAddExtensionEventHandler();
@@ -109,7 +115,9 @@ describe('ExtensionInstallModal', () => {
it('should handle blocked extension', async () => {
mockElectron.getAllowedExtensions.mockResolvedValue(['uvx allowed-package']);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(
<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />
);
const eventHandler = getAddExtensionEventHandler();
@@ -122,13 +130,53 @@ describe('ExtensionInstallModal', () => {
expect(screen.getAllByRole('button')).toHaveLength(2);
expect(screen.getByText(/Contact your administrator/)).toBeInTheDocument();
});
it('should block every extension when the configured allowlist is empty', async () => {
mockElectron.getAllowedExtensions.mockResolvedValue([]);
renderWithIntl(
<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />
);
const eventHandler = getAddExtensionEventHandler();
await act(async () => {
await eventHandler({}, 'goose://extension?cmd=npx&arg=blocked-extension&name=BlockedExt');
});
expect(screen.getByText('Extension Installation Blocked')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'OK' })).toBeInTheDocument();
});
it('should block installation and show policy error when allowlist fetch fails', async () => {
mockElectron.getAllowedExtensions.mockRejectedValue(
new Error('GOOSE_ALLOWLIST must use HTTPS: http://example.com/policy.yaml')
);
renderWithIntl(
<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />
);
const eventHandler = getAddExtensionEventHandler();
await act(async () => {
await eventHandler({}, 'goose://extension?cmd=npx&arg=some-extension&name=SomeExt');
});
expect(screen.getByText('Extension Policy Unavailable')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'OK' })).toBeInTheDocument();
expect(screen.getAllByRole('button')).toHaveLength(2);
expect(screen.getByText(/allowlist policy could not be retrieved/)).toBeInTheDocument();
});
});
describe('Modal Actions', () => {
it('should dismiss modal correctly', async () => {
mockElectron.getAllowedExtensions.mockResolvedValue([]);
mockElectron.getAllowedExtensions.mockResolvedValue(null);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(
<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />
);
const eventHandler = getAddExtensionEventHandler();
@@ -147,9 +195,11 @@ describe('ExtensionInstallModal', () => {
it('should handle successful extension installation', async () => {
vi.mocked(addExtensionFromDeepLink).mockResolvedValue(undefined);
mockElectron.getAllowedExtensions.mockResolvedValue([]);
mockElectron.getAllowedExtensions.mockResolvedValue(null);
renderWithIntl(<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />);
renderWithIntl(
<ExtensionInstallModal addExtension={mockAddExtension} setView={mockSetView} />
);
const eventHandler = getAddExtensionEventHandler();
@@ -36,6 +36,15 @@ const i18n = defineMessages({
id: 'extensionInstallModal.ok',
defaultMessage: 'OK',
},
policyErrorTitle: {
id: 'extensionInstallModal.policyErrorTitle',
defaultMessage: 'Extension Policy Unavailable',
},
policyErrorMessage: {
id: 'extensionInstallModal.policyErrorMessage',
defaultMessage:
'The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available.\n\nContact your administrator to check the GOOSE_ALLOWLIST configuration.',
},
untrustedTitle: {
id: 'extensionInstallModal.untrustedTitle',
defaultMessage: 'Install Untrusted Extension?',
@@ -94,7 +103,7 @@ const i18n = defineMessages({
},
});
type ModalType = 'blocked' | 'untrusted' | 'trusted';
type ModalType = 'blocked' | 'untrusted' | 'trusted' | 'policy-error';
interface ExtensionInfo {
name: string;
@@ -179,7 +188,7 @@ export function ExtensionInstallModal({ addExtension, setView }: ExtensionInstal
const allowedCommands = await window.electron.getAllowedExtensions();
if (!allowedCommands || allowedCommands.length === 0) {
if (allowedCommands === null) {
return 'trusted';
}
@@ -190,7 +199,7 @@ export function ExtensionInstallModal({ addExtension, setView }: ExtensionInstal
return isCommandAllowed ? 'trusted' : 'blocked';
} catch (error) {
console.error('Error checking allowlist:', error);
return 'trusted';
return 'policy-error';
}
};
@@ -237,6 +246,16 @@ export function ExtensionInstallModal({ addExtension, setView }: ExtensionInstal
};
}
case 'policy-error':
return {
title: intl.formatMessage(i18n.policyErrorTitle),
message: '\n\n' + intl.formatMessage(i18n.policyErrorMessage),
confirmLabel: intl.formatMessage(i18n.ok),
cancelLabel: '',
showSingleButton: true,
isBlocked: true,
};
case 'trusted':
default:
return {
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "OK"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "Möchten Sie die Erweiterung {name} wirklich installieren? Befehl: {command}"
},
+6
View File
@@ -1100,6 +1100,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "OK"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "Are you sure you want to install the {name} extension? Command: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "OK"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "¿Seguro que quieres instalar la extensión {name}? Comando: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "OK"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "Voulez-vous vraiment installer l'extension {name} ? Commande : {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "ठीक है"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "क्या आप वाकई {name} एक्सटेंशन इंस्टॉल करना चाहते हैं? आदेश: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "OK"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "Apakah Anda yakin ingin memasang ekstensi {name}? Perintah: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "OK"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "Vuoi davvero installare l'estensione {name}? Comando: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "OK"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "{name}拡張機能をインストールしてもよろしいですか?コマンド: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "확인"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "{name} 익스텐션을 설치하시겠습니까? 명령: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "OK"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "Adakah anda pasti mahu memasang sambungan {name}? Arahan: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "OK"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "Tem certeza de que deseja instalar a extensão {name}? Comando: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "OK"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "Установить расширение {name}? Команда: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "tamam"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "{name} uzantısını yüklemek istediğinizden emin misiniz? Komut: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "OK"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "Bạn có chắc chắn muốn cài đặt tiện ích mở rộng {name} không? Lệnh: {command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "确定"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "确定要安装 {name} 扩展吗?命令:{command}"
},
+6
View File
@@ -1091,6 +1091,12 @@
"extensionInstallModal.ok": {
"defaultMessage": "確定"
},
"extensionInstallModal.policyErrorMessage": {
"defaultMessage": "The extension allowlist policy could not be retrieved. Extension installation is blocked until the policy is available. Contact your administrator to check the GOOSE_ALLOWLIST configuration."
},
"extensionInstallModal.policyErrorTitle": {
"defaultMessage": "Extension Policy Unavailable"
},
"extensionInstallModal.trustedMessage": {
"defaultMessage": "您確定要安裝 {name} 擴充功能嗎?命令:{command}"
},
+5 -26
View File
@@ -18,6 +18,7 @@ import {
Tray,
} from 'electron';
import { pathToFileURL, format as formatUrl, URLSearchParams } from 'node:url';
import { fetchAllowlistContent, parseAllowlistCommands } from './allowlistFetcher';
import { Buffer } from 'node:buffer';
import fs from 'node:fs/promises';
import fsSync from 'node:fs';
@@ -42,7 +43,6 @@ import { isRetiredGooseChatApp } from './utils/retiredApps';
import type { Settings, SettingKey } from './utils/settings';
import { defaultSettings, getKeyboardShortcuts } from './utils/settings';
import * as crypto from 'crypto';
import * as yaml from 'yaml';
import windowStateKeeper from 'electron-window-state';
import {
getUpdateAvailable,
@@ -3078,34 +3078,13 @@ app.whenReady().then(async () => {
}
});
async function getAllowList(): Promise<string[]> {
async function getAllowList(): Promise<string[] | null> {
if (!process.env.GOOSE_ALLOWLIST) {
return [];
return null;
}
const response = await fetch(process.env.GOOSE_ALLOWLIST);
if (!response.ok) {
throw new Error(
`Failed to fetch allowed extensions: ${response.status} ${response.statusText}`
);
}
// Parse the YAML content
const yamlContent = await response.text();
const parsedYaml = yaml.parse(yamlContent);
// Extract the commands from the extensions array
if (parsedYaml && parsedYaml.extensions && Array.isArray(parsedYaml.extensions)) {
const commands = parsedYaml.extensions.map(
(ext: { id: string; command: string }) => ext.command
);
console.log(`Fetched ${commands.length} allowed extension commands`);
return commands;
} else {
console.error('Invalid YAML structure:', parsedYaml);
return [];
}
const yamlContent = await fetchAllowlistContent(process.env.GOOSE_ALLOWLIST);
return parseAllowlistCommands(yamlContent);
}
app.on('will-quit', async () => {
+1 -1
View File
@@ -124,7 +124,7 @@ type ElectronAPI = {
writeFile: (directory: string, content: string) => Promise<boolean>;
ensureDirectory: (dirPath: string) => Promise<boolean>;
listFiles: (dirPath: string, extension?: string) => Promise<string[]>;
getAllowedExtensions: () => Promise<string[]>;
getAllowedExtensions: () => Promise<string[] | null>;
getPathForFile: (file: File) => string;
setMenuBarIcon: (show: boolean) => Promise<boolean>;
getMenuBarIconState: () => Promise<boolean>;