Skip to content

fix: 修复 org-router shell 注入、cache 权限、actions 版本升级#119

Merged
nevstop merged 3 commits into
mainfrom
fix/router-shell-injection-and-cache
Jul 6, 2026
Merged

fix: 修复 org-router shell 注入、cache 权限、actions 版本升级#119
nevstop merged 3 commits into
mainfrom
fix/router-shell-injection-and-cache

Conversation

@nevstop

@nevstop nevstop commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

问题来源

修复 Actions run #28774182942 中的运行失败。

变更摘要

🔴 Shell 注入修复(核心)

  • scripts/router.py--comment-body--discussion-title--category-name--comment-author--event-typeargparse 默认值改为从环境变量(ROUTER_COMMENT_BODY 等)读取
  • .github/workflows/org-router.yml:移除 4 处 CLI 调用中的用户内容参数,依赖环境变量传递
  • 新增 classify-only__main__ 入口的 try/except 保底:异常时输出 OTHER 而非崩溃

🟡 Cache 写入权限

  • 添加 actions: write 到 job permissions,修复 cache save 步骤因 token scope 不足而失败

🟡 Actions 版本升级

  • actions/setup-python@v5v6
  • actions/cache/restore@v4v5
  • actions/cache/save@v4v5
  • 消除 Node.js 20 deprecation 警告

🟢 测试修复

  • tests/test_router.py:3 个 TestMainHumanIntervention 测试添加 caplog.set_level(logging.INFO),修复预存的日志级别不匹配导致的假失败

涉及文件

文件 操作
scripts/router.py 修改
.github/workflows/org-router.yml 修改
tests/test_router.py 修改

验证

  • CI workflow (#28775563131) 53/53 测试通过
  • classify-only 模式通过环境变量正确读取含特殊字符的用户内容
  • Cache save 正常工作

nevstop added 3 commits July 6, 2026 15:32
Move user-supplied content (comment-body, discussion-title, category-name,
comment-author, event-type) from CLI arguments to environment variable
fallback in parse_args. This prevents shell injection via backticks or
 in user content, since these values are no longer expanded by bash
when constructing the CLI command.

Workflow changes in subsequent commit will remove the corresponding CLI args.
…pgrade actions

1. Remove all user-supplied content CLI args (--comment-body, --discussion-title,
   --category-name, --event-type, --comment-author) from the 4 router.py
   invocations — these are now read from environment variables instead,
   eliminating shell injection risk.

2. Add 'actions: write' permission to allow cache save operations to succeed.

3. Upgrade actions/setup-python@v5 → v6, actions/cache/{restore,save}@v4 → v5
   to resolve Node.js 20 deprecation warnings.
The 3 tests in TestMainHumanIntervention check for INFO-level log
messages via caplog, but caplog's default handler level is WARNING.
Add caplog.set_level(logging.INFO) so these messages are captured.
@nevstop nevstop merged commit 6b572f5 into main Jul 6, 2026
1 check passed
@nevstop nevstop deleted the fix/router-shell-injection-and-cache branch July 6, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant