fix: avoid shell injection via PR body containing backticks#784
Merged
Conversation
Move PR_BODY to an env variable instead of inline shell assignment to prevent backticks from being interpreted as command substitution. Log:
Contributor
deepin pr auto review你好!我是CodeGeeX。我已经仔细审查了你提供的 Git Diff,这次修改主要是对 GitHub Actions 工作流中环境变量的使用方式进行了重构,将内联的变量赋值改为了 以下是针对这段代码的详细审查意见,涵盖语法逻辑、代码质量、代码性能和代码安全四个方面: 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
综合改进后的代码建议结合以上分析,我为你提供一份优化后的代码版本,修复了潜在的误报问题,并提升了性能与可读性: - name: check PR description for AI co-author pattern
shell: bash
env:
PR_BODY: ${{ github.event.pull_request.body }}
# 增加单词边界 \b 防止误匹配如 "Kai", "Baird" 等包含 ai/gpt 的名字
# 移至 env 块方便集中管理和修改
BLOCKED_PATTERN: 'Co-authored-by:.*\b(ai|agent|copilot|llm|gpt)\b'
run: |
# 使用 <<< (here-string) 替代管道,避免创建多余的 echo 子进程,提升性能
if grep -Eiq "${BLOCKED_PATTERN}" <<< "${PR_BODY}"; then
echo "FAIL: PR description contains blocked co-author AI pattern." >&2
echo "Blocked pattern: ${BLOCKED_PATTERN}" >&2
exit 1
fi主要变更说明:
|
BLumia
approved these changes
May 15, 2026
wineee
approved these changes
May 15, 2026
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, hudeng-go, wineee The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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.
Move PR_BODY to an env variable instead of inline shell assignment to prevent backticks from being interpreted as command substitution.
Log: