Skip to content

fix: reject non-digit characters in cve validator sequence number - #1611

Open
nikolauspschuetz wants to merge 1 commit into
go-playground:masterfrom
nikolauspschuetz:fix-cve-regex-nonzero-digit
Open

fix: reject non-digit characters in cve validator sequence number#1611
nikolauspschuetz wants to merge 1 commit into
go-playground:masterfrom
nikolauspschuetz:fix-cve-regex-nonzero-digit

Conversation

@nikolauspschuetz

Copy link
Copy Markdown

The cve validator's regex uses [^0] (any character except 0) in the three leading-zero sequence-number branches, where a non-zero digit [1-9] was intended — every other branch uses \d or [1-9]. So a sequence number containing a non-digit passes validation:

CVE-2020-0a00   valid  ❌
CVE-2020-0/00   valid  ❌
CVE-2020-00a0   valid  ❌
CVE-2020-000z   valid  ❌

A CVE ID's sequence number is decimal digits only (the syntax page linked in the code comment). Replacing [^0] with [1-9] in the three branches rejects the non-digit cases; the digit-only sequences those branches already matched are unchanged, so the existing tests still pass. Added the non-digit cases to TestCveFormatValidation.

@nikolauspschuetz
nikolauspschuetz marked this pull request as ready for review August 23, 2026 14:23
@nikolauspschuetz
nikolauspschuetz requested a review from a team as a code owner August 23, 2026 14:23
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.

2 participants