Skip to content

Commit a3df50d

Browse files
aduh95targos
authored andcommitted
tools: ensure the PR was not pushed before merging
When using Squash and Merge feature, it would allow to a malicious actor to push unreviewed code to their PR while the CQ is running and bypass the usual checks. This commit adds a check to refuse to land if the head of the PR branch is different from the one validated by ncu. PR-URL: #40747 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Voltrex <[email protected]>
1 parent ea968d5 commit a3df50d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/actions/commit-queue.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ for pr in "$@"; do
110110
jq -n \
111111
--arg title "$(git log -1 --pretty='format:%s')" \
112112
--arg body "$(git log -1 --pretty='format:%b')" \
113-
'{merge_method:"squash",commit_title:$title,commit_message:$body}' > output.json
113+
--arg head "$(grep 'Fetched commits as' output | cut -d. -f3 | xargs git rev-parse)" \
114+
'{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' > output.json
114115
cat output.json
115116
gitHubCurl "$(mergeUrl "$pr")" PUT --data @output.json > output
116117
cat output

0 commit comments

Comments
 (0)