Visitar URL original
Require Checkout Steps Not to Persist Credentials by ptr727 · Pull Request #4171 · ptr727/ProjectTemplate · GitHub
Skip to content

Require Checkout Steps Not to Persist Credentials - #4171

Merged
ptr727 merged 2 commits into
developfrom
burndown/checkout-persist-credentials
Nov 13, 2026
Merged

ptr727 merged 2 commits into
developfrom
burndown/checkout-persist-credentials

Conversation

@ptr727

@ptr727 ptr727 commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

actions/checkout writes the job's token into the checkout's git configuration by default, so every later step in the job, and anything it runs, can read a credential it was never handed. Per the maintainer's recorded answer on the issue (option 1), GOVERNANCE.md "Workflow YAML Conventions" gains a "Checkout credentials" rule: every actions/checkout step sets persist-credentials: false, and a job whose later step runs an authenticated git command against the remote keeps it with persist-credentials: true and a comment naming that step.

The hub workflows and the release-with-smoke caller snippet (with its documented copy in docs/reusable-workflows.md) are swept to match.

Per-job audit

Set to false, since no later step needs git authentication:

  • build-docker-task.yml: docker-prepare, docker-build-base, build-docker. The build context is a local path.
  • build-release-task.yml: dotnet-publish, build-nuget, build-pypi, build-release-asset.
  • deploy-site-task.yml: deploy. The deploy goes over SSH/rsync, not git, and the generator reads history locally.
  • get-version-task.yml: get-version. NBGV reads local history only.
  • publish-docker-readme-task.yml: get-repos, publish-readme.
  • validate-task.yml: lint, unit-test, validate. The prose gate's retry git fetch runs only when its base does not resolve, and in this caller the base is HEAD^1 of the pull request merge checkout, which is always local.
  • check-upstream-version-task.yml and run-codegen-pull-request-task.yml: peter-evans/create-pull-request configures its own HTTPS credential from its token input (gitConfigHelper.configureToken(inputs.branchToken) at the pinned SHA), so it does not read the persisted one. The checkout keeps its token: input for its own fetch.

Kept with persist-credentials: true and an inline reason:

  • build-release-task.yml github-release: the "Supersede a release the token cannot tag step" runs git fetch and git ls-remote against origin.

The release-with-smoke caller snippet's changes job (and its copy in docs/reusable-workflows.md) sets false too. Its "Filter changed paths step" now runs only on a pull_request event, where dorny/paths-filter reads the changed files from the API. On a dispatch it would have fetched the base branch with git for an output smoke-build ignores on a dispatch anyway, and an empty output there is what the doc's dispatch-bypass note already expects.

Already compliant and unchanged: canonical-review-sweep.yml, test-pull-request.yml.

Adopter hooks the tasks run (./.github/actions/*) were checked with a code search across the owner's repositories for git fetch, git push, git ls-remote, git pull, and git clone. The one hit is a public repository's validate hook, whose fetch works anonymously and falls back safely when it fails. docs/reusable-workflows.md "The Hook Contract" now states that a hook runs with no persisted git credential.

scripts/build_dist.py --check reports the generated skill distributions current, so no skill include carries this section.

The new comment lines are owed by the rule itself, so this pull request carries the comments label.

Closes on promotion: #1650

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Security
    • Checkout credentials are no longer persisted by default across build, release, validation, and deployment workflows. Steps that require authenticated Git access retain credentials explicitly.
    • Workflow hooks that access remotes must provide their own credentials.
  • Documentation
    • Updated workflow guidance and examples to reflect credential handling and to run changed-path filtering only for pull request events.

ptr727 and others added 2 commits November 13, 2026 11:31
actions/checkout writes the job's token into the checkout's git
configuration by default, so every later step and anything it runs can
read it. GOVERNANCE.md "Workflow YAML Conventions" gains the rule that
every checkout step sets persist-credentials: false, and a job whose
later step needs the token keeps it with an inline reason.

The hub workflows and the smoke caller snippet are swept to match. Two
steps keep the credential: the github-release job's supersede step runs
git fetch and git ls-remote, and outside a pull request the smoke
snippet's paths filter fetches the base branch with git.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ract

The smoke snippet's paths filter fetched with git only on a dispatch,
where nothing reads its result, so the step runs on pull requests alone
and the checkout takes persist-credentials: false. The hook contract
states that a hook gets no persisted git credential, and the governance
rule names the token the checkout persists rather than the job's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings November 13, 2026 19:40
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Nov 13, 2026
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Workflow checkouts now disable persisted Git credentials by default. The GitHub release checkout retains credentials for later authenticated Git commands. Governance guidance and reusable workflow examples describe credential handling. The smoke workflow and its caller example limit changed-path filtering to pull request events.

Changes: Checkout credential settings

Layer / File(s) Summary
Credential convention and examples
GOVERNANCE.md, docs/reusable-workflows.md, catalog/snippets/workflows/test-pull-request-smoke.yml
Governance and reusable workflow guidance describe credential handling for checkouts and hooks. The smoke workflow and caller example disable persisted credentials and run changed-path filtering only for pull request events.
Workflow checkout settings
.github/workflows/build-docker-task.yml, .github/workflows/build-release-task.yml, .github/workflows/check-upstream-version-task.yml, .github/workflows/deploy-site-task.yml, .github/workflows/get-version-task.yml, .github/workflows/publish-docker-readme-task.yml, .github/workflows/run-codegen-pull-request-task.yml, .github/workflows/validate-task.yml
Workflow checkouts disable persisted credentials. The GitHub release checkout explicitly retains credentials for later git fetch and git ls-remote commands.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · up to 991b6

Workflow checkouts no longer leave a Git credential in the workspace, except the release job that needs one for later fetch and ls-remote calls. The docs now say hooks must supply their own credential for authenticated Git. No concrete breakage was found in the repository's own workflows or actions, and the change is simple to revert, so it is ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Require Checkout Steps Not to Persist Credentials" matches the main change. The PR adds a GOVERNANCE.md rule requiring actions/checkout steps to set persist-credentials: false, and the work…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Require Checkout Steps Not to Persist Credentials" matches the main change. The PR adds a GOVERNANCE.md rule requiring actions/checkout steps to set persist-credentials: false, and the workflow files and docs are updated to comply. The title is specific, short, and states the primary change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8dbea41 and 991b67f.

Files selected for processing: 11

  • .github/workflows/build-docker-task.yml
  • .github/workflows/build-release-task.yml
  • .github/workflows/check-upstream-version-task.yml
  • .github/workflows/deploy-site-task.yml
  • .github/workflows/get-version-task.yml
  • .github/workflows/publish-docker-readme-task.yml
  • .github/workflows/run-codegen-pull-request-task.yml
  • .github/workflows/validate-task.yml
  • GOVERNANCE.md
  • catalog/snippets/workflows/test-pull-request-smoke.yml
  • docs/reusable-workflows.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 991b67f6ba8786739a2e0b65cd94487e2d7a9d9d, the content this pull request carries at that commit against develop, and it recorded 0 findings.

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.

🟢 Approval recommended

No active review issues are identified, and the changes consistently enforce explicit checkout credential handling while preserving the documented authenticated release exception.

No open issues 🎉

What changed in this PR

This pull request hardens GitHub Actions checkout behavior by preventing checkout tokens from being persisted unless a later step requires authenticated remote Git access.

Changes:

  • Adds a governance rule requiring explicit checkout credential handling.
  • Disables credential persistence across reusable workflows and smoke-test snippets.
  • Retains persistence for the release job's authenticated Git operations and documents hook behavior.
File Description
GOVERNANCE.md Defines the checkout credential persistence convention and its authenticated Git exception.
docs/​reusable-workflows.md Documents hook credential behavior and updates the smoke workflow example.
catalog/​snippets/​workflows/​test-pull-request-smoke.yml Updates the reusable smoke-test workflow snippet to disable credential persistence.
.github/​workflows/​validate-task.yml Disables credential persistence for validation jobs.
.github/​workflows/​run-codegen-pull-request-task.yml Disables persistence while retaining the action-provided pull request token.
.github/​workflows/​publish-docker-readme-task.yml Disables credential persistence for repository and README publishing jobs.
.github/​workflows/​get-version-task.yml Disables credential persistence during local version resolution.
.github/​workflows/​deploy-site-task.yml Disables credential persistence for the SSH-based site deployment job.
.github/​workflows/​check-upstream-version-task.yml Disables persistence while retaining the action-provided pull request token.
.github/​workflows/​build-release-task.yml Disables persistence for build jobs while retaining it for authenticated release checks.
.github/​workflows/​build-docker-task.yml Disables credential persistence across Docker preparation and build jobs.

Review effort: Lite

@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.69%. Comparing base (b38e084) to head (991b67f).
⚠️ Report is 198 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4171      +/-   ##
===========================================
- Coverage    81.60%   76.69%   -4.92%     
===========================================
  Files           26       41      +15     
  Lines         9070    14300    +5230     
===========================================
+ Hits          7402    10967    +3565     
- Misses        1668     3333    +1665     
Flag Coverage Δ
python-3.13 76.69% <ø> (-4.92%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ptr727
ptr727 merged commit f815f1a into develop Nov 13, 2026
14 checks passed
@ptr727
ptr727 deleted the burndown/checkout-persist-credentials branch November 13, 2026 20:05
ptr727 added a commit that referenced this pull request Nov 13, 2026
… Rules (#4189)

## Summary

Promotes the backlog-burndown rounds and changes from other hub sessions
from `develop` to `main`.

- Hooks and the prose gate: #4132, #4134, #4136, #4145, #4152, #4184.
The Husky hook reads its path list once and diffs a merge against
`MERGE_HEAD`. Interrupts re-raise their signal, a Markdown code span
reads as quoted data, and the gate picks a commit's diff base and
recognizes a conflicted promotion's branch cut from `main`.
- Procedures and carried rules: #4133, #4139, #4141, #4149, #4166,
#4177, #4179, #4183, #4185. Resync, audit and check-this-repo procedure
gaps, code style and shell interrupt rules, review-loop gaps across four
skills, the context and delegation section of `AGENTS.md`, question
rules in governance, the promotion line in pull request bodies,
closing-keyword behavior on promotion, and the history-rewrite premise.
- Review and cleanup tooling: #4138, #4148, #4154, #4156, #4157, #4163,
#4164, #4168, #4174, #4180. Cleanliness reads, parked handoffs, the
backlog report's JSON output, exact inline script pins, trusted inputs,
env-file includes, the bounded review wait, side-reviewer matching, and
a Copilot billing-failure notice read as a refusal.
- Workflow and runbook contract: #4153, #4155, #4169, #4171, #4178,
#4182. The runtime-secrets check, a registry entry and spec references,
the Copilot runbook pointers, credential-free checkout steps, and the
deploy-key and runner wording.
- From other hub sessions: #4159 (a repository's own .NET line under a
fleet default), #4161 (the 1Password CLI as an optional host tool),
#4162 (Codex's Windows installer and one managed opencode copy). These
carry no promotion line.

#4182 carries no promotion line by design, and #4175 holds the split-out
part of #4057's scope. Both #1448 and #4175 stay open.

Fixes #1071
Fixes #1154
Fixes #1391
Fixes #1471
Fixes #1594
Fixes #1620
Fixes #1627
Fixes #1650
Fixes #1801
Fixes #2853
Fixes #3620
Fixes #3668
Fixes #3697
Fixes #3766
Fixes #3787
Fixes #3837
Fixes #3840
Fixes #3842
Fixes #3844
Fixes #3865
Fixes #3882
Fixes #3890
Fixes #3894
Fixes #3912
Fixes #3916
Fixes #3954
Fixes #4014
Fixes #4015
Fixes #4016
Fixes #4043
Fixes #4050
Fixes #4057
Fixes #4058
Fixes #4062
Fixes #4084
Fixes #4097
Fixes #4098
Fixes #4099
Fixes #4104
Fixes #4108
Fixes #4114
Fixes #4115
Fixes #4117
Fixes #4118
Fixes #4119
Fixes #4121
Fixes #4122
Fixes #4123
Fixes #4131
Fixes #4135
Fixes #4140
Fixes #4142
Fixes #4143
Fixes #4144
Fixes #4151

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants