UNPKG

@specs-feup/clava

Version:

A C/C++ source-to-source compiler written in Typescript

34 lines 1.74 kB
import { ChildProcess } from "child_process"; export default class Sandbox { /** * Executes a command in a restricted environment and returns the output as a string * * **Sanitize the input before calling this method** * * @param command - String containing the command to be executed * @param args - Array of strings containing the arguments to be passed to the command * @param env - Object containing the environment variables to be set for the command * @returns Output of the command as a string */ static executeSandboxedCommand(command: string, args?: string[], env?: Map<string, string>): string; /** * Executes a command in a restricted environment and returns the output as a string * * **Sanitize the input before calling this method** * * @param command - String containing the command to be executed * @param args - Array of strings containing the arguments to be passed to the command * @param env - Object containing environment variables to be set for the child process * @returns Output of the command as a string */ static executeSandboxedCommandAsync(command: string, args?: string[], env?: Record<string, unknown>): ChildProcess; /** * Ensure command string does not contain any characters that could be used * * @param command - String containing the command to be sanitized * @returns The original command or throws an error if invalid */ static sanitizeCommand(command: (string | number)[]): Promise<(string | number)[]>; static splitCommandArgsEnv(commandArgs: (string | number)[]): Promise<[string, (string | number)[], string[]]>; } //# sourceMappingURL=Sandbox.d.ts.map