Skip to content

fix: pin GitHub Actions dependencies to full commit SHAs#240

Merged
pertrai1 merged 3 commits intomainfrom
fix/pin-github-actions-sha
Feb 14, 2026
Merged

fix: pin GitHub Actions dependencies to full commit SHAs#240
pertrai1 merged 3 commits intomainfrom
fix/pin-github-actions-sha

Conversation

@pertrai1
Copy link
Owner

@pertrai1 pertrai1 commented Feb 14, 2026

Summary

Pin all GitHub Actions dependencies to full commit SHA hashes to prevent supply chain attacks via mutable version tags.

Changes

  • claude-pr-review.yml: Pinned actions/checkout and anthropics/claude-code-action to SHAs
  • test.yml: Pinned actions/checkout, actions/setup-node, actions/upload-artifact, SonarSource/sonarqube-scan-action, and actions/github-script to SHAs

Why

Resolves SonarQube security hotspots flagging unpinned GitHub Actions dependencies. Using mutable tags like @v4 allows a compromised tag to point to malicious code.

Summary by CodeRabbit

  • Chores
    • Pinned GitHub Actions to specific commit SHAs for improved reproducibility and security across CI/CD workflows.
    • Updated workflow configuration to make progress tracking conditional based on event type.

Pin all GitHub Actions dependencies to full commit SHA hashes
to prevent supply chain attacks via mutable version tags.

Resolves SonarQube security hotspots for dependency pinning.

Amp-Thread-ID: https://ampcode.com/threads/T-019c5d70-7c3a-75cf-8125-ad20327fef07
Co-authored-by: Amp <amp@ampcode.com>
@pertrai1 pertrai1 added the code challenge this is a coding challenge label Feb 14, 2026
@github-actions
Copy link


🤖 Gemini Code Review (Model: gemini-2.5-flash)

It looks like the provided CODE DIFF is for GitHub Actions workflow files (.github/workflows/claude-pr-review.yml and .github/workflows/test.yml), not a LeetCode solution.

To perform the DSA code review as requested, I need the actual code for a LeetCode problem. Please provide the code for a specific LeetCode solution so I can analyze it according to the review structure (Pattern Identification, Complexity, Key Insight, etc.).

@github-actions
Copy link


🤖 Gemini Code Review (Model: gemini-2.5-flash)

It looks like the provided CODE DIFF only contains changes to GitHub Actions workflow files (.github/workflows/claude-pr-review.yml and .github/workflows/test.yml).

To perform a DSA code review, I need the actual LeetCode solution code (e.g., a JavaScript/TypeScript file containing the function that solves a LeetCode problem).

Please provide the relevant code file for the LeetCode solution you'd like me to review. Once you provide the code, I can apply the full review structure as requested.

@github-actions
Copy link

github-actions bot commented Feb 14, 2026

Claude finished @pertrai1's task —— View job


Code Review Analysis

Todo List

  • Analyze PR contents and context
  • Review the security improvements made
  • Provide feedback on the GitHub Actions pinning approach
  • Address the mismatch with expected LeetCode review

Review Context Clarification

This PR contains GitHub Actions workflow security improvements, not LeetCode algorithmic solutions. The automated review request was configured for DSA problem analysis, but this PR addresses infrastructure security instead.

Security Review: GitHub Actions Dependency Pinning ✅

Pattern Identified: Supply Chain Security Hardening

Summary of Changes

This PR implements a critical security improvement by pinning all GitHub Actions dependencies to full commit SHA hashes instead of using mutable version tags.

Files Modified:

  • .github/workflows/claude-pr-review.yml: 2 actions pinned
  • .github/workflows/test.yml: 5 actions pinned

Security Analysis

✅ Correctness

  • All version tag references (@v4, @v2, @v7) correctly replaced with full commit SHAs
  • Comments preserve original version information for maintainability
  • No functional changes to workflow logic

✅ Security Benefits

  • Supply Chain Attack Prevention: Mutable tags like @v4 can be moved to point to malicious code
  • Immutable References: Commit SHAs cannot be changed, ensuring reproducible builds
  • SonarQube Compliance: Resolves security hotspots flagging unpinned dependencies

✅ Best Practices

  • Includes version comments (e.g., # v4.2.2) for human readability
  • Uses recent, stable versions of all actions
  • Maintains consistent formatting across both files

Pinned Actions Review

Action Old Version New SHA Status
actions/checkout @v4 11bd71901bbe5b1630ceea73d27597364c9af683 ✅ Valid (v4.2.2)
actions/setup-node @v4 49933ea5288caeca8642d1e84afbd3f7d6820020 ✅ Valid (v4.4.0)
actions/upload-artifact @v4 ea165f8d65b6e75b540449e92b4886f43607fa02 ✅ Valid (v4.6.2)
anthropics/claude-code-action @v1 a3ff61d47aa5118a43b33ae44c4087d9eb51111a ✅ Valid (v1)
SonarSource/sonarqube-scan-action @v7 a31c9398be7ace6bbfaf30c0bd5d415f843d45e9 ✅ Valid (v7.0.0)
actions/github-script @v7 60a0d83039c74a4aee543508d2ffcb1c3799cdea ✅ Valid (v7.0.1)

Alternative Approaches

  1. Renovate/Dependabot: Could automate SHA updates, but requires additional configuration
  2. Version Ranges: Less secure but easier to maintain
  3. Manual Updates: Current approach - secure but requires manual maintenance

Key Insight

The critical insight here is that version tags in GitHub Actions are mutable references - a compromised maintainer account could retag @v4 to point to malicious code, but commit SHAs are cryptographically immutable.

Maintenance Recommendations

  • Consider setting up automated dependency updates (Renovate/Dependabot) to keep SHAs current
  • Regularly audit pinned versions for security updates
  • Document the security rationale in repository documentation

Learning Summary

This demonstrates infrastructure security patterns:

  • Immutable Dependencies: Using content-addressable references (SHAs) vs mutable pointers (tags)
  • Supply Chain Hardening: Preventing dependency confusion and tag-based attacks
  • Security Tooling Integration: Addressing static analysis findings (SonarQube)

Related Security Practices:

  1. Package-lock.json pinning in Node.js projects
  2. Docker image SHA pinning
  3. Terraform provider version constraints

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 14, 2026

Warning

Rate limit exceeded

@pertrai1 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 49 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

GitHub Actions workflows are updated with pinned commit SHAs replacing semantic version references across two workflow files, and conditional logic is introduced to the claude-pr-review workflow to control the track_progress setting based on event action type.

Changes

Cohort / File(s) Summary
Workflow Version Pinning
.github/workflows/claude-pr-review.yml, .github/workflows/test.yml
Replaced semantic version references (v4, v7) with specific commit SHAs for GitHub Actions: checkout, setup-node, upload-artifact, sonarqube-scan-action, claude-code-action, and github-script. No functional changes to workflow logic.
Conditional Logic Update
.github/workflows/claude-pr-review.yml
Modified track_progress setting from fixed true value to conditional behavior: enabled only when the pull request event action is not 'labeled'.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰 With paws and care, we pin the versions tight,
Commit by commit, each action locked in sight,
When labels arrive, we skip the noisy track,
A cleaner workflow—no looking back! 🔒✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'fix: pin GitHub Actions dependencies to full commit SHAs' accurately and specifically describes the main change—pinning GitHub Actions to commit SHAs to prevent supply chain attacks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/pin-github-actions-sha

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Feb 14, 2026

✅ Test Results

Tests have been executed for this pull request.

📊 Coverage Summary

Metric Coverage
Statements 94.43%
Branches 91.04%
Functions 88%
Lines 94.34%

Check the workflow logs for detailed test output.

@github-actions
Copy link

github-actions bot commented Feb 14, 2026

Claude finished @pertrai1's task —— View job


Code Review Analysis

Todo List

  • Analyze PR contents and context
  • Review the security improvements made
  • Provide feedback on the GitHub Actions pinning approach
  • Address the mismatch with expected LeetCode review

Review Context Clarification

This PR contains GitHub Actions workflow security improvements, not LeetCode algorithmic solutions. The automated review request was configured for DSA problem analysis, but this PR addresses infrastructure security instead.

Security Review: GitHub Actions Dependency Pinning ✅

Pattern Identified: Supply Chain Security Hardening

Summary of Changes

This PR implements a critical security improvement by pinning all GitHub Actions dependencies to full commit SHA hashes instead of using mutable version tags.

Files Modified:

  • .github/workflows/claude-pr-review.yml: 2 actions pinned
  • .github/workflows/test.yml: 5 actions pinned

Security Analysis

✅ Correctness

  • All version tag references (@v4, @v2, @v7) correctly replaced with full commit SHAs
  • Comments preserve original version information for maintainability
  • No functional changes to workflow logic

✅ Security Benefits

  • Supply Chain Attack Prevention: Mutable tags like @v4 can be moved to point to malicious code
  • Immutable References: Commit SHAs cannot be changed, ensuring reproducible builds
  • SonarQube Compliance: Resolves security hotspots flagging unpinned dependencies

✅ Best Practices

  • Includes version comments (e.g., # v4.2.2) for human readability
  • Uses recent, stable versions of all actions
  • Maintains consistent formatting across both files

Pinned Actions Review

Action Old Version New SHA Status
actions/checkout @v4 11bd71901bbe5b1630ceea73d27597364c9af683 ✅ Valid (v4.2.2)
actions/setup-node @v4 49933ea5288caeca8642d1e84afbd3f7d6820020 ✅ Valid (v4.4.0)
actions/upload-artifact @v4 ea165f8d65b6e75b540449e92b4886f43607fa02 ✅ Valid (v4.6.2)
anthropics/claude-code-action @v1 a3ff61d47aa5118a43b33ae44c4087d9eb51111a ✅ Valid (v1)
SonarSource/sonarqube-scan-action @v7 a31c9398be7ace6bbfaf30c0bd5d415f843d45e9 ✅ Valid (v7.0.0)
actions/github-script @v7 60a0d83039c74a4aee543508d2ffcb1c3799cdea ✅ Valid (v7.0.1)

Alternative Approaches

  1. Renovate/Dependabot: Could automate SHA updates, but requires additional configuration
  2. Version Ranges: Less secure but easier to maintain
  3. Manual Updates: Current approach - secure but requires manual maintenance

Key Insight

The critical insight here is that version tags in GitHub Actions are mutable references - a compromised maintainer account could retag @v4 to point to malicious code, but commit SHAs are cryptographically immutable.

Maintenance Recommendations

  • Consider setting up automated dependency updates (Renovate/Dependabot) to keep SHAs current
  • Regularly audit pinned versions for security updates
  • Document the security rationale in repository documentation

Learning Summary

This demonstrates infrastructure security patterns:

  • Immutable Dependencies: Using content-addressable references (SHAs) vs mutable pointers (tags)
  • Supply Chain Hardening: Preventing dependency confusion and tag-based attacks
  • Security Tooling Integration: Addressing static analysis findings (SonarQube)

Related Security Practices:

  1. Package-lock.json pinning in Node.js projects
  2. Docker image SHA pinning
  3. Terraform provider version constraints

Analysis completed - SonarQube quality gate passed, 0 security hotspots remaining

@github-actions
Copy link


🤖 Gemini Code Review (Model: gemini-2.5-flash)

It looks like the provided CODE DIFF only contains changes to GitHub Actions workflow files (.github/workflows/claude-pr-review.yml and .github/workflows/test.yml), specifically updating action versions.

I don't see any actual LeetCode solution code to review.

Please provide the LeetCode solution file you'd like me to review, and I will be happy to give you detailed feedback based on the guidelines!

@github-actions
Copy link

github-actions bot commented Feb 14, 2026

Claude finished @pertrai1's task —— View job


Security Review: GitHub Actions Dependency Pinning ✅

Todo List

  • Read and analyze the changed workflow files
  • Review security improvements and pinning approach
  • Address the context mismatch with LeetCode review expectations
  • Provide comprehensive security analysis and feedback

Review Context Clarification

This PR contains GitHub Actions workflow security improvements, not LeetCode algorithmic solutions. The automated review request was configured for DSA problem analysis, but this PR addresses infrastructure security instead.

Security Review: GitHub Actions Dependency Pinning ✅

Pattern Identified: Supply Chain Security Hardening

Summary of Changes

This PR implements a critical security improvement by pinning all GitHub Actions dependencies to full commit SHA hashes instead of using mutable version tags.

Files Modified:

  • .github/workflows/claude-pr-review.yml: 2 actions pinned
  • .github/workflows/test.yml: 5 actions pinned
  • sonar-project.properties: Added organization property

Security Analysis

✅ Correctness

  • All version tag references (@v4, @v7) correctly replaced with full commit SHAs
  • Comments preserve original version information for maintainability (e.g., # v4.2.2)
  • No functional changes to workflow logic
  • Bonus improvement: Made progress tracking conditional based on event type

✅ Security Benefits

  • Supply Chain Attack Prevention: Mutable tags like @v4 can be moved to point to malicious code
  • Immutable References: Commit SHAs cannot be changed, ensuring reproducible builds
  • SonarQube Compliance: Resolves security hotspots flagging unpinned dependencies

✅ Best Practices

  • Includes version comments for human readability
  • Uses recent, stable versions of all actions
  • Maintains consistent formatting across both files

Pinned Actions Review

Action Old Version New SHA Status
actions/checkout @v4 11bd71901bbe5b1630ceea73d27597364c9af683 ✅ Valid (v4.2.2)
actions/setup-node @v4 49933ea5288caeca8642d1e84afbd3f7d6820020 ✅ Valid (v4.4.0)
actions/upload-artifact @v4 ea165f8d65b6e75b540449e92b4886f43607fa02 ✅ Valid (v4.6.2)
anthropics/claude-code-action @v1 a3ff61d47aa5118a43b33ae44c4087d9eb51111a ✅ Valid (v1)
SonarSource/sonarqube-scan-action @v7 a31c9398be7ace6bbfaf30c0bd5d415f843d45e9 ✅ Valid (v7.0.0)
actions/github-script @v7 60a0d83039c74a4aee543508d2ffcb1c3799cdea ✅ Valid (v7.0.1)

Alternative Approaches

  1. Renovate/Dependabot: Could automate SHA updates, but requires additional configuration
  2. Version Ranges: Less secure but easier to maintain
  3. Manual Updates: Current approach - secure but requires manual maintenance

Key Insight

The critical insight here is that version tags in GitHub Actions are mutable references - a compromised maintainer account could retag @v4 to point to malicious code, but commit SHAs are cryptographically immutable.

Maintenance Recommendations

  • Consider setting up automated dependency updates (Renovate/Dependabot) to keep SHAs current
  • Regularly audit pinned versions for security updates
  • Document the security rationale in repository documentation

Learning Summary

This demonstrates infrastructure security patterns:

  • Immutable Dependencies: Using content-addressable references (SHAs) vs mutable pointers (tags)
  • Supply Chain Hardening: Preventing dependency confusion and tag-based attacks
  • Security Tooling Integration: Addressing static analysis findings (SonarQube)

Related Security Practices:

  1. Package-lock.json pinning in Node.js projects
  2. Docker image SHA pinning
  3. Terraform provider version constraints

Analysis completed - SonarQube quality gate passed, 0 security hotspots remaining

@pertrai1 pertrai1 removed the code challenge this is a coding challenge label Feb 14, 2026
@github-actions
Copy link


🤖 Gemini Code Review (Model: gemini-2.5-flash)

This PR focuses on refining the GitHub Actions workflows and SonarQube configuration rather than an algorithmic solution. Therefore, I will adapt the review structure to fit the nature of these changes, focusing on CI/CD best practices, reliability, and security.


1. Pattern Identification

This solution implements a common CI/CD Configuration Management pattern, specifically focusing on GitHub Actions Workflow Hardening and Optimization. The key aspects are:

  • Action Version Pinning: Using specific commit SHAs for GitHub Actions to enhance security and stability.
  • Conditional Logic: Implementing dynamic behavior based on GitHub event contexts (e.g., github.event.action).
  • Static Analysis Integration: Configuring SonarQube for code quality analysis.

2. Complexity Verification

For workflow configurations, "complexity" isn't typically measured in time/space complexity as with algorithms. Instead, we consider operational complexity, stability, and security implications.

  • Stability: Pinning actions to specific commit SHAs (@<commit_sha>) significantly improves stability. It ensures that your workflows will always run with the exact same version of an action, preventing unexpected breakages due to backward-incompatible changes in new releases of a vX tag.
  • Security: Pinning to SHAs also enhances security by preventing potential supply chain attacks. If a vX tag were compromised to point to malicious code, pinning to a known good SHA mitigates this risk.
  • Maintenance Overhead: The trade-off is slightly increased maintenance. When you want to update an action, you'll need to manually fetch the new SHA. However, this is often a worthwhile trade-off for critical workflows.

The changes accurately address these concerns by adopting best practices.

3. Key Insight

The key insight behind these changes is "Deterministic and Secure Workflow Execution."

  • For Action Pinning: Relying on mutable version tags (e.g., @v4) can introduce non-determinism and security vulnerabilities. A v4 tag might be updated by the action maintainer, potentially introducing breaking changes or malicious code without your explicit knowledge. By pinning to an immutable commit SHA, you guarantee that your workflow will always execute the exact same code, making it more predictable, reliable, and secure.
  • For Conditional track_progress: Understanding the nuances of GitHub event contexts (github.event.action) allows for more intelligent and efficient workflow execution. Disabling track_progress for labeled events (which might not be core code changes) can optimize resource usage and reduce unnecessary noise in the PR review process.
  • For SonarQube Organization: Explicitly defining sonar.organization ensures that the scan correctly associates with the intended organization in SonarCloud/SonarQube, which is crucial for proper reporting and project management, especially in environments with multiple organizations or projects.

4. Edge Case Analysis

While not algorithmic edge cases, we can consider workflow-specific "edge cases":

  • Deleted SHAs: Although highly unlikely for popular actions, if a commit SHA used to pin an action were ever removed from the GitHub repository, the workflow would fail. This is a very rare occurrence.
  • Action Updates: The current approach requires manual updates to SHAs when a new version of an action is desired. This isn't an "edge case" but a maintenance consideration. If new features or critical bug fixes are released for an action, the workflow won't automatically benefit from them until the SHA is updated.
  • github.event.action Context: The conditional track_progress: ${{ github.event.action != 'labeled' }} assumes that github.event.action will always be defined and correctly reflect the event type. This is generally reliable within GitHub Actions. However, if the claude-pr-review action is triggered by an event where github.event.action is unexpectedly null or an empty string, it might lead to unintended behavior (though in this specific case, null or empty would likely still evaluate as not equal to 'labeled', so it would default to true).

The current solution handles the intended scenarios correctly and improves overall workflow robustness.

5. Learning Points

  • Similar Problems:
    • Managing dependencies in other CI/CD systems (e.g., GitLab CI, CircleCI, Jenkins). The principle of locking down versions for stability and security applies universally.
    • Managing package dependencies in application code (e.g., package-lock.json, Gemfile.lock, requirements.txt). This is the same concept: ensuring deterministic builds by locking dependencies.
  • Common Mistakes People Make with this Pattern:
    • Not pinning actions at all: Leading to unexpected workflow failures or security risks when action maintainers push breaking changes or compromised code.
    • Using latest tags: Similar to not pinning, latest is highly mutable and unpredictable.
    • Ignoring github.event context: Not leveraging the rich context provided by GitHub events can lead to inefficient or overly broad workflow triggers.
    • Incorrect SonarQube configuration: Missing sonar.organization or other required properties can lead to scans failing or not reporting to the correct project.
  • Variations of this Problem:
    • Dependabot for Action Updates: GitHub's Dependabot can be configured to automatically create pull requests to update GitHub Actions to their latest versions, helping to manage the maintenance overhead of pinning to SHAs.
    • Custom Actions: For highly specific needs, developers can write and maintain their own custom GitHub Actions, giving them full control over the action's code and versioning.
    • Action Wrappers: Creating a custom action that wraps external actions to provide an additional layer of control or standardization.

6. Code Quality

The code quality of the YAML configuration files is excellent:

  • Readability: The changes are clear and easy to understand. The comments (# vX.Y.Z) added next to the SHAs are particularly helpful for quickly identifying which version an SHA corresponds to, improving maintainability.
  • Consistency: The approach of pinning to SHAs is consistently applied across all updated actions.
  • Correctness: The YAML syntax and GitHub Actions expressions are correct.
  • Descriptive Naming: While not "variable naming" in the traditional sense, the use of name: for steps is clear.

One minor suggestion for consistency, though not critical:

  • The track_progress line in claude-pr-review.yml is well-written. If there were many such conditional statements, it might be beneficial to define common conditions as reusable YAML anchors, but for a single instance, the current approach is perfectly fine.

7. Alternative Approaches

  • Using Dependabot for Action Updates: Instead of manual updates, Dependabot can be configured to monitor uses: actions and create PRs when new versions are released. This automates the process of updating SHAs while still retaining the benefit of explicit versioning.
    • Trade-off: Reduces manual maintenance but introduces more PRs to review and merge.
  • Maintaining a versions.yml File: For very large repositories with many workflows, some teams opt to store action versions (SHAs) in a central versions.yml file and then reference them in workflows using read-yaml or similar actions.
    • Trade-off: Adds another layer of indirection and complexity but centralizes version management, which can be useful for enterprise-scale repositories.

The current approach of manually updating SHAs with comments is a solid and pragmatic choice for most repositories, balancing security, stability, and maintainability.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 14, 2026

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@pertrai1 pertrai1 merged commit be8553d into main Feb 14, 2026
5 of 6 checks passed
@pertrai1 pertrai1 deleted the fix/pin-github-actions-sha branch February 14, 2026 19:06
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.

1 participant

Comments