Skip to content

feat(actions): support explicit commit range verification for non-PR workflows - #38

Merged
grgbkr merged 5 commits into
mainfrom
grgbkr/signing-for-dev-release
Sep 11, 2026
Merged

grgbkr merged 5 commits into
mainfrom
grgbkr/signing-for-dev-release

Conversation

@grgbkr

@grgbkr grgbkr commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds optional head-sha and base-ref inputs to verify-signed-commit-authors so it can verify commit ranges outside of pull_request events (e.g. workflow_dispatch). This enables mono's dev-release workflow to verify that all unmerged commits on a branch are signed by allowed team members before building and publishing Docker images.

Changes

  • action.yml:
    • Added optional head-sha and base-ref inputs.
    • Made github-token default to ${{ github.token }} and updated its description to note its use for unshallowing and fetching commit history in commit-range mode.
  • verify-signed-commit-authors.mjs:
    • PR Mode: Pull request commits are determined authoritatively from the event payload. Specifying head-sha on a pull_request event is now rejected outright.
    • Commit-Range Mode: Verifies all unmerged commits in base-ref..head-sha. Inputs are validated (40-char hex SHA normalized to lowercase, safe ref pattern, no dash prefix). If head-sha is already merged into base-ref, it verifies ancestor relationship and cleanly passes with zero commits.
    • Shallow Clone Safety: Detects shallow checkouts (actions/checkout default fetch-depth: 1). Automatically unshallows via origin if GITHUB_TOKEN is present, or fails closed if the repository remains shallow, preventing truncated git rev-list history from bypassing signature checks.
    • Ref Disambiguation: Qualifies base-ref before querying Git so unqualified names (e.g. main or refs/heads/main) fall back to refs/remotes/origin/main and cannot be hijacked by same-named tags (refs/tags/main).
    • Shared Verification: Extracted shared verifyCommits helper between PR mode and commit-range mode.
  • verify-signed-commit-authors.test.mjs:
    • Added 13 new unit tests covering: commit-range verification, already-merged branches, invalid signatures, missing inputs, dash injection, rejecting head-sha on PR events, unqualified branch resolution (main), qualified branch resolution (refs/heads/main), same-named tag disambiguation, uppercase SHA normalization, shallow repository unshallowing, and failing closed when shallow.
    • All 17 tests pass.

Copilot AI 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.

🟡 Changes recommended

Shallow checkouts can omit unmerged commits from verification, and plain branch names fail fallback resolution.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds explicit commit-range signature verification for non-PR workflows.

Changes:

  • Adds head-sha and base-ref inputs.
  • Implements commit-range verification and shared commit validation.
  • Adds tests for the new execution paths.
File summaries
File Description
action.yml Defines commit-range inputs and token default.
verify-signed-commit-authors.mjs Implements range resolution, fetching, and verification.
verify-signed-commit-authors.test.mjs Tests PR and commit-range behavior.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/actions/verify-signed-commit-authors/verify-signed-commit-authors.mjs Outdated

Copilot AI 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.

🟡 Changes recommended

Fully qualified branch refs can fail resolution after being fetched into an origin remote-tracking ref.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread .github/actions/verify-signed-commit-authors/verify-signed-commit-authors.mjs Outdated
Comment thread .github/actions/verify-signed-commit-authors/action.yml

Copilot AI 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.

🟡 Changes recommended

Ambiguous short base refs can resolve to a same-named tag instead of the intended branch.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread .github/actions/verify-signed-commit-authors/verify-signed-commit-authors.mjs Outdated

Copilot AI 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.

🔵 Needs a closer look

The PR head tamper check incorrectly rejects equivalent uppercase SHA input.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

.github/actions/verify-signed-commit-authors/verify-signed-commit-authors.mjs:38

  • The tamper check compares SHA text case-sensitively, even though FULL_SHA_PATTERN accepts uppercase hexadecimal. A valid uppercase spelling of the PR head is therefore rejected as an override. Compare normalized SHA values so equivalent hashes are accepted.
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI 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.

🟡 Changes recommended

PR head validation contradicts the stated contract, and valid non-branch refs cannot be fetched correctly.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

.github/actions/verify-signed-commit-authors/verify-signed-commit-authors.mjs:175

  • base-ref is documented as a commit ref, and resolveBaseCommit accepts fully qualified refs, but this fetch path treats every non-SHA as a branch. For example, a missing refs/tags/v1 is fetched as refs/heads/refs/tags/v1, so a valid tag ref can never be retrieved and range verification fails. Fetch non-branch refs/* explicitly while preserving the existing branch mappings.
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +37 to +50
const rawHead = process.env.SIGNED_COMMIT_HEAD_SHA?.trim();
if (rawHead) {
fail(
'head-sha cannot be specified on a pull request event; commits are determined from the pull request payload.',
);
}

const prNumber = validateInteger('pull request number', pr.number);
const prCommitCount = validateInteger(
'pull request commit count',
pr.commits,
);
const prHeadSha = validateSha('pull request head SHA', pr.head?.sha);
const prBaseSha = validateSha('pull request base SHA', pr.base?.sha);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i've updated the pr description, that is not the desired contract. for pull requests a head sha should not be specified it should come from the pr.

@grgbkr
grgbkr added this pull request to the merge queue Sep 11, 2026
Merged via the queue into main with commit b0bc55c Sep 11, 2026
6 checks passed
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.

3 participants