forked from game-ci/unity-builder
-
Notifications
You must be signed in to change notification settings - Fork 1
fix(ci): replace inherited Codecov literal with OIDC #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Eli Pinkerton (wallstop)
merged 3 commits into
main
from
agent/remove-inherited-codecov-literal
Jul 19, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { parse } from 'yaml'; | ||
|
|
||
| const credentialNamePattern = | ||
| /(?:^|_)(?:API_KEY|ACCESS_KEY|CREDENTIAL|PASSWORD|PASSWD|PRIVATE_KEY|SECRET|TOKEN)(?:_|$)/i; | ||
| const credentialValuePatterns = [ | ||
| /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, | ||
| /^(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|glpat-[A-Za-z0-9_-]{20,})$/, | ||
| /^(?:AKIA|ASIA)[A-Z0-9]{16}$/, | ||
| /^eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/, | ||
| /^-----BEGIN [A-Z0-9 ]+ PRIVATE KEY-----/, | ||
| /^(?=.{32,}$)(?=.*[A-Za-z])(?=.*\d)[A-Za-z0-9+/=_-]+$/, | ||
| ]; | ||
|
|
||
| function isCredentialShapedLiteral(name, value) { | ||
| if (!credentialNamePattern.test(name) || typeof value !== 'string') return false; | ||
|
|
||
| const scalar = value.trim(); | ||
| if (!scalar) return false; | ||
| if (/^\$\{\{\s*(?:secrets\.[A-Za-z_][A-Za-z0-9_]*|github\.token)\s*\}\}$/.test(scalar)) { | ||
| return false; | ||
| } | ||
| if (scalar.includes('${{')) return true; | ||
|
|
||
| return credentialValuePatterns.some((pattern) => pattern.test(scalar)); | ||
| } | ||
|
|
||
| function findCredentialShapedEnvLiterals(document, fileName = '<workflow>') { | ||
| const findings = []; | ||
|
|
||
| function visit(value, nodePath) { | ||
| if (Array.isArray(value)) { | ||
| value.forEach((entry, index) => visit(entry, [...nodePath, String(index)])); | ||
| return; | ||
| } | ||
| if (!value || typeof value !== 'object') return; | ||
|
|
||
| for (const [key, child] of Object.entries(value)) { | ||
| const childPath = [...nodePath, key]; | ||
| if (key === 'env' && child && typeof child === 'object' && !Array.isArray(child)) { | ||
| for (const [name, envValue] of Object.entries(child)) { | ||
| if (isCredentialShapedLiteral(name, envValue)) { | ||
| findings.push({ fileName, name, path: [...childPath, name].join('.') }); | ||
| } | ||
| } | ||
| } | ||
| visit(child, childPath); | ||
| } | ||
| } | ||
|
|
||
| visit(document, []); | ||
| return findings; | ||
| } | ||
|
|
||
| function renderDiagnosticComponent(value) { | ||
| return JSON.stringify(String(value)) | ||
| .replaceAll(':', '\\u003a') | ||
| .replaceAll('\u2028', '\\u2028') | ||
| .replaceAll('\u2029', '\\u2029'); | ||
| } | ||
|
|
||
| function renderCredentialFinding(finding) { | ||
| return `${renderDiagnosticComponent(finding.fileName)} has a credential-shaped literal at ${renderDiagnosticComponent(finding.path)}; use OIDC or a GitHub secret reference`; | ||
| } | ||
|
|
||
| function auditWorkflowCredentialLiterals(source, fileName = '<workflow>') { | ||
| return findCredentialShapedEnvLiterals(parse(source), fileName); | ||
| } | ||
|
|
||
| export { | ||
| auditWorkflowCredentialLiterals, | ||
| findCredentialShapedEnvLiterals, | ||
| isCredentialShapedLiteral, | ||
| renderCredentialFinding, | ||
| renderDiagnosticComponent, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.