mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
Adds shell command allowlist (#68)
* Wire through passthrough commands * Add default passthrough commands * Clean up config passing to useGeminiStream
This commit is contained in:
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user