summaryrefslogtreecommitdiff
path: root/packages/server
diff options
context:
space:
mode:
authorJuliette Love <[email protected]>2025-04-20 21:06:22 +0100
committerGitHub <[email protected]>2025-04-20 21:06:22 +0100
commita76d9b4dcfa291c182c4fb1320992db448f0285c (patch)
tree02390710cfc6deb73657a1d400f534c93030aaeb /packages/server
parentf480ef4bbcc9dc03b5a9a1e80e5f428038c8d34e (diff)
Adds shell command allowlist (#68)
* Wire through passthrough commands * Add default passthrough commands * Clean up config passing to useGeminiStream
Diffstat (limited to 'packages/server')
-rw-r--r--packages/server/src/config/config.ts19
1 files changed, 18 insertions, 1 deletions
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,
+ );
}