Skip to content

Commit 864f359

Browse files
authored
[Fix](GA)Add sha check for auto-pick-script (apache#42500)
## Proposed changes - Use pull_request_target to prevent unauthorized execution. - Add SHA checks to ensure that the file has not been tampered with, thus addressing security concerns.
1 parent 25552e5 commit 864f359

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

.github/workflows/auto-cherry-pick.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
name: Auto Cherry-Pick to Branch
1919

2020
on:
21-
pull_request:
21+
pull_request_target:
2222
types:
2323
- closed
2424
branches:
@@ -27,7 +27,6 @@ permissions:
2727
checks: write
2828
contents: write
2929
pull-requests: write
30-
repository-projects: write
3130
jobs:
3231
auto_cherry_pick:
3332
runs-on: ubuntu-latest
@@ -44,7 +43,16 @@ jobs:
4443
- name: Install dependencies
4544
run: |
4645
pip install PyGithub
47-
46+
- name: Check SHA
47+
run: |
48+
expected_sha="1941de05514e15c216067778e0287b4c3ebcd6f6042ee189a12257bfd0cdd9f764e18c7dae5de868e9b7128ce3be98dc8f78252932cee7d55552fc0cf8b69496"
49+
calculated_sha=$(sha512sum tools/auto-pick-script.py | awk '{ print $1 }')
50+
if [ "$calculated_sha" != "$expected_sha" ]; then
51+
echo "SHA mismatch! Expected: $expected_sha, but got: $calculated_sha"
52+
exit 1
53+
else
54+
echo "SHA matches: $calculated_sha"
55+
fi
4856
- name: Auto cherry-pick
4957
env:
5058
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)