Skip to content

FIX: Pin GitHub Actions to full-length commit SHAs - #716

Open
Dan Fiedler (danfiedler-msft) wants to merge 2 commits into
microsoft:mainfrom
danfiedler-msft:danfiedler/pin-actions
Open

FIX: Pin GitHub Actions to full-length commit SHAs#716
Dan Fiedler (danfiedler-msft) wants to merge 2 commits into
microsoft:mainfrom
danfiedler-msft:danfiedler/pin-actions

Conversation

@danfiedler-msft

@danfiedler-msft Dan Fiedler (danfiedler-msft) commented Aug 12, 2026

Copy link
Copy Markdown

Work Item / Issue Reference

AB#47291


Summary

This PR pins GitHub Actions to full-length commit SHAs for improved security and reproducibility and adds a 7 day cooldown to Dependabot configuration for GitHub Actions. This work is described in more detail at https://aka.ms/action-pinning.

Why?

Pinning actions to commit SHAs prevents supply-chain attacks where a tag could be moved to point to malicious code. This is a recommended security best practice per the GitHub Actions security hardening guide.

This change mitigates the risk of tag retargeting to malicious code as seen in incidents like the tj-actions/changed-files action compromise or codfish/semantic-release-action compromise and improves the integrity and reproducibility of the CI/CD pipeline.

What changed?

Action pinning: Third-party action references in .github/workflows/ that used mutable tag-based references (e.g., actions/checkout@v4) have been updated to full-length commit SHAs with a version comment (e.g., actions/checkout@<sha> # v4) using the pinact tool. References that were already pinned to a SHA, or that used immutable release tags, were left unchanged.

Dependabot configuration: .github/dependabot.yml has been updated to ensure a github-actions package-ecosystem section is present with a cooldown configuration (default-days: 7). This groups Dependabot PRs for GitHub Actions and enforces a minimum 7-day cooldown between updates. If the file did not exist, it was created. If a github-actions section already existed, only the cooldown block was added or its default-days value was increased to 7 if it was lower. The 7-day cooldown provides a window for the community to detect and report compromised releases before they are automatically proposed as updates, reducing exposure to supply-chain attacks via newly published malicious versions.

Is this safe to merge?

Yes. The pinned SHAs correspond to the same commits that the existing tags pointed to. No behavioral changes are introduced. You can verify the pinned SHA value using the GitHub REST API (e.g., the commit hash for actions/checkout@v7 can be found in the sha property in the JSON response for GET https://api.github.com/repos/actions/checkout/commits/v7).

Additional Information

For more information, please see https://aka.ms/action-pinning

Copilot AI lite review requested due to automatic review settings August 12, 2026 16:08
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the repository’s CI/CD supply chain by replacing mutable GitHub Actions references (e.g., @v4) with full commit-SHA pins, and introduces a Dependabot configuration for GitHub Actions with a 7-day minimum package age (cooldown) to reduce exposure to newly published compromised releases.

Changes:

  • Pinned third-party and GitHub-maintained Actions in workflows to full-length commit SHAs with version comments.
  • Pinned the marocchino/sticky-pull-request-comment reference used by the composite action that posts coverage comments.
  • Added .github/dependabot.yml to enable weekly GitHub Actions updates with grouping and a 7-day cooldown window.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/pr-format-check.yml Pins actions/github-script to a full commit SHA for PR formatting checks.
.github/workflows/pr-code-coverage.yml Pins actions/checkout and actions/upload-artifact to full commit SHAs for coverage reporting.
.github/workflows/lint-check.yml Pins actions/checkout and actions/setup-python to full commit SHAs for lint workflows.
.github/workflows/issue-triage.yml Pins actions/github-script to a full commit SHA for issue triage automation.
.github/workflows/issue-acknowledge.yml Pins actions/github-script to a full commit SHA for issue acknowledgement automation.
.github/workflows/forked-pr-coverage.yml Pins actions/checkout to a full commit SHA for forked PR coverage posting.
.github/workflows/devskim.yml Pins actions/checkout, microsoft/DevSkim-Action, and github/codeql-action/upload-sarif to full commit SHAs.
.github/dependabot.yml Adds Dependabot config for GitHub Actions with grouping and a 7-day cooldown.
.github/actions/post-coverage-comment/action.yml Pins marocchino/sticky-pull-request-comment to a full commit SHA.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/dependabot.yml
Comment on lines +8 to +11
schedule:
interval: "weekly"
cooldown:
default-days: 7
@bewithgaurav

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@bewithgaurav Gaurav Sharma (bewithgaurav) changed the title Pin GitHub Actions to full-length commit SHAs FIX: Pin GitHub Actions to full-length commit SHAs Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

checked all 7 pins against the api, each sha matches the tag it replaced. grouping looks right too.
one thing inline on the dependabot directory - else lgtm

Comment thread .github/dependabot.yml
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

with directory: "/", dependabot only reads .github/workflows, so it never sees the sticky-pull-request-comment pin in .github/actions/post-coverage-comment/action.yml. that one stays at v2.9.4 while the other six keep getting updated, better to include that dir as well, suggestion:

Suggested change
directory: "/"
directories:
- "/"
- "/.github/actions/*"

@github-actions

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

82%


📈 Total Lines Covered: 7368 out of 8963
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No lines with coverage information in this diff.


📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 59.9%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 76.6%
mssql_python.__init__.py: 77.6%
mssql_python.row.py: 77.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 81.4%
mssql_python.pybind.connection.connection.cpp: 84.3%
mssql_python.logging.py: 85.5%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

Sumit Sarabhai (sumitmsft) added a commit that referenced this pull request Aug 13, 2026
- forked-pr-coverage.yml: query /pulls?state=open (paginated) instead of
  /commits/{sha}/pulls, which never returns a fork's head commit, so fork
  PRs never resolved and no coverage comment was ever posted.
- prepare_fork_coverage_comment.py: remove the workflow_run.pull_requests
  fast-path; GitHub always sends it empty for fork runs, so it was dead
  code that only the happy-path test exercised.
- tests: point the happy-path test at the real head-SHA resolution and add
  a regression that an attacker-supplied event pull_requests entry is ignored.
- Revert action SHA pins (checkout, upload-artifact, sticky-comment) to tags
  to avoid colliding with #716, which owns SHA pinning.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

3 participants