Skip to content

Commit

Permalink
ci: Do not persist credentials after checkout (#7772)
Browse files Browse the repository at this point in the history
See actions/checkout#485 and
https://johnstawinski.com/2024/01/11/playing-with-fire-how-we-executed-a-critical-supply-chain-attack-on-pytorch/

In short, it is a terrible idea to persist even our default credentials
after checkout. There's no call for that, so we will now set
`persist-credentials: false` on all checkout actions.

The only exceptions are for the release job, which wants to push a tag
and create a branch, each of which explicitly persist credentials now
and explain why in a comment.
  • Loading branch information
joeyparrish authored Dec 18, 2024
1 parent 758c084 commit 7da1698
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
persist-credentials: false

- name: Lint
run: python build/check.py
Expand Down Expand Up @@ -104,6 +105,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
persist-credentials: false

# Older versions of Safari can be installed, but not to the root, and it
# can't replace the standard version, at least not on GitHub's VMs. If
Expand Down Expand Up @@ -256,6 +258,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
persist-credentials: false

- name: Docker
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/demo-version-index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
with:
# We need a list of all tags for this, so fetch the entire history.
fetch-depth: 0
persist-credentials: false

- uses: google-github-actions/auth@v2
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ jobs:
ref: main
# Use a special shaka-bot access token for releases.
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
# We want to explicitly use these credentials to push a tag.
# The job is only one more step, so they don't leak.
persist-credentials: true

- name: Tag the main branch
run: |
# Set missing git config for the tag.
Expand Down Expand Up @@ -189,6 +193,9 @@ jobs:
fetch-depth: 0
# Use a special shaka-bot access token for releases.
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
# We want to explicitly use these credentials to create the branch.
# The job is only one more step, so they don't leak.
persist-credentials: true

- name: Create release branch
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/report-incremental-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Compute incremental code coverage
id: compute
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/selenium-lab-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ needs.compute-sha.outputs.SHA }}
persist-credentials: false

- name: Install dependencies
run: npm ci
Expand Down Expand Up @@ -154,6 +155,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ needs.compute-sha.outputs.SHA }}
persist-credentials: false

- name: Set commit status to pending
if: ${{ inputs.skip_test_status == false }}
Expand Down Expand Up @@ -235,6 +237,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ needs.compute-sha.outputs.SHA }}
persist-credentials: false

- name: Set commit status to pending
if: ${{ inputs.skip_commit_status == false }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/talk-to-shaka-bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Handle command
shell: bash
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/update-screenshots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ needs.compute-sha.outputs.SHA }}
persist-credentials: false

- name: Set commit status to pending
uses: shaka-project/shaka-github-tools/set-commit-status@main
Expand Down Expand Up @@ -61,6 +62,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ needs.compute-sha.outputs.SHA }}
persist-credentials: false

- name: Get artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -114,6 +116,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ needs.compute-sha.outputs.SHA }}
persist-credentials: false

- name: Compute final status
id: compute
Expand Down

0 comments on commit 7da1698

Please sign in to comment.