-
Notifications
You must be signed in to change notification settings - Fork 0
fix(kpi): reject compact credential-shaped source IDs (#496 merge-result promotion) #507
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
Closed
Closed
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
d7240ba
test(kpi): reject compact credential-shaped source ids
seonghobae 0f086fc
test(kpi): keep source-id expectations aligned with policy
seonghobae dc7fe1e
fix(kpi): reject compact credential-shaped source ids
seonghobae fec97a1
test(kpi): reject password-shaped source IDs
seonghobae 72a8804
fix(kpi): reject password-shaped source IDs
seonghobae 134508f
test(kpi): reject control characters in source IDs
seonghobae b0e8964
fix(kpi): reject control characters in source IDs
seonghobae cf90269
test(kpi): reject authorization-shaped source IDs
seonghobae 88cdb03
fix(kpi): reject authorization-shaped source IDs
seonghobae 6e5776c
test(kpi): reject ambiguous Unicode source IDs
seonghobae 35bc0d0
fix(kpi): reject ambiguous Unicode source IDs
seonghobae e4028e5
test(kpi): reject non-canonical Unicode spaces in source IDs
seonghobae 7472691
fix(kpi): reject non-canonical Unicode spaces in source IDs
seonghobae f2e086e
test(kpi): require NFC provenance source identity
seonghobae 2f9abd3
fix(kpi): require NFC provenance source identity
seonghobae 587c01a
test(kpi): reject compatibility-ambiguous source IDs
seonghobae 7b2659c
fix(kpi): require compatibility-canonical source IDs
seonghobae 9fdd8c8
test(kpi): reject strong npm token source IDs
seonghobae 15260fd
fix(kpi): reject strong npm token source IDs
seonghobae ed9b532
test(kpi): include source ID validator in exact coverage
seonghobae 6af6391
test(kpi): exercise source ID coverage branches
seonghobae 0ae23fa
test(kpi): reject locator-shaped source IDs
seonghobae 9994f74
fix(kpi): reject locator-shaped source IDs
seonghobae a3fe812
test(kpi): reject non-hierarchical locator source IDs
seonghobae 5b4bc50
fix(kpi): reject non-hierarchical locator source IDs
seonghobae 89ee5ab
test(kpi): reject executable locator source IDs
seonghobae 059ff6a
fix(kpi): reject executable locator source IDs
seonghobae 7c607d9
test(kpi): reject credential assignment source IDs
seonghobae b4ec2d0
fix(kpi): reject credential assignment source IDs
seonghobae 2c148c6
test(kpi): reject password-alias source credentials
seonghobae 1f6fd1f
fix(kpi): reject password-alias source credentials
seonghobae 352bd94
test(kpi): reject percent-encoded source authority
seonghobae ec62fd6
fix(kpi): reject percent-encoded source authority
seonghobae 4e2cadb
chore(kpi): converge current protected main
seonghobae f1357b0
ci: refresh current-main merge result for PR 496
seonghobae 34d37b0
Merge f1357b02cb457d9a0d606c6207f84267526f3a93 into 9fd64b184a7df5292…
seonghobae 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,32 @@ | ||
| const compactCredentialLabelPattern = /(^|[^a-z0-9])(clientsecret|sessiontoken|authtoken|accesstoken|refreshtoken|accesskeyid|secretaccesskey|signingkey)([^a-z0-9]|$)/i; | ||
| const credentialHeaderAssignmentPattern = /(^|[^a-z0-9])(authorization|bearer|credential|sig|signature|pwd|passphrase)\s*[:=]/i; | ||
| const githubCredentialTokenPattern = /(^|[^a-z0-9])(github_pat_|gh[pousr]_)/i; | ||
| const npmCredentialTokenPattern = /(^|[^a-z0-9])npm_[a-z0-9]{36}([^a-z0-9]|$)/i; | ||
| const unsafeIdentityCodePointPattern = /[\p{Cc}\p{Cf}\p{Cs}\p{Zl}\p{Zp}]/u; | ||
| const nonCanonicalSpacePattern = /[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/u; | ||
| const percentEncodedIdentityPattern = /%[0-9A-Fa-f]{2}/; | ||
| const nonHierarchicalLocatorSchemePattern = /^(?:about|data|javascript|mailto|sms|tel|vbscript):/i; | ||
|
|
||
| export function hasUnsafeSourceId(value) { | ||
| const rawSourceId = String(value ?? ""); | ||
| const sourceId = rawSourceId.trim(); | ||
| const normalized = sourceId.toLowerCase(); | ||
| const camelSeparatedSourceId = sourceId.replace(/([a-z0-9])([A-Z])/g, "$1_$2"); | ||
| return rawSourceId !== sourceId | ||
| || sourceId !== sourceId.normalize("NFKC") | ||
| || unsafeIdentityCodePointPattern.test(sourceId) | ||
| || nonCanonicalSpacePattern.test(sourceId) | ||
| || percentEncodedIdentityPattern.test(sourceId) | ||
| || normalized === "placeholder" | ||
| || normalized === "todo" | ||
| || normalized === "tbd" | ||
| || normalized.startsWith("replace-with-") | ||
| || /https?:\/\//i.test(sourceId) | ||
| || sourceId.includes("://") | ||
| || nonHierarchicalLocatorSchemePattern.test(sourceId) | ||
| || sourceId.includes("?") | ||
| || /(^|[^a-z0-9])(github_pat_|gh[pousr]_)/i.test(sourceId) | ||
| || /(^|[^a-z0-9])(token|secret|api[_-]?key|access[_-]?key|private[_-]?key)([^a-z0-9]|$)/i.test(sourceId); | ||
| || githubCredentialTokenPattern.test(sourceId) | ||
| || npmCredentialTokenPattern.test(sourceId) | ||
| || /(^|[^a-z0-9])(token|secret|password|passwd|api[_-]?key|access[_-]?key|private[_-]?key)([^a-z0-9]|$)/i.test(camelSeparatedSourceId) | ||
| || compactCredentialLabelPattern.test(sourceId) | ||
| || credentialHeaderAssignmentPattern.test(sourceId); | ||
| } | ||
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,42 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { hasUnsafeSourceId } from "../scripts/lib/source-id.mjs"; | ||
|
|
||
| describe("source-id exact production coverage", () => { | ||
| it.each([ | ||
| " source", | ||
| "source ", | ||
| "source", | ||
| "source\u0000id", | ||
| "source\u202Eid", | ||
| "source\uD800id", | ||
| "source\u2028id", | ||
| "source\u2029id", | ||
| "source\u00A0id", | ||
| "placeholder", | ||
| "todo", | ||
| "tbd", | ||
| "replace-with-source", | ||
| "https://logs.noema.internal/export", | ||
| "source?token=redacted", | ||
| "ghp_EXAMPLEVALUE123456", | ||
| "npm_abcdefghijklmnopqrstuvwxyz0123456789", | ||
| "token=EXAMPLEVALUE123456", | ||
| "apiKey=EXAMPLEVALUE123456", | ||
| "clientSecret=EXAMPLEVALUE123456", | ||
| "authorization=Bearer EXAMPLEVALUE123456", | ||
| ])("executes a fail-closed source identity branch for %j", (sourceId) => { | ||
| expect(hasUnsafeSourceId(sourceId)).toBe(true); | ||
| }); | ||
|
|
||
| it.each([ | ||
| undefined, | ||
| null, | ||
| "", | ||
| "cloudflare-logpush:noema-production", | ||
| "github-app:noema-reviewer", | ||
| "npm-package-metadata", | ||
| "source-é", | ||
| ])("executes a non-secret source identity branch for %j", (sourceId) => { | ||
| expect(hasUnsafeSourceId(sourceId)).toBe(false); | ||
| }); | ||
| }); |
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 |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ export default defineConfig({ | |
| "scripts/prepare-agent-pr-message.mjs", | ||
| "scripts/verify-orchestrator-gateway.mjs", | ||
| "scripts/lib/orchestrator-gateway.mjs", | ||
| "scripts/lib/source-id.mjs", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| "scripts/workflow-registry-audit.mjs", | ||
| "scripts/workflow-registry-disable-plan.mjs", | ||
| "scripts/workflow-registry-live-disable.mjs", | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 Behavior change lacks changelog entry
New
hasUnsafeSourceIdrejections are absent from the Unreleased changelog. Repository policy requires every behavior change to be recorded.Was this helpful? React with 👍 or 👎 to provide feedback.