FIX: Pin GitHub Actions to full-length commit SHAs - #716
FIX: Pin GitHub Actions to full-length commit SHAs#716Dan Fiedler (danfiedler-msft) wants to merge 2 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
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-commentreference used by the composite action that posts coverage comments. - Added
.github/dependabot.ymlto 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.
| schedule: | ||
| interval: "weekly" | ||
| cooldown: | ||
| default-days: 7 |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Gaurav Sharma (bewithgaurav)
left a comment
There was a problem hiding this comment.
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
| version: 2 | ||
| updates: | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" |
There was a problem hiding this comment.
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:
| directory: "/" | |
| directories: | |
| - "/" | |
| - "/.github/actions/*" |
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changesNo 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
|
- 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>
Work Item / Issue Reference
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.ymlhas been updated to ensure agithub-actionspackage-ecosystem section is present with acooldownconfiguration (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 agithub-actionssection already existed, only thecooldownblock was added or itsdefault-daysvalue 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@v7can be found in theshaproperty in the JSON response forGET https://api.github.com/repos/actions/checkout/commits/v7).Additional Information
For more information, please see https://aka.ms/action-pinning