From a76d9b4dcfa291c182c4fb1320992db448f0285c Mon Sep 17 00:00:00 2001 From: Juliette Love Date: Sun, 20 Apr 2025 21:06:22 +0100 Subject: Adds shell command allowlist (#68) * Wire through passthrough commands * Add default passthrough commands * Clean up config passing to useGeminiStream --- packages/server/src/config/config.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'packages/server/src') diff --git a/packages/server/src/config/config.ts b/packages/server/src/config/config.ts index bd698cf6..fad219b5 100644 --- a/packages/server/src/config/config.ts +++ b/packages/server/src/config/config.ts @@ -9,22 +9,28 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import process from 'node:process'; +const DEFAULT_PASSTHROUGH_COMMANDS = ['ls', 'git', 'npm']; + export class Config { private apiKey: string; private model: string; private targetDir: string; private debugMode: boolean; + private passthroughCommands: string[]; constructor( apiKey: string, model: string, targetDir: string, debugMode: boolean, + passthroughCommands?: string[], ) { this.apiKey = apiKey; this.model = model; this.targetDir = targetDir; this.debugMode = debugMode; + this.passthroughCommands = + passthroughCommands || DEFAULT_PASSTHROUGH_COMMANDS; } getApiKey(): string { @@ -42,6 +48,10 @@ export class Config { getDebugMode(): boolean { return this.debugMode; } + + getPassthroughCommands(): string[] { + return this.passthroughCommands; + } } function findEnvFile(startDir: string): string | null { @@ -72,6 +82,13 @@ export function createServerConfig( model: string, targetDir: string, debugMode: boolean, + passthroughCommands?: string[], ): Config { - return new Config(apiKey, model, path.resolve(targetDir), debugMode); + return new Config( + apiKey, + model, + path.resolve(targetDir), + debugMode, + passthroughCommands, + ); } -- cgit v1.2.3