Add support for SHA-256 Git object IDs#3893
Open
henrymercer wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates git OID handling to support SHA-256 repositories (64-hex object IDs) in the CodeQL Action, and adds unit tests to validate the updated parsing behavior.
Changes:
- Accept 64-character (SHA-256) OIDs when deriving the base branch head commit from a PR merge commit.
- Extend
git ls-files --stageparsing to accept SHA-1 (40) and SHA-256 (64) OID lengths (and reject other lengths). - Add unit tests covering SHA-256 OIDs for both code paths, and update the changelog.
Show a summary per file
| File | Description |
|---|---|
| src/git-utils.ts | Updates OID length assumptions and ls-files parsing to support SHA-256. |
| src/git-utils.test.ts | Adds unit tests for SHA-256 OIDs and invalid OID lengths. |
| CHANGELOG.md | Records the new SHA-256 git object ID support as an unreleased change. |
| lib/upload-sarif-action.js | Generated JS output reflecting the TypeScript changes. |
| lib/upload-lib.js | Generated JS output reflecting the TypeScript changes. |
| lib/setup-codeql-action.js | Generated JS output reflecting the TypeScript changes. |
| lib/resolve-environment-action.js | Generated JS output reflecting the TypeScript changes. |
| lib/init-action.js | Generated JS output reflecting the TypeScript changes. |
| lib/init-action-post.js | Generated JS output reflecting the TypeScript changes. |
| lib/autobuild-action.js | Generated JS output reflecting the TypeScript changes. |
| lib/analyze-action.js | Generated JS output reflecting the TypeScript changes. |
| lib/analyze-action-post.js | Generated JS output reflecting the TypeScript changes. |
Copilot's findings
- Files reviewed: 3/12 changed files
- Comments generated: 1
| // The fields are: <mode> <oid> <stage>\t<path> | ||
| const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/; | ||
| // The OID is either 40 (SHA-1) or 64 (SHA-256) hex characters. | ||
| const regex = /^[0-9]+ ([0-9a-f]{40}(?:[a-f0-9]{24})?) [0-9]+\t(.+)$/; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update assumptions about Git OIDs to support SHA-256 OIDs, and add unit tests.
This incorporates review feedback from #3872.
Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
Workflow types:
dynamicworkflows (Default Setup, Code Quality, ...).Products:
analysis-kinds: code-scanning.analysis-kinds: code-quality.upload-sarifaction.Environments:
github.comand/or GitHub Enterprise Cloud with Data Residency.How did/will you validate this change?
.test.tsfiles).pr-checks).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist