Skip to content

Sandbox

Execute JavaScript, Python, or shell commands in isolated environments.

3 modules

ModuleDescription
JavaScript 실행타임아웃과 함께 Node.js를 통해 JavaScript 코드를 실행합니다
Python 실행타임아웃과 함께 서브프로세스에서 Python 코드를 실행합니다
쉘 실행타임아웃 및 환경 제어와 함께 쉘 명령을 실행합니다

Modules

JavaScript 실행

sandbox.execute_js

타임아웃과 함께 Node.js를 통해 JavaScript 코드를 실행합니다

Parameters:

NameTypeRequiredDefaultDescription
codestringYes-Node.js를 통해 실행할 JavaScript 코드
timeoutnumberNo10실행 타임아웃(초)

Output:

FieldTypeDescription
stdoutstring스크립트의 표준 출력
stderrstring스크립트의 표준 에러
exit_codenumber프로세스 종료 코드 (0 = 성공)
execution_time_msnumber실행 시간 (밀리초)

Example: Simple console.log

yaml
code: console.log("Hello, World!");
timeout: 10

Example: JSON processing

yaml
code: const data = { name: "test", value: 42 };
console.log(JSON.stringify(data, null, 2));

Python 실행

sandbox.execute_python

타임아웃과 함께 서브프로세스에서 Python 코드를 실행합니다

Parameters:

NameTypeRequiredDefaultDescription
codestringYes-실행할 Python 코드
timeoutnumberNo10실행 타임아웃(초)
allowed_modulesarrayNo-가져올 수 있는 모듈의 화이트리스트 (모두 허용하려면 비워 두세요)

Output:

FieldTypeDescription
stdoutstring스크립트의 표준 출력
stderrstring스크립트의 표준 에러
exit_codenumber프로세스 종료 코드 (0 = 성공)
execution_time_msnumber실행 시간 (밀리초)

Example: Simple print

yaml
code: print("Hello, World!")
timeout: 10

Example: Math calculation

yaml
code: import math
print(math.pi)
allowed_modules: ["math"]

쉘 실행

sandbox.execute_shell

타임아웃 및 환경 제어와 함께 쉘 명령을 실행합니다

Parameters:

NameTypeRequiredDefaultDescription
commandstringYes-실행할 쉘 명령
timeoutnumberNo10실행 타임아웃(초)
working_dirstringNo-명령의 작업 디렉토리
envobjectNo-설정할 추가 환경 변수 (현재 환경과 병합됨)

Output:

FieldTypeDescription
stdoutstring명령의 표준 출력
stderrstring명령의 표준 에러
exit_codenumber프로세스 종료 코드 (0 = 성공)
execution_time_msnumber실행 시간 (밀리초)

Example: Simple echo

yaml
command: echo "Hello, World!"
timeout: 10

Example: List files with custom working directory

yaml
command: ls -la
working_dir: /tmp

Released under the Apache 2.0 License.