360 Secure SkillHub
360 安全技能中心

Code Executor

该 Skill 通过脚本在沙箱环境中执行 Python、JavaScript、Bash、Ruby、Go 等代码片段或文件,支持设置超时、内存和输入输出限制,默认无网络访问,并以 JSON 返回执行结果;但引用的 scripts/execute.py 脚本未包含在文件列表中。

jpengcheng523-netizen
jpengcheng523-netizen
热度 50.16
最近更新 2026-05-11 17:35:58
分类:开发依赖:代码执行 / 读写文件应用场景:调试排错 / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add jpeng-code-executor
Metadata
name
jpeng-code-executor
description
Safe code execution in sandboxed environments. Supports Python, JavaScript, Bash, and more with resource limits and timeout controls.
version
1.0.0
author
jpeng
tags
["code","execution","sandbox","python","javascript"]

Code Executor

Execute code safely in sandboxed environments with resource limits.

When to Use

  • User wants to run code snippets
  • Test code before deployment
  • Execute scripts with security constraints
  • Run untrusted code safely

Features

  • Multi-language support: Python, JavaScript, Bash, Ruby, Go
  • Resource limits: CPU, memory, execution time
  • Network isolation: Optional network access
  • File system isolation: Temporary sandbox directory

Usage

Execute Python

python3 scripts/execute.py \
  --language python \
  --code "print('Hello, World!')" \
  --timeout 10

Execute from file

python3 scripts/execute.py \
  --language python \
  --file ./script.py \
  --timeout 30 \
  --memory 256

Execute JavaScript

python3 scripts/execute.py \
  --language javascript \
  --code "console.log(2 + 2)"

With input

python3 scripts/execute.py \
  --language python \
  --code "x = input(); print(f'You said: {x}')" \
  --input "Hello"

Output

{
  "success": true,
  "stdout": "Hello, World!\n",
  "stderr": "",
  "exit_code": 0,
  "execution_time_ms": 42
}

Safety

  • Default timeout: 30 seconds
  • Default memory limit: 512MB
  • No network access by default
  • Output limited to 1MB