-
Notifications
You must be signed in to change notification settings - Fork 0
fix: gate 文件清单三防线——edited/rename 溯源/3000 fail-closed(ADR-0016) #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,10 @@ | ||
| name: gate | ||
| on: | ||
| pull_request: | ||
| # edited(qodo review #1,CI-Workflows #8 同款加固):adr-required 消费 | ||
| # 可变的 PR title/body——不订阅 edited 则作者可在 check 通过后编辑掉 | ||
| # ADR 引用而不触发重验;补引用救活 fail 的 check 同样依赖 edited 重触发 | ||
| types: [opened, synchronize, reopened, edited] | ||
| push: | ||
| branches: [main] | ||
|
|
||
|
|
@@ -65,8 +69,23 @@ jobs: | |
| PR_TITLE: ${{ github.event.pull_request.title }} | ||
| PR_BODY: ${{ github.event.pull_request.body }} | ||
| run: | | ||
| # --paginate(评审项):>100 文件的 PR 首页截断会把 C1 变更漏检成非 C1 | ||
| FILES=$(gh api --paginate "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files?per_page=100" --jq '.[].filename') | ||
| # 文件清单三防线(qodo review #2 #3,CI-Workflows #8 同款加固): | ||
| # --paginate:>100 文件的 PR 首页截断会把 C1 变更漏检成非 C1; | ||
| # rename 的 previous_filename 一并纳入——governance/standards/CODEOWNERS | ||
| # 等 C1 资产改名移出受管路径同样是 C1 变更(files API 只在 | ||
| # previous_filename 暴露原路径); | ||
| # files API 3000 文件硬上限:返回数 < changed_files = 清单不完整, | ||
| # fail-closed(清单不全时 C1 判定不可信,宁误杀不放过)。 | ||
| PR_API="repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | ||
| FILES_API="$PR_API/files?per_page=100" | ||
| CHANGED=$(gh api "$PR_API" --jq '.changed_files') | ||
| FILES_CUR=$(gh api --paginate "$FILES_API" --jq '.[].filename') | ||
| GOT=$(grep -c . <<<"$FILES_CUR" || true) | ||
|
Comment on lines
+82
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Newline filename bypasses cap GOT counts nonempty output lines rather than files, so a filename containing a newline can inflate the count and conceal truncation above GitHub's 3000-file limit. An attacker can place such a filename among the returned entries and a C1 file beyond the limit, causing the incomplete list to pass and skip ADR enforcement. Agent Prompt
|
||
| if [ "$GOT" -lt "$CHANGED" ]; then | ||
| echo "::error::PR 声明变更 $CHANGED 个文件但 files API 只返回 $GOT 个(3000 上限截断)——C1 判定完整性无法保证,fail-closed" | ||
| exit 1 | ||
| fi | ||
| FILES=$( { echo "$FILES_CUR"; gh api --paginate "$FILES_API" --jq '[.[].previous_filename // empty][]'; } ) | ||
| if ! echo "$FILES" | grep -qE '^(governance/|standards/|scripts/|\.github/|CODEOWNERS|profile/)'; then | ||
| echo "非 C1 路径变更,跳过 adr-required" | ||
| exit 0 | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. gh api uses workflow token
📘 Rule violation⛨ SecurityThe added GitHub API requests authenticate through the existing ${{ github.token }} rather than a single-repository cloudbrid-agent token issued by scripts/gh-app-token.sh. This violates the required authentication and identity policy for automated GitHub operations.Agent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools