generate-sandbox-policy
它能做什么
这项技能让 AI 把你希望沙盒访问的内容,转换为有效的网络策略文件。适合设置 OpenShell 沙盒、并希望控制允许哪些网站和 API 调用的人。
适用场景
- ✓你想允许沙盒中的 AI 访问某个特定网站或 API 的时候。
- ✓你有 API 文档,并希望把策略限制在某些方法和路径上的时候。
- ✓你需要更改网络中间件如何挂载到沙盒,或其失败时的处理方式的时候。
技能链接
https://github.com/NVIDIA/OpenShell/blob/main/skills/generate-sandbox-policy/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请编写一条沙盒策略,让我的 AI 只能读取 GitHub API,其他一概不允许。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会收集你需要的主机和访问权限,根据你提供的输入选择合适的细节程度,并编写一份符合沙盒策略格式的 YAML 策略,供你审阅。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Generate Sandbox Policy
Generate YAML sandbox network policies and network middleware configuration from API documentation and natural-language user requirements.
Overview
This skill translates a user's plain-language policy intent into a valid sandbox policy. The amount of detail the user provides determines the granularity of the generated policy — from broad L4 or preset-based policies (just a host:port) up to fine-grained per-endpoint L7 rules (full API docs).
The output is a network_policies YAML block, an optional network_middlewares block, and optionally a full policy file that conforms to the sandbox policy schema.
Step 1: Gather Inputs
Determine the Detail Tier
The user's input falls into one of three tiers. Work with whatever the user provides — do not require a higher tier than needed.
| Tier | User provides | What you can generate |
|---|---|---|
| Minimal | Host(s) and plain-language intent | L4-only policies, or L7 with access presets (read-only, read-write, full) |
| Moderate | Host(s) + some known URL paths or resources | L7 with targeted glob rules for known paths, presets for the rest |
| Full | Complete API docs (OpenAPI, Swagger, markdown, URL) | Fine-grained per-endpoint L7 rules with specific method+path combinations |
Minimal Tier (host + intent only)
The user provides API endpoints and a broad intent. No API docs needed.
Examples:
- "Allow curl to hit api.github.com, read-only"
- "Give claude full access to api.anthropic.com"
- "Let /usr/bin/myapp talk to internal-svc:8080 but only for reading"
This is sufficient for:
- L4-only policies (host:port + binary checks, no method or path rules)
- Preset-based L7 policies (
read-only,read-write,fullon all paths)
For this tier, default to:
access: read-onlywhen the user says "read", "browse", "view", "query", "fetch"access: read-writewhen the user says "read-write", "create", "update" (but not "delete")access: fullwhen the user says "full access", "everything", "unrestricted"- L4-only when the user says "just allow it", "pass through", or "no
inspection". Omit
protocolfor explicit-proxy clients. Useprotocol: tcponly when the workload must use native DNS and direct socket calls, the endpoint has a valid DNS hostname, and the selected runtime support (currently Docker and Podman).
Moderate Tier (host + partial path knowledge)
The user knows some API paths but doesn't have full docs.
Examples:
- "Allow GET on /api/v1/models and POST on /api/v1/completions at integrate.api.nvidia.com"
- "Read-only on /repos/** at api.github.com, but also allow POST on /repos///issues"
Generate explicit rules for the known paths. If the user also wants broader access beyond the specific paths, combine with a catch-all rule or suggest a preset instead.
Full Tier (complete API docs)
The user provides full API documentation. Accepted formats:
| Format | How to consume |
|---|---|
| URL | Fetch with the agent's web access and parse the endpoint list |
| File path | Read the file (OpenAPI JSON/YAML, markdown, etc.) |
| Pasted text | Parse inline from the conversation |
| OpenAPI/Swagger spec | Extract paths object for all method+path combinations |
From the API docs, build an endpoint inventory — a list of (method, path, description) tuples. Group them logically (e.g., by resource or tag). Then generate precise rules that allow only what the user's intent requires.
Policy Intent
Regardless of tier, extract (or infer) these from the user's description:
| Aspect | What to identify | Required? |
|---|---|---|
| Scope | Which API host(s) and port(s) | Yes — always needed |
| Access level | Broad intent: read-only, read-write, full, or custom | Yes — ask if unclear |
| Methods | Specific HTTP methods to allow | Only for custom/fine-grained |
| Paths | Specific URL paths or patterns | Only for custom/fine-grained |
| Enforcement | enforce or audit? Default to enforce. |
No — has a default |
| Binary | Which binary/process should have access | Yes — ask if not stated |
| Middleware | Whether admitted HTTP requests, final HTTP responses, or client WebSocket text messages need an ordered built-in or operator-run processing stage | No |
If the host and access level are clear but binaries are not specified, ask the user w
常见问题
使用它需要 API 文档吗?
不需要。一个主机和简单描述就足以生成基本策略。完整的 API 文档可以让它编写更精确的规则。
什么是访问预设?
预设是现成的访问级别,例如只读、读写或完全访问。在不需要详细规则时,AI 可以直接使用。
它能只为部分路径编写规则吗?
可以。如果知道一些具体的 URL 路径,它可以为这些路径编写针对性规则,其余部分使用预设。
详情
作者的原始描述
Generate sandbox security policies from plain-language requirements and optional REST API documentation. Produces L4 or fine-grained L7 network policies and ordered network middleware configuration. Use for API access rules, middleware host selection, failure behavior, or built-in and operator-run middleware attachment. Trigger keywords - generate policy, create policy, update policy, change policy, sandbox policy, network policy, API policy, security policy, allow API, restrict API, network middleware, supervisor middleware.
repo: NVIDIA/OpenShell
热度
- GitHub 星标
- 21k
- 排名
- #10367
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
create-github-issue
21k帮你的智能体使用 gh 命令行工具和项目模板,为错误、功能请求或任务创建 GitHub 议题。
create-github-pr
21k让你的智能体在检查工作是否可以提交审查后,使用 gh 工具为你的分支开启 GitHub 拉取请求。
review-github-pr
21k教你的智能体阅读 GitHub 拉取请求,并用通俗的语言解释其中的修改、关键设计选择和值得注意的代码。
watch-github-actions
21k让你的智能体查看 GitHub Actions 运行情况,持续跟踪直到运行结束,并阅读任何失败作业的日志。