-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix: potential CI injections #15720
Open
erikburt
wants to merge
4
commits into
develop
Choose a base branch
from
fix/gha-workflow-zizmor
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix: potential CI injections #15720
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
457ee7f
fix: persist-credentials false for actions/checkout
erikburt ebeeb0c
fix: possible template injection in CI
erikburt 172e8fd
Merge branch 'develop' into fix/gha-workflow-zizmor
erikburt ddd920c
Merge branch 'develop' into fix/gha-workflow-zizmor
erikburt 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 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 |
---|---|---|
|
@@ -26,12 +26,14 @@ runs: | |
# Only do a full checkout on merge_groups | ||
if: github.event_name == 'merge_group' | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
|
||
- name: Checkout repo | ||
uses: actions/[email protected] | ||
if: github.event_name != 'merge_group' | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 1 | ||
|
||
- name: Setup Go | ||
|
This file contains 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 |
---|---|---|
|
@@ -24,6 +24,8 @@ jobs: | |
steps: | ||
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
- name: Configure aws credentials | ||
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1 | ||
with: | ||
|
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -12,6 +12,8 @@ jobs: | |
steps: | ||
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | ||
id: bash-scripts | ||
with: | ||
|
@@ -26,6 +28,8 @@ jobs: | |
steps: | ||
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
- name: Run ShellCheck | ||
if: needs.changes.outputs.bash-scripts-src == 'true' | ||
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # v2.0.0 | ||
|
This file contains 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 |
---|---|---|
|
@@ -38,27 +38,33 @@ jobs: | |
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
ref: ${{ env.CHECKOUT_REF }} | ||
|
||
- name: Get image tag | ||
id: get-image-tag | ||
env: | ||
GH_EVENT_NAME: ${{ github.event_name }} | ||
GH_EVENT_NUMBER: ${{ github.event.number }} | ||
GH_INPUTS_BUILD_PUBLISH: ${{ inputs.build-publish }} | ||
LABEL_HAS_BUILD_PUBLISH: ${{ contains(github.event.pull_request.labels.*.name, 'build-publish') }} | ||
run: | | ||
short_sha=$(git rev-parse --short HEAD) | ||
echo "release-type=snapshot" | tee -a $GITHUB_OUTPUT | ||
if [[ ${{ github.event_name }} == 'push' ]]; then | ||
if [[ $GH_EVENT_NAME == 'push' ]]; then | ||
echo "image-tag=develop" | tee -a $GITHUB_OUTPUT | ||
echo "release-type=nightly" | tee -a $GITHUB_OUTPUT | ||
elif [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then | ||
elif [[ $GH_EVENT_NAME == 'workflow_dispatch' ]]; then | ||
echo "image-tag=${short_sha}" | tee -a $GITHUB_OUTPUT | ||
if [[ "${{ inputs.build-publish }}" == 'false' ]]; then | ||
if [[ "$GH_INPUTS_BUILD_PUBLISH" == 'false' ]]; then | ||
echo "release-type=snapshot" | tee -a $GITHUB_OUTPUT | ||
else | ||
echo "release-type=nightly" | tee -a $GITHUB_OUTPUT | ||
fi | ||
else | ||
if [[ ${{ github.event_name }} == "pull_request" ]]; then | ||
echo "image-tag=pr-${{ github.event.number }}-${short_sha}" | tee -a $GITHUB_OUTPUT | ||
if [[ ${{ contains(github.event.pull_request.labels.*.name, 'build-publish') }} == "true" ]]; then | ||
if [[ $GH_EVENT_NAME == "pull_request" ]]; then | ||
echo "image-tag=pr-${GH_EVENT_NUMBER}-${short_sha}" | tee -a $GITHUB_OUTPUT | ||
if [[ $LABEL_HAS_BUILD_PUBLISH == "true" ]]; then | ||
echo "release-type=nightly" | tee -a $GITHUB_OUTPUT | ||
fi | ||
fi | ||
|
@@ -86,6 +92,7 @@ jobs: | |
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
ref: ${{ env.CHECKOUT_REF }} | ||
fetch-depth: 0 | ||
|
||
|
@@ -124,6 +131,7 @@ jobs: | |
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
ref: ${{ env.CHECKOUT_REF }} | ||
|
||
- name: Configure aws credentials | ||
|
This file contains 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 |
---|---|---|
|
@@ -15,6 +15,8 @@ jobs: | |
steps: | ||
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
- name: Check for VERSION file bump on tags | ||
# Avoids checking VERSION file bump on forks. | ||
if: ${{ github.repository == 'smartcontractkit/chainlink' }} | ||
|
@@ -38,6 +40,7 @@ jobs: | |
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
|
||
- name: Configure aws credentials | ||
|
@@ -96,6 +99,7 @@ jobs: | |
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
|
||
- name: Configure aws credentials | ||
|
This file contains 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 |
---|---|---|
|
@@ -18,6 +18,8 @@ jobs: | |
steps: | ||
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
- name: Check git tag type | ||
id: check-git-tag-type | ||
shell: bash | ||
|
@@ -67,6 +69,8 @@ jobs: | |
steps: | ||
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Build, sign and publish chainlink image | ||
id: build-sign-publish | ||
|
@@ -99,6 +103,8 @@ jobs: | |
steps: | ||
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
- name: Notify Slack | ||
uses: smartcontractkit/.github/actions/slack-notify-git-ref@31e00facdd8f57a2bc7868b5e4c8591bf2aa3727 # [email protected] | ||
with: | ||
|
This file contains 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 |
---|---|---|
|
@@ -18,6 +18,8 @@ jobs: | |
steps: | ||
- name: Checkout Repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Setup Go | ||
uses: ./.github/actions/setup-go | ||
|
This file contains 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 |
---|---|---|
|
@@ -31,6 +31,7 @@ jobs: | |
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
|
||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | ||
|
@@ -95,6 +96,7 @@ jobs: | |
- name: Checkout .Github repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
repository: smartcontractkit/.github | ||
ref: 9aed33e5298471f20a3d630d711b96ae5538728c # [email protected] | ||
path: ./dot_github | ||
|
@@ -170,6 +172,7 @@ jobs: | |
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
|
||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | ||
|
This file contains 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 |
---|---|---|
|
@@ -18,6 +18,8 @@ jobs: | |
steps: | ||
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
|
||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | ||
id: change | ||
|
This file contains 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 |
---|---|---|
|
@@ -28,6 +28,7 @@ jobs: | |
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
repository: smartcontractkit/chainlink | ||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | ||
id: match-some | ||
|
@@ -59,6 +60,8 @@ jobs: | |
steps: | ||
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Setup NodeJS | ||
uses: ./.github/actions/setup-nodejs | ||
|
@@ -134,6 +137,7 @@ jobs: | |
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
# fetches all history for all tags and branches to provide more metadata for sonar reports | ||
fetch-depth: 0 | ||
|
||
|
@@ -191,6 +195,8 @@ jobs: | |
steps: | ||
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Setup Go | ||
uses: ./.github/actions/setup-go | ||
|
@@ -235,6 +241,8 @@ jobs: | |
steps: | ||
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Setup Go | ||
uses: ./.github/actions/setup-go | ||
|
This file contains 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 |
---|---|---|
|
@@ -43,6 +43,7 @@ jobs: | |
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
repository: smartcontractkit/chainlink | ||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | ||
id: match-some | ||
|
@@ -129,6 +130,8 @@ jobs: | |
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
- name: Golang Lint (${{ matrix.modules }}) | ||
uses: ./.github/actions/golangci-lint | ||
with: | ||
|
@@ -192,6 +195,8 @@ jobs: | |
steps: | ||
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Change Modtime of Files (cache optimization) | ||
shell: bash | ||
|
@@ -214,8 +219,10 @@ jobs: | |
|
||
- name: Replace chainlink-evm deps | ||
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' && inputs.evm-ref != ''}} | ||
env: | ||
GH_INPUTS_EVM_REF: ${{ inputs.evm-ref }} | ||
shell: bash | ||
run: go get github.com/smartcontractkit/chainlink-integrations/evm/relayer@${{ inputs.evm-ref }} | ||
run: go get github.com/smartcontractkit/chainlink-integrations/evm/relayer@$GH_INPUTS_EVM_REF | ||
|
||
- name: Setup Solana | ||
if: ${{ needs.filter.outputs.should-run-ci-core == 'true' }} | ||
|
@@ -368,6 +375,8 @@ jobs: | |
steps: | ||
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Setup node | ||
uses: actions/[email protected] | ||
|
@@ -391,8 +400,10 @@ jobs: | |
|
||
- name: Replace chainlink-evm deps | ||
if: ${{ github.event_name == 'workflow_dispatch' && inputs.evm-ref != ''}} | ||
env: | ||
GH_INPUTS_EVM_REF: ${{ inputs.evm-ref }} | ||
shell: bash | ||
run: go get github.com/smartcontractkit/chainlink-integrations/evm/relayer@${{ inputs.evm-ref }} | ||
run: go get github.com/smartcontractkit/chainlink-integrations/evm/relayer@$GH_INPUTS_EVM_REF | ||
|
||
- name: Build binary | ||
run: go build -o chainlink.test . | ||
|
@@ -452,6 +463,7 @@ jobs: | |
- name: Checkout the repo | ||
uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 # fetches all history for all tags and branches to provide more metadata for sonar reports | ||
|
||
- name: Download all workflow artifacts | ||
|
@@ -596,6 +608,7 @@ jobs: | |
exit 0 | ||
- uses: actions/[email protected] | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
- name: Setup Go | ||
uses: ./.github/actions/setup-go | ||
|
Oops, something went wrong.
Oops, something went wrong.
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.
Is there a way to do this by default so that we don't have to spam it around everywhere? (and remember to add it in the future for new workflows?)
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.
afaik the only way to achieve this would be by wrapping actions/checkout in a composite GHA and this as the default.
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.
^ yeah this would be the only way
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.
Also, I don't think it matters that much it was an easy remedy to a lot of warning level errors.
I might try and add it to
gha-workflow-validator
so it will annotate these references to make sure there's persist credentials.