Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions hooks/bounded-process.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export type HookNetworkAccess = "deny" | "allow";

export interface BoundedProcessOptions {
cwd?: string;
env?: NodeJS.ProcessEnv;
/** Extra non-sensitive names to forward; loader and credential-like names are rejected. */
envAllowlist?: readonly string[];
input?: string | Uint8Array;
timeoutMs?: number;
maxInputBytes?: number;
maxStdoutBytes?: number;
maxStderrBytes?: number;
network?: HookNetworkAccess;
/** Override the platform containment binary path, primarily for deterministic validation. */
containmentExecutable?: string;
}

export interface BoundedProcessResult {
exitCode: number | null;
signal: NodeJS.Signals | null;
stdout: string;
stderr: string;
timedOut: boolean;
error: string | null;
}

export const DEFAULT_MAX_INPUT_BYTES: number;
export const DEFAULT_MAX_STDOUT_BYTES: number;
export const DEFAULT_MAX_STDERR_BYTES: number;
export const DEFAULT_TIMEOUT_MS: number;

export function readBoundedStdin(maxBytes?: number): string;
export function runBoundedProcess(argv: string[], options?: BoundedProcessOptions): Promise<BoundedProcessResult>;
Loading