Skip to content

ci: pin third-party actions to commit SHAs - #20

Merged
polewskm merged 3 commits into
mainfrom
ci/pin-third-party-actions
Nov 4, 2026
Merged

polewskm merged 3 commits into
mainfrom
ci/pin-third-party-actions

Conversation

@polewskm

@polewskm polewskm commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Why

CodeQL's extended query suite, now on for every NCodeGroup repository, reports a third-party action referenced by a tag as actions/unpinned-tag: whoever controls that repository can move the tag, and the step runs with this workflow's token and secrets. A full commit SHA is the one reference nobody can move.

Changes

Third-party actions are pinned to the commit SHA of the release their tag pointed at, with the release in a comment, so Dependabot's github-actions updates keep bumping them (it updates the SHA and the comment together). Behavior is unchanged: each SHA is the commit the tag resolves to today.

Verified

Each SHA was resolved from the tag with gh api repos/<action>/commits/<tag> and matched to the release tag with git ls-remote --tags. The CodeQL alerts for these lines close when this merges.

@polewskm
polewskm deployed to code-review October 31, 2026 03:47 — with GitHub Actions Active

@ncode-review ncode-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 NCode Review at 99403f2: 1 new finding on the changed lines.

Not on a changed line:

  • 🟠 F1 Should fix: Checkout steps leave the job token in .git/config .github/workflows/main.yml:26. None of the actions/checkout steps (lines 26, 57, 85) set persist-credentials: false, so in the publish job, which has contents: write, a token with write access stays in .git/config. Fix: Add with: persist-credentials: false to each checkout step, unless a later step really needs to push. This PR doesn't change these lines, so it can go here or in a follow-up.
  • 🟡 F2 Nit: Are first-party actions meant to stay on tags? ci.yml already pins them .github/workflows/main.yml:26. actions/checkout@v7 (lines 26, 57, 85), actions/setup-dotnet@v6 (lines 28, 63, 95), actions/upload-artifact@v7 (line 41) and actions/download-artifact@v8 (lines 59, 87) are still on mutable tags, but ci.yml and code-review.yml pin checkout and setup-dotnet to SHAs. Fix: Pin the remaining actions using the SHAs already in ci.yml (checkout 3d3c42e5…, setup-dotnet a98b5685…) plus SHAs for upload/download-artifact. Or, if first-party actions are deliberately left on tags, say so in the PR description.
  • 🟡 F3 Nit: Publish step: stored API key, no --skip-duplicate, no .snupkg push, no version/tag check .github/workflows/main.yml:99. The publish step (not changed by this PR) pushes only *.nupkg using secrets.NUGET_APIKEY, without --skip-duplicate, without pushing the .snupkg files, and without checking that the package versions match the release tag. Fix: Is this in scope for a later hardening PR? If so: switch to NuGet trusted publishing via OIDC, add --skip-duplicate, push the .snupkg files, and check versions against the tag before pushing.

Comment thread .github/workflows/main.yml Resolved
@ncode-review

ncode-review Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Superseded by the review at 10bfa2d.

polewskm commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Autopilot: Answering the NCode Review summary and review (F1-F4).

  • F1 (should fix, checkout credentials): real. I checked all three jobs in main.yml: no step runs git push, tags or otherwise uses the stored git credentials; the gh release upload step passes GITHUB_TOKEN in its own env. Fixed in 10bfa2d by adding with: persist-credentials: false to the three actions/checkout steps.
  • F2 (nit, first-party actions on tags): intentional. This PR pins third-party actions, which is what CodeQL's actions/unpinned-tag reports; first-party actions/* stay on tags unless the maintainer wants them pinned too. The PR description already says third-party only. I did not widen the scope.
  • F3 (nit, publish step hardening): out of scope for a pinning PR. Note that the project-template update in Update from project-template v0.41.0 to v0.61.2 #22 adds .github/workflows/publish.yml (NuGet trusted publishing via OIDC) which covers this; the main.yml publish job would then be redundant, a decision for the maintainer.
  • F4 (nit, dorny/test-reporter): answered in its thread; follow-up for the maintainer.

I also removed the generated-by line from the PR description, which made the required Commit attribution check fail; editing the description re-runs it. PR #20 is behind main but merges cleanly (no conflicts), so I did not merge main into it.


Generated by Claude Code

@polewskm

polewskm commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

/review

@ncode-review

ncode-review Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

🤖 Review complete

Verdict: ✅ Approve — Re-review of what changed since the last review at 99403f2: 3 hunks in 1 file, by correctness only. No further findings above nits.

1 reviewer run — 0 findings (run details)

Reviewer Model Findings Top
correctness sonnet-5-5 0 🟢

Trial: findings are posted as review threads and in the check run. $0.01 on Amazon Bedrock, 11s, at 10bfa2d. (how to interact)

📋 Outcomes

Merged at abd565c: 0 fixed, 1 dismissed, 0 acknowledged, 0 ignored.

Finding Reviewer Severity Outcome
F4 rule-check 🟡 Nit 👎 dismissed

@polewskm
polewskm enabled auto-merge November 4, 2026 01:46
@polewskm
polewskm merged commit 0b71dc8 into main Nov 4, 2026
10 checks passed
@polewskm
polewskm deleted the ci/pin-third-party-actions branch November 4, 2026 01:48
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