360 Secure SkillHub
360 安全技能中心

Code Executor

这是一款沙箱化代码执行工具,核心支持Python、JavaScript等多语言,通过网络与文件系统隔离保障安全,可配置CPU、内存、执行超时等资源限制。典型用于运行代码片段、预部署测试、安全执行不可信代码等场景。输入可通过命令行指定语言、代码片段/文件,支持传入输入参数;输出为标准JSON,包含执行状态、输出内容等信息。

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

安装技能

复制下面的话术发给你的 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