fix: [Security] Pin GitHub Actions to a full-length commit SHA#4542
Conversation
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 4b317c8 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
BenchmarksBenchmark execution time: 2026-03-16 13:45:18 Comparing candidate commit 4b317c8 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 157 metrics, 7 unstable metrics.
|
615aedf
into
main
### What does this PR do? Completes the supply-chain hardening started in #4542 by automating ongoing maintenance of SHA-pinned GitHub Actions: 1. Switches Dependabot to a **weekly** schedule so SHA pins stay current. 2. Pins the three remaining `@v` tag refs in `test-apps.cue` to full commit SHAs. 3. Adds an **auto-sync workflow** that patches `test-apps.cue` whenever Dependabot bumps SHAs in `test-apps.yml`. ### Motivation After #4542, Dependabot can update YAML workflow files but not the CUE source template (`test-apps.cue`). Without automation, every Dependabot PR creates drift: `test-apps.yml` gets updated SHAs while `test-apps.cue` stays stale. A developer running `make test-apps.yml` would silently revert all pinned SHAs back to `@v` tags, undoing the security fix. A naive CI drift check (`cue export && git diff --exit-code`) doesn't work because `cue export` cannot produce YAML comments — Dependabot adds version comments (`# vX.Y.Z`) that the CUE exporter can't reproduce, so the diff would always be non-empty regardless of SHA correctness. The auto-sync workflow triggers on Dependabot branch pushes, extracts updated SHAs from `test-apps.yml` via `grep`/`sed`, patches `test-apps.cue`, and commits back to the branch. Uses `push` trigger (not `pull_request_target`) for simplicity and full write access without untrusted-code risks. The `GITHUB_TOKEN` push safety prevents infinite workflow loops. ### Reviewer's Checklist - [ ] Changed code has unit tests for its functionality at or near 100% coverage. - [ ] [System-Tests](https://github.com/DataDog/system-tests/) covering this feature have been added and enabled with the va.b.c-dev version tag. - [ ] There is a benchmark for any new code, or changes to existing code. - [ ] If this interacts with the agent in a new way, a system test has been added. - [ ] New code is free of linting errors. You can check this by running `make lint` locally. - [ ] New code doesn't break existing tests. You can check this by running `make test` locally. - [ ] Add an appropriate team label so this PR gets put in the right place for the release notes. - [ ] All generated files are up to date. You can check this by running `make generate` locally. - [ ] Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running `make fix-modules` locally. Unsure? Have a question? Request a review! Co-authored-by: kemal.akkoyun <kemal.akkoyun@datadoghq.com>
Pin GitHub Actions to SHA hashes
This automated PR pins third-party GitHub Actions references from mutable tag versions (e.g.,
@v4) to their corresponding SHA hashes (e.g.,@abc123...). The original tag is preserved as a comment for readability. Your workflows will work exactly the same way. Internal actions (under theDataDogorganization) are not pinned.Read https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions for more details and info on how to configure this for entire repos.
Why pin GitHub Actions?
Git tags are mutable: they can be moved to point to different commits at any time. A compromised or malicious action maintainer could update a tag to inject arbitrary code into your CI workflows (see the tj-actions incident). Pinning to SHA hashes ensures you always run the exact code you reviewed, protecting your repository from supply chain attacks such as the tj-actions incident.
What if something breaks?
If a pinned action doesn't work for your use case, you can push a commit directly to this branch to fix it. As a last resort, reach out to #sdlc-security on Slack.
Set up Dependabot or Renovate for automatic updates
Once actions are pinned to SHA hashes, you should configure Dependabot or Renovate to receive weekly update PRs when new versions are available.
In the case of Dependabot, create or update
.github/dependabot.yml:Dependabot will automatically propose PRs that update both the SHA hash and the version comment like in this example.
This PR was automatically generated by the GitHub Actions Pinning tool, owned by #sdlc-security.