Skip to content

fix: expand commit hash regex to support SHA-256 (64-char) hashes - #4347

Merged
yaananth merged 9 commits into
actions:mainfrom
yaananth:sha256/fix-wellknown-regex
May 4, 2026
Merged

yaananth merged 9 commits into
actions:mainfrom
yaananth:sha256/fix-wellknown-regex

Conversation

@yaananth

@yaananth yaananth commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes https://github.com/github/actions-runtime/issues/5475
Fixes https://github.com/github/actions-runtime/issues/5483
Fixes https://github.com/github/actions-runtime/issues/5484

Summary

Expand runner commit-hash handling to support both SHA-1 (40-char) and SHA-256 (64-char) commit hashes, preparing the runner for Git's SHA-256 transition.

Changes

  • WellKnownRegularExpressions.cs: Update the commit-hash regex from \b[0-9a-f]{40}\b to \b(?:[0-9a-f]{40}|[0-9a-f]{64})\b; add CommitHash as the canonical key while keeping SHA1 as a backward-compatible alias.
  • RepositoryPlugin.cs (v1.0/v1.1): Update repository plugin callers to use WellKnownRegularExpressions.CommitHash instead of the legacy SHA1 key; remove the unused v1.0 _validSha1 field.
  • WellKnownRegularExpressionsL0.cs: Add coverage for 40-char SHA-1, 64-char SHA-256, 63/65-char boundaries, mixed-case matching, alias compatibility, and unknown keys.
  • ConstantGenerationL0.cs: Fold in the former test: update CommitHash length assertion for SHA-256 support #4348 assertion update so generated CommitHash may be either 40-char SHA-1 or 64-char SHA-256 and is hex-only.
  • ActionManagerL0.cs: Add validation for 64-character resolved SHAs in action archive cache and symlink cache paths.

Validation

  • Focused local verification passed:
    • dotnet test src/Test/Test.csproj --filter "FullyQualifiedName~WellKnownRegularExpressionsL0|FullyQualifiedName~ConstantGenerationL0" --no-restore
    • dotnet test src/Test/Test.csproj --filter "FullyQualifiedName~ActionManagerL0" --no-restore --logger "console;verbosity=minimal"
  • CI is green on the latest commit.

PR consolidation

Context


Automated by project-board-agents-plugin via /project-board-agents:lead
Board: https://github.com/orgs/github/projects/24272/views/1
Item: [P0] Fix core SHA-1 regex in actions/runner WellKnownRegularExpressions.cs
Run: sha256-p0-runner-00050

- update WellKnownRegularExpressions to match both 40-char (SHA-1) and 64-char (SHA-256) hex strings
- add CommitHash constant as canonical name while keeping SHA1 for backward compatibility
- remove dead _validSha1 field in RepositoryPlugin v1.0

Co-authored-by: Copilot <[email protected]>
yaananth and others added 2 commits April 16, 2026 15:26
Add dedicated test class covering:
- 40-char SHA-1 match (regression guard)
- 64-char SHA-256 match (new behavior)
- 63/65-char boundary rejection
- Mixed-case matching (IgnoreCase)
- SHA1 and CommitHash keys return same regex instance
- Unknown key returns null

Co-authored-by: Copilot <[email protected]>
@yaananth
yaananth marked this pull request as ready for review April 28, 2026 17:37
@yaananth
yaananth requested a review from a team as a code owner April 28, 2026 17:37
Copilot AI review requested due to automatic review settings April 28, 2026 17:37
Allow CommitHash to be either 40 chars (SHA-1) or 64 chars (SHA-256).
Add hex format validation.

Co-authored-by: Copilot <[email protected]>

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

Updates the runner’s well-known commit-hash regular expression to recognize both SHA-1 (40 hex) and SHA-256 (64 hex) commit IDs, and updates checkout plugins to use a new canonical CommitHash key while preserving the existing SHA1 key for compatibility.

Changes:

  • Add CommitHash well-known regex key and map both SHA1 and CommitHash to the updated commit-hash regex.
  • Expand commit-hash regex from 40-hex to 40-or-64-hex.
  • Update repository checkout plugins (v1.0/v1.1) to use CommitHash, and add L0 tests for the new behavior.
Show a summary per file
File Description
src/Sdk/DTPipelines/Pipelines/Expressions/WellKnownRegularExpressions.cs Adds CommitHash key and updates the commit-hash regex to allow 40 or 64 hex chars.
src/Runner.Plugins/Repository/v1.0/RepositoryPlugin.cs Removes unused local SHA1 regex field and uses CommitHash key for hash detection.
src/Runner.Plugins/Repository/v1.1/RepositoryPlugin.cs Uses CommitHash key for hash detection during checkout input handling.
src/Test/L0/Sdk/WellKnownRegularExpressionsL0.cs Adds unit tests validating key behavior and 40/64-char matching.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 4

@yaananth
yaananth merged commit 5ed0c52 into actions:main May 4, 2026
26 of 29 checks passed

@gordolara789-tech gordolara789-tech 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.

Exit

github-actions Bot pushed a commit to johngeorgewright/actions-runner that referenced this pull request May 18, 2026
jdx added a commit to jdx/jactionlint that referenced this pull request Oct 13, 2026
…e docs do not list (#170)

## What

The `correctness` profile reported keys, values and contexts that GitHub
accepts. Each of them is allowed by the workflow schema of the runner
(`src/Sdk/WorkflowParser/workflow-v1.0.json`) or of the language service
(`actions/languageservices`, `workflow-parser/src/workflow-v1.0.json`),
but the documentation that the generators read does not list them yet. I
checked every item against the schema (and the PR or commit that added
it) before changing anything.

| Item | Source |
| --- | --- |
| top-level `description:` | `workflow-root` of both schemas |
| `cancel-timeout-minutes` on a job (`jobs.<id>.timeout-minutes`
contexts) | `job-factory` of both schemas |
| `types` of `image_version` (`created`, `ready`, `deleted`) |
`image-version-mapping` of both schemas |
| `stacked` for `pull_request` and `pull_request_target` |
languageservices#384 and its schema (the runner schema does not have it
yet) |
| `drives` permission scope (`read`, `write`, `none`) |
languageservices#380 |
| `github.artifacts`, `github.artifacts_list` | github/docs
`contexts.md`, behind the `actions-artifacts-file` flag |
| empty string in the `options` of a `choice` input | languageservices
2934e369 (vscode-github-actions#395). The runner schema still says
non-empty; the dispatch form is the server's, so I followed the language
service |
| `steps`, `job`, `runner`, `env`, `always/cancelled/failure/success`,
`hashFiles` in `snapshot.if` | actions/runner#4443, `snapshot-if` of the
runner schema |
| a 64 digit commit hash is a pinned `uses:` | actions/runner#4347 |

Also:

- `excessive-permissions` skips a level that the scope does not have
(`models: write`). It printed `lets the job , and ...` with an empty
description; `invalid-permissions` already reports the level. `drives`
has a description now. `undocumented-permissions` has no scope table, so
it needed no entry.
- `snapshot.if` is now checked after the steps of the job (like
`outputs`), so `steps.<id>` is typed and a missing step is still
reported.
- The webhook generator has an override table,
`scripts/generate-webhook-events/overrides.go`, with the source of every
entry. It is applied in `run()` after parsing the docs, so `go generate`
keeps `stacked` and the `image_version` types. `all_webhooks.go` has the
same content, which I checked by regenerating from the live docs into a
scratch file (the only difference was `merge_group: destroyed`, which
the docs dropped and which is the other data PR's business and the next
PR's). The `snapshot.if` fallback of the availability generator was
extended the same way; `availability.go` equals what the generator
prints from the live docs.
- `docs/actionlint.md` lists these as places where the checks follow a
newer schema than actionlint 1.7. The `.out` files of the fixtures that
came from actionlint were updated: the key lists in `unexpected key`
messages, and the lines that expected an error for `''` in `options` and
for `env`/`runner` in `snapshot.if`.

Part of #167 (the first "schema drift" checkbox).

## Not done / skipped

- `snapshot.tags`, job-level `success(...)` arguments and the
relaxed-parser keys of the runner schema (item 26 of the research) are
not documented; left for later.
- `repository-projects` no longer documented: low priority, it goes with
the false-negative PR if at all.

## Tests

- `testdata/ok/schema_drift.yaml`: every item above, must stay clean in
the correctness profile.
- `testdata/err/schema_drift_invalid.yaml`: what must still be reported
next to them (an unknown type or level, a duplicated empty option,
`secrets` in `cancel-timeout-minutes`, a missing step in `snapshot.if`).
- `schema_drift_test.go`: types, `snapshot.if` availability,
`snapshot.if` against the steps of the job, excessive-permissions for
`models: write` and `drives: write`, and that every scope with a `write`
level has a description.
- Unit tests for the generator override, the 64 digit pin
(`TestParseUses`, `TestRequireCommitHashOptIn`).
- `go build ./...`, `go vet ./...`, `gofmt -l`, `go test ./...` (the
root package takes about 200 s on this loaded machine) and `go run
./scripts/generate-rules-doc -check` pass. I did not run `go test -race`
or `hk check --all` (the machine was at load 380 from the parallel
agents), and `staticcheck` in this environment fails on export data of
the toolchain.

I did not run a corpus: nothing here adds a finding. Every change makes
the profile accept more.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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.

5 participants