Skip to content

Commit f5bf17e

Browse files
authored
Pin GitHub Action references to commit SHAs (#333)
## Summary Pin all GitHub Action references to full commit SHAs instead of mutable version tags to prevent supply chain attacks. This is a security best practice recommended by [GitHub's security hardening guide](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-third-party-actions). Mutable version tags (e.g. `@v2`) can be moved to point to different commits, meaning a compromised upstream action could execute malicious code in our workflows. Pinning to commit SHAs ensures we always run the exact code we've reviewed. ## Changes | Old Reference | New Reference | Hash | Version | |--------------|---------------|------|---------| | actions/checkout@v4 | actions/checkout@34e1148 | 34e114876b0b11c390a56381ad16ebd13914f8d5 | [v4.3.1](https://github.com/actions/checkout/releases/tag/v4.3.1) | | anthropics/claude-code-base-action@beta | anthropics/claude-code-base-action@e8132bc | e8132bc5e637a42c27763fc757faa37e1ee43b34 | [v0.063](http://github.com/anthropics/claude-code-base-action/releases/tag/v0.0.63) | | aws-actions/application-observability-for-aws@v1 | aws-actions/application-observability-for-aws@95bb59e | 95bb59e4538ba9ef746805d8a2bbbe531ba2a728 | [v1.1.1](https://github.com/aws-actions/application-observability-for-aws/releases/tag/v1.1.1) | | aws-actions/configure-aws-credentials@v4 | aws-actions/configure-aws-credentials@7474bc4 | 7474bc4690e29a8392af63c5b98e7449536d5c3a | [v4.3.1](https://github.com/aws-actions/configure-aws-credentials/releases/tag/v4.3.1) | ## Static Code Check Added a `static-code-checks` job to `release-build.yml` that will fail PRs introducing mutable GitHub Action version references.
1 parent 07006fd commit f5bf17e

3 files changed

Lines changed: 43 additions & 7 deletions

File tree

.github/workflows/awsapm.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ jobs:
4242

4343
steps:
4444
- name: Checkout repository
45-
uses: actions/checkout@v4
45+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 #v4.3.1
4646

4747
- name: Configure AWS credentials
48-
uses: aws-actions/configure-aws-credentials@v4
48+
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a #v4.3.1
4949
with:
5050
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
5151
aws-region: ${{ vars.AWS_REGION || 'us-east-1' }}
@@ -55,7 +55,7 @@ jobs:
5555
# - https://github.com/anthropics/claude-code-action/issues/693
5656
- name: Prepare Investigation Context
5757
id: prepare
58-
uses: aws-actions/application-observability-for-aws@v1
58+
uses: aws-actions/application-observability-for-aws@95bb59e4538ba9ef746805d8a2bbbe531ba2a728 #v1.1.1
5959
with:
6060
bot_name: "@awsapm"
6161
cli_tool: "claude_code"
@@ -64,7 +64,7 @@ jobs:
6464
- name: Run Claude Investigation - Attempt 1
6565
id: claude
6666
continue-on-error: true
67-
uses: anthropics/claude-code-base-action@beta
67+
uses: anthropics/claude-code-base-action@e8132bc5e637a42c27763fc757faa37e1ee43b34 #v0.0.63
6868
with:
6969
use_bedrock: "true"
7070
# Set to any Bedrock Model ID
@@ -77,7 +77,7 @@ jobs:
7777
- name: Run Claude Investigation - Attempt 2
7878
id: claude-retry
7979
if: steps.claude.outcome == 'failure'
80-
uses: anthropics/claude-code-base-action@beta
80+
uses: anthropics/claude-code-base-action@e8132bc5e637a42c27763fc757faa37e1ee43b34 #v0.0.63
8181
with:
8282
use_bedrock: "true"
8383
model: "us.anthropic.claude-sonnet-4-5-20250929-v1:0"
@@ -88,7 +88,7 @@ jobs:
8888
# Step 3: Post results back to GitHub issue/PR
8989
- name: Post Investigation Results
9090
if: always()
91-
uses: aws-actions/application-observability-for-aws@v1
91+
uses: aws-actions/application-observability-for-aws@95bb59e4538ba9ef746805d8a2bbbe531ba2a728 #v1.1.1
9292
with:
9393
cli_tool: "claude_code"
9494
comment_id: ${{ steps.prepare.outputs.awsapm_comment_id }}

.github/workflows/pr-build.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: MIT
3+
4+
name: PR Build
5+
on:
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
# TODO: Add build/test steps
12+
jobs:
13+
static-code-checks:
14+
runs-on: ubuntu-latest
15+
steps:
16+
17+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
18+
with:
19+
fetch-depth: 0
20+
- name: Check for versioned GitHub actions
21+
if: always()
22+
run: |
23+
# Get changed GitHub workflow/action files
24+
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD | grep -E "^\.github/(workflows|actions)/.*\.ya?ml$" || true)
25+
26+
if [ -n "$CHANGED_FILES" ]; then
27+
# Check for any versioned actions, excluding comments and this validation script
28+
VIOLATIONS=$(grep -Hn "uses:.*@v" $CHANGED_FILES | grep -v "grep.*uses:.*@v" | grep -v "#.*@v" || true)
29+
if [ -n "$VIOLATIONS" ]; then
30+
echo "Found versioned GitHub actions. Use commit SHAs instead:"
31+
echo "$VIOLATIONS"
32+
exit 1
33+
fi
34+
fi
35+
36+
echo "No versioned actions found in changed files"

.github/workflows/release-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
secrets: inherit
2020
with:
2121
aws-region: 'us-east-1'
22-
test-cluster-name: 'e2e-enablement-script-test'
22+
test-cluster-name: 'e2e-enablement-script-test'

0 commit comments

Comments
 (0)