Repository navigation
docs: add docs for network.rules - #115
Conversation
📝 WalkthroughWalkthrough本次变更更新网络参数支持范围,并新增通过 Changes网络规则文档
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/zh-CN/01.云沙箱/04.功能说明/06.网络/07.出网请求头转换.md`:
- Line 191: 更新 Node.js 示例中的 Authorization Header,复用前文对 API_TOKEN 的非空校验,并使用校验后的
token 构造 Bearer 值;未配置 token 时不要生成或写入 Bearer undefined。
- Around line 297-300: 更新自定义镜像说明中的 CA 支持时间要求,移除无法满足的未来日期“2026-08-15”,改为已确认的平台 CA
发布时间;若无法确认具体日期,则改写为“平台 CA 发布完成后,以官方公告为准”。保留官方镜像版本要求不变。
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 9b8a8a02-73c7-4435-aa28-f4f21a16715c
📒 Files selected for processing (2)
docs/zh-CN/01.云沙箱/04.功能说明/06.网络/05.网络访问控制.mddocs/zh-CN/01.云沙箱/04.功能说明/06.网络/07.出网请求头转换.md
| - 如果使用官方镜像,请确保版本不低于 `v0.0.44`: | ||
| - `fc-e2b-registry.${regionId}.cr.aliyuncs.com/runtime/base:v0.0.44` | ||
| - `fc-e2b-registry.${regionId}.cr.aliyuncs.com/runtime/code-interpreter-v1:v0.0.44` | ||
| - 如果是自定义镜像,请确保镜像构建发生在 2026-08-15 平台发布完成之后,旧镜像不会自动获得平台 CA。 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Repo files around target:"
fd -a '07\.出网请求头转换\.md' . || true class="pl-s">"$(fd '07\.出网请求头转换\.md' . | head -n 1 || true)"
if [ -n "$target" ]; then
echo "Target: $target"
wc -l "$target"
echo "Lines 280-310:"
sed -n '280,310p' "$target" | cat -n -v
echo "Occurrences of date/version terms:"
rg -n "v0\.0\.44|2026-08-15|平台 CA|template|CA|自定义镜像|官方镜像" "$target"
fi
echo "Search repository for v0.0.44 / 2026-08-15 / 模板 CA:"
rg -n "v0\.0\.44|2026-08-15|平台 CA|自定义镜像|官方镜像" docs .github 2>/dev/null || trueRepository: aliyun-fc/fc-docs
Length of output: 46895
🌐 Web query:
阿里云函数计算 e2b runtime base v0.0.44 fc-e2b-registry cr.aliyuncs.com CA 模板 CA 2026
💡 Result:
在阿里云函数计算(Function Compute, FC)的云沙箱(E2B)服务中,fc-e2b-registry 是官方维护的镜像仓库域名,用于存储各类预置的沙箱环境镜像 [1][2][3]。 关于你提到的版本和资源: 1. 关于 v0.0.44 镜像: fc-e2b-registry.cn-beijing.cr.aliyuncs.com/runtime/code-interpreter-v1:v0.0.44 等镜像版本确实存在,并被用于构建 E2B 兼容的沙箱模板 [4]。官方文档建议在构建自定义镜像模板时,直接使用这些预置的官方镜像,无需您额外提供 ACR EE 实例 [1][2]。 2. 关于 Base 模板: base 模板是云沙箱提供的一种最小化运行环境,仅包含 E2B envd 兼容的基础服务(支持沙箱生命周期管理、基础 Shell 命令执行和文件系统访问),不预置代码解释器或浏览器自动化服务 [5][3]。它常作为自定义业务运行时或工具链的基础基线 [5]。 3. 使用方式(示例): 在使用 E2B SDK 时,你可以指定 FROM_IMAGE 来构建自定义模板。以下是基于官方推荐的构建方式: E2B_API_KEY=e2b_xxx FROM_IMAGE="fc-e2b-registry.cn-beijing.cr.aliyuncs.com/runtime/code-interpreter-v1:v0.0.44" # 使用 Python SDK 构建模板 from e2b import Template, default_build_logger import os build = Template.build( Template.from_image(os.environ["FROM_IMAGE"]), name="my-custom-template", cpu_count=2, memory_mb=2048, on_build_logs=default_build_logger,) 如果你的需求是使用标准的 Python 代码解释能力,通常推荐直接使用 code-interpreter-v1 模板;如果需要高度定制环境(如安装特定的系统库),则基于 base 或 code-interpreter-v1 镜像进行扩展 [5][3]。这些信息在 2026 年 8 月的阿里云官方文档中是有效的 [5][3]。
Citations:
- 1: https://www.alibabacloud.com/help/zh/functioncompute/build-a-custom-image-template
- 2: https://help.aliyun.com/zh/functioncompute/build-a-custom-image-template
- 3: https://www.alibabacloud.com/help/zh/functioncompute/built-in-templates/
- 4: https://help.aliyun.com/zh/functioncompute/overview-of-templates
- 5: https://www.alibabacloud.com/help/zh/functioncompute/base-template
🌐 Web query:
site:docs.aliyun.com 函数计算 e2b 出网请求头转换 自定义镜像 模板 CA
💡 Result:
相关阿里云文档主要是:
-
构建自定义镜像模板:介绍 E2B 模板、自定义镜像、镜像转换模式、请求头配置、ACR EE/VPC、CA 证书等。重点搜索词中的“自定义镜像、模板、CA、请求头转换”都在此文档中。[1]
-
定义模板:介绍通过 E2B SDK 的
Template.build()和Template.from_image()从镜像创建模板。[2] -
基础镜像:说明模板构建使用的基础镜像格式及 ACR EE 镜像要求。[3]
其中与“请求头转换”最相关的配置包括:
headers = {
"X-E2B-Template-Build-Mode": "builder", # 或 direct
"X-E2B-Template-Source-Registry-Type": "acree",
"X-E2B-Template-Dest-Image-Ref": "...",
"X-E2B-Template-Alpha-RegistryConfig-CertConfig-Insecure": "false",
}builder 会将普通业务镜像转换为云沙箱模板镜像;direct 则要求源镜像本身已包含 E2B 运行依赖。[1]
Sources:
[1] (help.aliyun.com)
[2] (help.aliyun.com)
[3] (help.aliyun.com)
Citations:
- 1: https://help.aliyun.com/zh/functioncompute/build-a-custom-image-template?utm_source=openai
- 2: https://help.aliyun.com/zh/functioncompute/define-template?utm_source=openai
- 3: https://help.aliyun.com/zh/functioncompute/base-image?utm_source=openai
🌐 Web query:
site:help.aliyun.com "平台 CA" "v0.0.44" "2026-08-15" "出网请求头转换"
💡 Result:
经查证,截至2026年8月10日,阿里云及其相关生态产品中并没有名为“平台 CA v0.0.44”且在2026年8月15日发布“出网请求头转换”功能的记录。 您的查询可能涉及以下技术概念的混淆或特定企业内部系统的版本更新: 1. 技术背景:在阿里云产品体系中,“出网请求头转换”(或称“回源HTTP请求头修改”)是边缘安全加速(ESA)、CDN、DCDN以及API网关等产品的标准功能 [1][2][3][4][5]。这些功能通常用于在请求回源时添加、修改、删除或重写HTTP请求头,以满足业务对接需求 [1][2][3]。 2. 版本记录参考: - 阿里云 Lingma 系列(Qoder CN CLI)在2026年7月13日曾发布 v1.0.44 版本 [6]。 - Cloud Agents CN 的版本号序列中包含 0.5.0 等版本,但并未检索到与“CA v0.0.44”完全吻合的发布记录 [7]。 如果这是您所在公司或特定内部平台的发布需求,建议直接查阅该平台的官方发布说明文档(Release Notes)或联系内部技术支持团队以获取准确的更新日志。如果您确认该信息属于阿里云产品,建议提供更准确的产品名称以供进一步核实。
Citations:
- 1: https://help.aliyun.com/zh/edge-security-acceleration/esa/user-guide/modify-outgoing-request-header
- 2: https://help.aliyun.com/zh/edge-security-acceleration/esa/user-guide/conversion-rules-overview/
- 3: https://help.aliyun.com/zh/api-gateway/traditional-api-gateway/user-guide/transformer-plug-in
- 4: https://help.aliyun.com/zh/edge-security-acceleration/dcdn/configure-custom-request-headers
- 5: https://help.aliyun.com/zh/cdn/user-guide/configure-custom-request-headers
- 6: https://help.aliyun.com/zh/lingma/qoder-cn-cli
- 7: https://help.aliyun.com/zh/lingma/product-overview/cloud-agents-cn-update-log
修正自定义镜像 CA 支持的时间要求。
v0.0.44 是当前云沙箱模板镜像版本,但 2026-08-15 是未来日期,用户现在无法满足。自定义镜像项请改为已确认的平台 CA 发布时间,或改为“平台 CA 发布完成后,以官方公告为准”。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/zh-CN/01.云沙箱/04.功能说明/06.网络/07.出网请求头转换.md` around lines 297 - 300,
更新自定义镜像说明中的 CA 支持时间要求,移除无法满足的未来日期“2026-08-15”,改为已确认的平台 CA 发布时间;若无法确认具体日期,则改写为“平台
CA 发布完成后,以官方公告为准”。保留官方镜像版本要求不变。
Change-Id: I51cdd90f2994163b73f1968a2b162322979c5ced Co-developed-by: Qoder <noreply@qoder.com>
bfcc87b to
d60e85a
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/zh-CN/01.云沙箱/04.功能说明/06.网络/07.出网请求头转换.md`:
- Around line 163-165: 在“运行时更新”首次介绍 updateNetwork/update_network 的说明中,补充 Python
SDK ≥ 2.11 且 Python ≥ 3.10 的前提;注明 Python 3.9 可能仅安装兼容的 2.10.x 并触发
AttributeError,并引导用户升级 Python ≥ 3.10 后重装 e2b,或改用 REST PUT
/sandboxes/{id}/network。
- Around line 287-293: 更新网络请求头转换文档中 Node.js 的说明,明确区分内置 CA、系统 CA 与额外 CA 的加载方式:系统
CA 需使用 --use-system-ca,其他 CA 需通过 NODE_EXTRA_CA_CERTS 配置。不要将 Node.js 与
Debian/Ubuntu 系统 CA 已可开箱即用的表述混为一谈,除非文档明确说明模板已将平台 CA 安装到 Node.js 默认信任路径。
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3674bbb0-1dc1-44ec-b26c-70fbbc685c1e
📒 Files selected for processing (1)
docs/zh-CN/01.云沙箱/04.功能说明/06.网络/07.出网请求头转换.md
| ## 运行时更新 | ||
|
|
||
| `network.rules` 支持通过 `updateNetwork`(TypeScript)/ `update_network`(Python)在**不重建沙箱**的情况下修改。`PUT /sandboxes/{id}/network` 是**全量替换**,不是 patch。更新时应同时提交最终的 `allowOut`、`denyOut` 和 `rules`。省略 `rules`、传 `null` 或传 `{}` 都会清空已有规则。 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 3 \
'update_network|Python SDK|2\.11|Python 3\.10|Python 3\.9|PUT /sandboxes/\{id\}/network' \
docs/zh-CN/01.云沙箱/04.功能说明/06.网络/05.网络访问控制.md \
docs/zh-CN/01.云沙箱/04.功能说明/06.网络/07.出网请求头转换.md || trueRepository: aliyun-fc/fc-docs
Length of output: 5338
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re
src = Path("docs/zh-CN/01.云沙箱/04.功能说明/06.网络/07.出网请求头转换.md").read_text(encoding="utf-8")
near = "\n".join(src.splitlines()[160:168])
sections = {
"runtime": re.search(r"^## 运行时更新.*?(?=^## )", src, flags=re.M | re.S),
"create": re.search(r"^## 创建沙箱与设置网络.*?(?=^## )", src, flags=re.M | re.S),
}
terms = {
"has_update_network_mention": "update_network" in near,
"has_update_network_code": bool(re.search(r"update_network\(", src)),
"python_sdk_version_in_near": bool(re.search(r"Python SDK[^\\d]*(\d+\.?)*|SDK[^\\d]*(\d+\.?)*|2\.11|3\.10|3\.9", near)),
"python_runtime_version_in_near": bool(re.search(r"Python[^\\d]*(\d+\.?\d*)?|3\.10|3\.9", near)),
}
print("near_runtime_heading:")
print(near.rstrip("\n"))
print("\nsection_coverage:")
for k, m in sections.items():
print(f"{k}: {bool(m)}")
print("\nterms:", terms)
PYRepository: aliyun-fc/fc-docs
Length of output: 799
补充 update_network 的 Python 运行时前提。
此处的 Python 示例会调用 sandbox.update_network(...),但 runtime 小节没有说明 Python SDK / Python 版本的准入条件,与 05.网络访问控制.md 的规定不一致。建议在首次说明 updateNetwork(TypeScript)/ update_network(Python)时补充:Python SDK ≥ 2.11,Python ≥ 3.10;Python 3.9 可能只会安装兼容的 2.10.x,导致 AttributeError,此时请升级 Python ≥ 3.10 后重装 e2b,或改用 REST PUT /sandboxes/{id}/network。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/zh-CN/01.云沙箱/04.功能说明/06.网络/07.出网请求头转换.md` around lines 163 - 165,
在“运行时更新”首次介绍 updateNetwork/update_network 的说明中,补充 Python SDK ≥ 2.11 且 Python ≥
3.10 的前提;注明 Python 3.9 可能仅安装兼容的 2.10.x 并触发 AttributeError,并引导用户升级 Python ≥ 3.10
后重装 e2b,或改用 REST PUT /sandboxes/{id}/network。
Source: Path instructions
| 如果沙箱客户端不信任平台 CA,检查证书文件、模板版本和语言 truststore。官方模板及受支持的 Debian/Ubuntu 自定义模板会配置平台 CA,curl、Python requests 和 Node.js 可开箱即用;以下客户端通常需要自行配置信任: | ||
|
|
||
| - Java:把 `/usr/local/share/ca-certificates/e2b-ca.crt` 导入 JVM `cacerts` 或应用 truststore; | ||
| - Firefox/NSS; | ||
| - 只读取 OpenSSL CApath 的应用; | ||
| - 非 Debian/Ubuntu 自定义镜像; | ||
| - 使用私有 trust bundle、证书 pinning 或忽略系统环境变量的客户端。 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
files="$(fd -a -I -t f 'package\.json|\.nvmrc|\.node-version|Dockerfile|\.tool-versions' . || true)"
if [ -n "$files" ]; then
printf '%s\n' "$files" | xargs -r rg -n \
'engines|node-version|FROM node|NODE_EXTRA_CA_CERTS|use-system-ca'
fiRepository: aliyun-fc/fc-docs
Length of output: 159
🌐 Web query:
Node.js --use-system-ca NODE_EXTRA_CA_CERTS CLI documentation nodejs.org
💡 Result:
In Node.js, --use-system-ca and NODE_EXTRA_CA_CERTS are mechanisms used to manage and extend the trusted Certificate Authority (CA) certificates used for TLS validation [1]. --use-system-ca The --use-system-ca flag (or the NODE_USE_SYSTEM_CA=1 environment variable) instructs Node.js to load CA certificates from the operating system's trust store [1]. When enabled, Node.js uses these system CAs in addition to its bundled CAs (a snapshot of the Mozilla CA store) [1]. On Windows and macOS, Node.js follows platform-specific policies for locally trusted certificates [2]. On other platforms (such as Linux), Node.js typically loads certificates from the default files and directories respected by the linked OpenSSL library (e.g., /etc/ssl/cert.pem and /etc/ssl/certs) [2]. NODE_EXTRA_CA_CERTS The NODE_EXTRA_CA_CERTS environment variable allows you to extend the set of trusted CAs by specifying a file containing one or more additional certificates in PEM format [3]. When set, Node.js reads this file only at process launch [3]. This variable is ignored if the process is running with elevated privileges (setuid root or with Linux file capabilities) [3]. It is also ignored if the ca option is explicitly specified in a TLS or HTTPS request [3]. Combining Options These mechanisms can be used together [1]. When both --use-system-ca and NODE_EXTRA_CA_CERTS are configured, Node.js trusts the bundled CA store, the system CA store, and the additional certificates provided via the environment variable [1]. Note: These settings do not apply when the ca property is explicitly configured for an individual tls.connect or https.request method [1][3].
Citations:
- 1: https://nodejs.org/learn/http/enterprise-network-configuration
- 2: nodejs/node@44b19ec534
- 3: https://nodejs.org/docs/latest-v19.x/api/cli.html
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf 'Target file lines 260-300:\n'
sed -n '260,300p' 'docs/zh-CN/01.云沙箱/04.功能说明/06.网络/07.出网请求头转换.md' | cat -n
printf '\nRepository search for e2b-ca.crt and CA trust wording:\n'
rg -n "e2b-ca\.crt|Node\.js|nodejs|ca-certificates|truststore|NODE_EXTRA_CA_CERTS|--use-system-ca|系统 CA|内置 CA|平台 CA" .Repository: aliyun-fc/fc-docs
Length of output: 50373
🌐 Web query:
Node.js ca certificates Linux OpenSSL CApath default NODE_EXTRA_CA_CERTS --use-system-ca
💡 Result:
In Node.js, the handling of CA certificates on Linux is primarily managed through the following mechanisms, which allow you to extend or replace the default set of trusted authorities [1][2]. 1. --use-system-ca (Flag or NODE_USE_SYSTEM_CA) The --use-system-ca flag (or the NODE_USE_SYSTEM_CA environment variable) instructs Node.js to load CA certificates from the default OpenSSL certificate file and directory [3][4]. When enabled, Node.js uses the paths typically configured for the version of OpenSSL it is linked against—usually /etc/ssl/cert.pem for the default file and /etc/ssl/certs for the default directory [3]. These certificates are cached upon the first load [5][3]. This flag is intended to help developers securely include system-wide trusted CAs, especially when encountering common certificate verification errors [6]. 2. NODE_EXTRA_CA_CERTS The NODE_EXTRA_CA_CERTS environment variable allows you to extend the set of well-known, bundled CA certificates with additional certificates in PEM format [7]. When this variable is set to a path pointing to a file containing one or more trusted certificates, those certificates are added to the trusted store [7][8]. - Usage: This variable is read only once during the startup of the Node.js process; changing it at runtime (e.g., via process.env) has no effect [7][9]. - Limitations: It is ignored if the Node.js process runs as setuid root or has Linux file capabilities set [7]. It is also not used if the ca option is explicitly provided to a TLS/HTTPS client or server [7]. 3. Default Behavior By default, if neither --use-system-ca nor NODE_EXTRA_CA_CERTS is configured, Node.js relies on a bundled set of CA certificates [1][2]. The --use-system-ca flag and --use-openssl-ca are mutually exclusive [1]. If you need both custom certificates and system-wide certificates, you can combine --use-system-ca with NODE_EXTRA_CA_CERTS [4]. 4. OpenSSL Environment Variables Node.js respects standard OpenSSL environment variables such as SSL_CERT_FILE and SSL_CERT_DIR [3][2]. If these are set, they can override the default paths Node.js uses when --use-system-ca is enabled [3]. These variables can be used as a workaround if the standard paths on your Linux distribution differ from those expected by the linked OpenSSL library [3].
Citations:
- 1: https://github.com/nodejs/node/blob/d90d9d55/src/crypto/crypto_context.cc
- 2: nodejs/node@33012e9
- 3: nodejs/node@44b19ec534
- 4: https://nodejs.org/learn/http/enterprise-network-configuration
- 5: crypto: support --use-system-ca on non-Windows and non-macOS nodejs/node#57009
- 6: https://nodejs.org/api/tls.html
- 7: https://nodejs.org/docs/latest-v19.x/api/cli.html
- 8: crypto: allow adding extra certs to well-known CAs nodejs/node#9139
- 9: https://r2.nodejs.org/docs/v18.11.0/api/cli.html
区分 Node.js 的平台 CA 加载路径。
Node.js 默认信任其内置 CA 集合;系统 CA 需要 --use-system-ca,其他 CA 需要 NODE_EXTRA_CA_CERTS。当前文案把 /usr/local/share/ca-certificates/e2b-ca.crt、系统 CA 和 Node.js“可开箱即用”放在同一前提里,会让用户在未明确运行时配置的情况下误以为直接放入该路径即可生效。如需支持直接放入该路径,应指明模板已将其安装进 Node.js 默认 CA 路径;否则为 Node.js 补充具体加载配置。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/zh-CN/01.云沙箱/04.功能说明/06.网络/07.出网请求头转换.md` around lines 287 - 293,
更新网络请求头转换文档中 Node.js 的说明,明确区分内置 CA、系统 CA 与额外 CA 的加载方式:系统 CA 需使用
--use-system-ca,其他 CA 需通过 NODE_EXTRA_CA_CERTS 配置。不要将 Node.js 与 Debian/Ubuntu 系统
CA 已可开箱即用的表述混为一谈,除非文档明确说明模板已将平台 CA 安装到 Node.js 默认信任路径。
Change-Id: I51cdd90f2994163b73f1968a2b162322979c5ced
Co-developed-by: Qoder noreply@qoder.com
变更说明
请说明本次修改涉及的产品、章节和问题。
变更类型
验证
make check相关 Issue
如有,请填写 Issue 链接。
文档范围
05.网络访问控制.md,补充network.rules文档链接,并更新网络参数和运行时更新说明。07.出网请求头转换.md,介绍使用network.rules配置出站请求头转换。页面与资源变更