Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commit-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function commitStream (ghUser, ghProject) {
null
) {
(commit.reviewers ??= []).push({ name: m[1], email: m[2] })
} else if ((m = line.match(/\bCVE-ID:\s+(CVE-\d{4}-\d{4,})\b/)) !== null) {
} else if ((m = line.match(/^\s*CVE-ID:\s+(CVE-\d{4}-\d{4,})\b/)) !== null) {
commit.cveId = m[1]
} else if ((m = line.match(/^\s+PR(?:[- ]?URL)?:\s*(.+)\s*$/) || line.match(/\(#(\d+)\)$/)) !== null) {
commit.prUrl = m[1]
Expand Down
30 changes: 30 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,36 @@ test('cve id with 4 or more sequence digits', async () => {
assert.deepStrictEqual(commits.map((c) => c.cveId), ids)
})

test('CVE-ID on the summary line is kept as the summary', async () => {
const commits = await toCommits([
'commit 0000000000000000000000000000000000000000',
'Author: RafaelGSS <rafael.nunu@hotmail.com>',
'Date: Fri Nov 22 00:19:29 2024 -0300',
'',
' deps: CVE-ID: CVE-2024-1234 fix',
'',
' body line one'
])
assert.strictEqual(commits.length, 1)
assert.strictEqual(commits[0].summary, 'deps: CVE-ID: CVE-2024-1234 fix')
assert.deepStrictEqual(commits[0].description, ['body line one'])
assert.strictEqual(commits[0].cveId, undefined)
})

test('unindented CVE-ID line sets cveId', async () => {
const commits = await toCommits([
'commit 0000000000000000000000000000000000000000',
'Author: RafaelGSS <rafael.nunu@hotmail.com>',
'Date: Fri Nov 22 00:19:29 2024 -0300',
'',
' deps: fix vulnerability',
'',
'CVE-ID: CVE-2024-1234'
])
assert.strictEqual(commits.length, 1)
assert.strictEqual(commits[0].cveId, 'CVE-2024-1234')
})

test('body lines starting with "PR" are not PR urls', async () => {
const commits = await toCommits([
'commit 0000000000000000000000000000000000000000',
Expand Down
Loading