Skip to content

Commit 3018c30

Browse files
committed
fix: accept CVE IDs with 4 or more sequence digits
1 parent e851881 commit 3018c30

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎commit-stream.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default function commitStream (ghUser, ghProject) {
4646
commit.reviewers = []
4747
}
4848
commit.reviewers.push({ name: m[1], email: m[2] })
49-
} else if ((m = line.match(/\bCVE-ID:\s+(CVE-\d{4}-\d{5})\b/)) !== null) {
49+
} else if ((m = line.match(/\bCVE-ID:\s+(CVE-\d{4}-\d{4,})\b/)) !== null) {
5050
commit.cveId = m[1];
5151
} else if ((m = line.match(/^\s+PR(?:[- ]?URL)?:?\s*(.+)\s*$/) || line.match(/\(#(\d+)\)$/)) !== null) {
5252
commit.prUrl = m[1]

‎test.js‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,27 @@ test('cve id', function (t) {
252252
}, 'got correct pr url for green-button merge')
253253
})
254254
})
255+
256+
test('cve id with 4 or more sequence digits', function (t) {
257+
const log = (cveId) => [
258+
'commit 0000000000000000000000000000000000000000',
259+
'Author: RafaelGSS <rafael.nunu@hotmail.com>',
260+
'Date: Fri Nov 22 00:19:29 2024 -0300',
261+
'',
262+
' deps: fix vulnerability',
263+
'',
264+
` CVE-ID: ${cveId}`
265+
]
266+
const ids = ['CVE-2026-9358', 'CVE-2024-12345', 'CVE-2017-1000117']
267+
const stream = commitStream()
268+
const commits = []
269+
stream.on('data', (commit) => commits.push(commit))
270+
stream.on('end', () => {
271+
t.deepEqual(commits.map((c) => c.cveId), ids)
272+
t.end()
273+
})
274+
for (const id of ids) {
275+
for (const line of log(id)) stream.write(line)
276+
}
277+
stream.end()
278+
})

0 commit comments

Comments
 (0)