Skip to content

Commit 5174fef

Browse files
committed
Fix security, draft-PR, and comment-cleanup issues in maintainer-approval
- Checkout base branch SHA to prevent PR-authored code execution on review events - Add ready_for_review to pull_request_target types so draft promotions trigger - Delete ALL matching comments (not just first) including legacy REVIEWER_SUGGESTION marker - Add concurrency group to prevent overlapping runs per PR Co-authored-by: Isaac
1 parent 42d8345 commit 5174fef

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.github/workflows/maintainer-approval.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,18 @@ function buildSingleDomainPendingComment(sortedScores, dirScores, scoredCount, e
390390

391391
// --- Comment management ---
392392

393+
const LEGACY_MARKER = "<!-- REVIEWER_SUGGESTION -->";
394+
393395
async function postComment(github, owner, repo, prNumber, comment) {
394396
const comments = await github.paginate(github.rest.issues.listComments, {
395397
owner, repo, issue_number: prNumber,
396398
});
397-
const existing = comments.find(c => c.body && c.body.includes(MARKER));
398-
if (existing) {
399+
const toDelete = comments.filter(c =>
400+
c.body && (c.body.includes(MARKER) || c.body.includes(LEGACY_MARKER))
401+
);
402+
for (const c of toDelete) {
399403
await github.rest.issues.deleteComment({
400-
owner, repo, comment_id: existing.id,
404+
owner, repo, comment_id: c.id,
401405
});
402406
}
403407
await github.rest.issues.createComment({

.github/workflows/maintainer-approval.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ name: PR approval
22

33
on:
44
pull_request_target:
5+
types: [opened, synchronize, reopened, ready_for_review]
56
pull_request_review:
67
types: [submitted, dismissed]
78

9+
concurrency:
10+
group: pr-approval-${{ github.event.pull_request.number }}
11+
cancel-in-progress: true
12+
813
defaults:
914
run:
1015
shell: bash
@@ -23,6 +28,7 @@ jobs:
2328
steps:
2429
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2530
with:
31+
ref: ${{ github.event.pull_request.base.sha }}
2632
persist-credentials: false
2733
fetch-depth: 0
2834
- name: Check approval and suggest reviewers

0 commit comments

Comments
 (0)