[chore](workflow) Fix security issues with pull_request_target (#26525)
In the workflow Code Checks, we use the event pull_request_target which has write permission to enable the actions to comment on our PRs. We should be careful with the write permission and must forbid from running any user code. The previous PR #24761 tried its best to achieve this goal. However, there is a scenario lacking of consideration (See #26494). #26494 attacks the workflow by git submodule way. This PR fixes this scenario by checkouting the external action explicitly in the workflow.
This commit is contained in:
1
.github/actions/action-sh-checker
vendored
1
.github/actions/action-sh-checker
vendored
Submodule .github/actions/action-sh-checker deleted from 76ab0b22e1
1
.github/actions/clang-format-lint-action
vendored
1
.github/actions/clang-format-lint-action
vendored
Submodule .github/actions/clang-format-lint-action deleted from 6adbe14579
1
.github/actions/clang-tidy-review
vendored
1
.github/actions/clang-tidy-review
vendored
Submodule .github/actions/clang-tidy-review deleted from 2c55ef8cfc
20
.github/workflows/clang-format.yml
vendored
20
.github/workflows/clang-format.yml
vendored
@ -31,14 +31,21 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
|
||||
- name: Checkout ${{ github.ref }} ( ${{ github.event.pull_request.head.sha }} )
|
||||
if: ${{ github.event_name == 'pull_request_target' }}
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
submodules: recursive
|
||||
|
||||
- name: Checkout paths-filter
|
||||
run: |
|
||||
rm -rf ./.github/actions/paths-filter
|
||||
git clone https://github.com/dorny/paths-filter .github/actions/paths-filter
|
||||
|
||||
pushd .github/actions/paths-filter &>/dev/null
|
||||
git checkout 4512585405083f25c027a35db413c2b3b9006d50
|
||||
popd &>/dev/null
|
||||
|
||||
- name: Paths filter
|
||||
uses: ./.github/actions/paths-filter
|
||||
@ -49,6 +56,15 @@ jobs:
|
||||
- 'be/src/**'
|
||||
- 'be/test/**'
|
||||
|
||||
- name: Checkout clang-format-lint-action
|
||||
run: |
|
||||
rm -rf ./.github/actions/clang-format-lint-action
|
||||
git clone https://github.com/DoozyX/clang-format-lint-action .github/actions/clang-format-lint-action
|
||||
|
||||
pushd .github/actions/clang-format-lint-action &>/dev/null
|
||||
git checkout 6adbe14579e5b8e19eb3e31e5ff2479f3bd302c7
|
||||
popd &>/dev/null
|
||||
|
||||
- name: "Format it!"
|
||||
if: ${{ steps.filter.outputs.be_changes == 'true' }}
|
||||
uses: ./.github/actions/clang-format-lint-action
|
||||
|
||||
33
.github/workflows/code-checks.yml
vendored
33
.github/workflows/code-checks.yml
vendored
@ -27,21 +27,22 @@ jobs:
|
||||
- name: Checkout ${{ github.ref }} ( ${{ github.sha }} )
|
||||
if: ${{ github.event_name != 'pull_request_target' }}
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Checkout ${{ github.ref }} ( ${{ github.event.pull_request.head.sha }} )
|
||||
if: ${{ github.event_name == 'pull_request_target' }}
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
submodules: recursive
|
||||
|
||||
- name: Patch
|
||||
- name: Checkout action-sh-checker
|
||||
run: |
|
||||
pushd .github/actions/action-sh-checker >/dev/null
|
||||
rm -rf ./.github/actions/action-sh-checker
|
||||
git clone https://github.com/luizm/action-sh-checker .github/actions/action-sh-checker
|
||||
|
||||
pushd .github/actions/action-sh-checker &>/dev/null
|
||||
git checkout 76ab0b22e1f194e4a582edc7969df6485c4e9246
|
||||
sed -i 's/\[ "$GITHUB_EVENT_NAME" == "pull_request" \]/\[\[ "$GITHUB_EVENT_NAME" == "pull_request" || "$GITHUB_EVENT_NAME" == "pull_request_target" \]\]/' entrypoint.sh
|
||||
popd >/dev/null
|
||||
popd &>/dev/null
|
||||
|
||||
- name: Run ShellCheck
|
||||
uses: ./.github/actions/action-sh-checker
|
||||
@ -63,7 +64,15 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
submodules: recursive
|
||||
|
||||
- name: Checkout paths-filter
|
||||
run: |
|
||||
rm -rf ./.github/actions/paths-filter
|
||||
git clone https://github.com/dorny/paths-filter .github/actions/paths-filter
|
||||
|
||||
pushd .github/actions/paths-filter &>/dev/null
|
||||
git checkout 4512585405083f25c027a35db413c2b3b9006d50
|
||||
popd &>/dev/null
|
||||
|
||||
- name: Paths Filter
|
||||
uses: ./.github/actions/paths-filter
|
||||
@ -117,7 +126,6 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
submodules: recursive
|
||||
|
||||
- name: Download
|
||||
uses: actions/download-artifact@v3
|
||||
@ -125,6 +133,15 @@ jobs:
|
||||
name: compile_commands
|
||||
path: ./be/build_Release
|
||||
|
||||
- name: Checkout clang-tidy review
|
||||
run: |
|
||||
rm -rf ./.github/actions/clang-tidy-review
|
||||
git clone https://github.com/ZedThree/clang-tidy-review .github/actions/clang-tidy-review
|
||||
|
||||
pushd .github/actions/clang-tidy-review &>/dev/null
|
||||
git checkout 2c55ef8cfc9acb3715d433e58aea086dcec9b206
|
||||
popd &>/dev/null
|
||||
|
||||
- name: Run clang-tidy review
|
||||
uses: ./.github/actions/clang-tidy-review
|
||||
id: review
|
||||
|
||||
3
.github/workflows/license-eyes.yml
vendored
3
.github/workflows/license-eyes.yml
vendored
@ -30,15 +30,12 @@ jobs:
|
||||
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
|
||||
if: ${{ github.event_name != 'pull_request_target' }}
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Checkout ${{ github.ref }} ( ${{ github.event.pull_request.head.sha }} )
|
||||
if: ${{ github.event_name == 'pull_request_target' }}
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
submodules: recursive
|
||||
|
||||
- name: Check License
|
||||
uses: apache/skywalking-eyes@v0.2.0
|
||||
|
||||
9
.gitmodules
vendored
9
.gitmodules
vendored
@ -4,9 +4,6 @@
|
||||
[submodule ".github/actions/get-workflow-origin"]
|
||||
path = .github/actions/get-workflow-origin
|
||||
url = https://github.com/potiuk/get-workflow-origin.git
|
||||
[submodule ".github/actions/clang-format-lint-action"]
|
||||
path = .github/actions/clang-format-lint-action
|
||||
url = https://github.com/DoozyX/clang-format-lint-action.git
|
||||
[submodule ".github/actions/setup-maven"]
|
||||
path = .github/actions/setup-maven
|
||||
url = https://github.com/stCarolas/setup-maven.git
|
||||
@ -19,12 +16,6 @@
|
||||
[submodule ".github/actions/ccache-action"]
|
||||
path = .github/actions/ccache-action
|
||||
url = https://github.com/hendrikmuhs/ccache-action
|
||||
[submodule ".github/actions/action-sh-checker"]
|
||||
path = .github/actions/action-sh-checker
|
||||
url = https://github.com/luizm/action-sh-checker
|
||||
[submodule ".github/actions/clang-tidy-review"]
|
||||
path = .github/actions/clang-tidy-review
|
||||
url = https://github.com/ZedThree/clang-tidy-review.git
|
||||
[submodule "be/src/apache-orc"]
|
||||
path = be/src/apache-orc
|
||||
url = https://github.com/apache/doris-thirdparty.git
|
||||
|
||||
Reference in New Issue
Block a user