Skip to content

Pin-down external GHA to SHA refs to protect against compromise#339

Merged
knuton merged 1 commit intodividat:mainfrom
yfyf:pin-down-gha
Apr 28, 2026
Merged

Pin-down external GHA to SHA refs to protect against compromise#339
knuton merged 1 commit intodividat:mainfrom
yfyf:pin-down-gha

Conversation

@yfyf
Copy link
Copy Markdown
Collaborator

@yfyf yfyf commented Apr 24, 2026

Been meaning to do this, but this was the final trigger: https://socket.dev/blog/bitwarden-cli-compromised

Doing this for e.g. actions/checkout might be overkill, but I think it is more hygienic if it is identical for all uses:

@yfyf yfyf requested a review from knuton April 24, 2026 10:41
@yfyf yfyf added reviewable Ready for initial or iterative review and removed reviewable Ready for initial or iterative review labels Apr 24, 2026
@yfyf yfyf marked this pull request as draft April 24, 2026 10:42
@yfyf
Copy link
Copy Markdown
Collaborator Author

yfyf commented Apr 24, 2026

Whoops, short SHA's don't work, need to fix.

@yfyf yfyf marked this pull request as ready for review April 24, 2026 10:55
@yfyf yfyf added the reviewable Ready for initial or iterative review label Apr 24, 2026
Copy link
Copy Markdown
Member

@knuton knuton left a comment

Choose a reason for hiding this comment

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

Confirmed that the original refs resolve to those commits with an ad hoc AI-gen bash script:

#!/bin/bash

# Check if an argument was provided
if [ -z "$1" ]; then
  echo "Usage: $0 <user/repo@sha>"
  echo "Example: $0 torvalds/linux@1bd9238"
  exit 1
fi

# Check if jq is installed
if ! command -v jq &> /dev/null; then
  echo "Error: 'jq' is required but not installed. Please install it (e.g., apt install jq, brew install jq)."
  exit 1
fi

# Parse the input format (user/repo@sha)
# IFS (Internal Field Separator) splits the string at '/' and '@'
IFS='@/' read -r user repo sha <<< "$1"

if [ -z "$user" ] || [ -z "$repo" ] || [ -z "$sha" ]; then
  echo "Error: Invalid format. Please use user/repo@sha"
  exit 1
fi

echo "Fetching commit info for $user/$repo at $sha..."
echo "--------------------------------------------------"

# Fetch data from GitHub API
response=$(curl -s -H "Accept: application/vnd.github.v3+json" \
  "https://api.github.com/repos/$user/$repo/commits/$sha")

# Check if the API returned a "Not Found" message
message=$(echo "$response" | jq -r '.message // empty')
if [ "$message" = "Not Found" ]; then
  echo "Error: Commit or repository not found."
  exit 1
fi

# Extract and print relevant information using jq
echo "$response" | jq -r '
  "Author:  " + .commit.author.name + " <" + .commit.author.email + ">",
  "Date:    " + .commit.author.date,
  "URL:     " + .html_url,
  "--------------------------------------------------\n" +
  .commit.message
'

@knuton knuton removed the reviewable Ready for initial or iterative review label Apr 28, 2026
@knuton knuton merged commit 8a820f2 into dividat:main Apr 28, 2026
30 checks passed
@yfyf yfyf deleted the pin-down-gha branch April 28, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants