Skip to content

feat: harden checkout #795

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

Merged
merged 3 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/checkout-go/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ runs:
if: inputs.ref != ''
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
with:
fetch-depth: 1
persist-credentials: false
repository: "${{ inputs.repository }}"
ref: "${{ inputs.ref }}"
Expand All @@ -55,6 +56,9 @@ runs:
repository: "${{ inputs.repository }}"
token: "${{ inputs.token }}"

- name: Verify checkout
uses: slsa-framework/slsa-github-generator/.github/actions/verify-checkout@main
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this is merged, I will update this code to a hash pin instead of "@main"


- name: Set up Go environment
uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # tag=v3.3.0
with:
Expand Down
16 changes: 16 additions & 0 deletions .github/actions/verify-checkout/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Verify a checkout's sha"
description: "verify commit sha for a GitHub repo"

runs:
using: "composite"
steps:
- name: Verify commit sha
shell: bash
run: |
set -euo pipefail

git_sha=$(git log -1 --format='%H')
if [[ "$git_sha" != "$GITHUB_SHA" ]]; then
echo "mismatch git sha $git_sha != $GITHUB_SHA"
exit 1
fi