feat(sandbox): Add SANDBOX_FLAGS for custom container options (#2036)

Co-authored-by: matt korwel <matt.korwel@gmail.com>
This commit is contained in:
andrea-berling
2025-08-01 18:32:44 +02:00
committed by GitHub
parent d42e3f1e7f
commit c725e258c6
2 changed files with 27 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ import os from 'node:os';
import path from 'node:path';
import fs from 'node:fs';
import { readFile } from 'node:fs/promises';
import { quote } from 'shell-quote';
import { quote, parse } from 'shell-quote';
import {
USER_SETTINGS_DIR,
SETTINGS_DIRECTORY_NAME,
@@ -399,6 +399,14 @@ export async function start_sandbox(
// run init binary inside container to forward signals & reap zombies
const args = ['run', '-i', '--rm', '--init', '--workdir', containerWorkdir];
// add custom flags from SANDBOX_FLAGS
if (process.env.SANDBOX_FLAGS) {
const flags = parse(process.env.SANDBOX_FLAGS, process.env).filter(
(f): f is string => typeof f === 'string',
);
args.push(...flags);
}
// add TTY only if stdin is TTY as well, i.e. for piped input don't init TTY in container
if (process.stdin.isTTY) {
args.push('-t');