fix(ci): prevent PR title shell injection - #35
Merged
Conversation
| gh pr merge "$PR_NUMBER" \ | ||
| --auto --squash \ | ||
| --subject "[field-journal] ${{ github.event.pull_request.title }}" | ||
| --subject "$PR_SUBJECT" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
说明
针对
auto-merge-journal.yml中直接嵌入 PR 变量导致的 Shell 命令注入隐患进行修复,并将动态输入统一调整为环境变量传递;同步新增 CI 安全性的自动化测试脚本。改动
工作流安全重构 (
.github/workflows/auto-merge-journal.yml)${{ github.event.pull_request.number }}和${{ github.event.pull_request.title }}统一提取至 Job 级别的env环境变量(PR_NUMBER,PR_TITLE,PR_SUBJECT)。gh pr diff、gh pr merge及gh pr comment时,将内联表达式替换为双引号包裹的环境变量(如"$PR_NUMBER"、"$PR_SUBJECT"),阻断命令注入路径。安全回归测试 (
skills/scripts/test-workflow-title-safety.ps1)github.event直接拼接进 Shell 指令的行为。