Skip to content

Commit f839143

Browse files
authored
Merge pull request #167 from nodejs/add-cve-id-to-commitoutput
feat: add CVE-ID to commit-output
2 parents 35b762c + f2f235b commit f839143

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

.github/workflows/test-and-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
npm run test:ci
4646
release:
4747
name: Release
48+
permissions:
49+
contents: write
4850
needs: test
4951
runs-on: ubuntu-latest
5052
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

commit-to-output.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export const formatType = {
3939

4040
function toStringPlaintext (data) {
4141
let s = ''
42+
43+
if (data.cveId) {
44+
s += `(${data.cveId})`
45+
}
46+
4247
s += (data.semver || []).length ? `(${data.semver.join(', ').toUpperCase()}) ` : ''
4348

4449
if (data.revert) {
@@ -76,6 +81,7 @@ function toStringMarkdown (data) {
7681
let s = ''
7782
s += `* \\[[\`${data.sha.substr(0, 10)}\`](${data.shaUrl})] - `
7883
s += (data.semver || []).length ? `**(${data.semver.join(', ').toUpperCase()})** ` : ''
84+
s += data.cveId ? `**(${data.cveId})** ` : ''
7985
s += data.revert ? '***Revert*** "' : ''
8086
s += data.group ? `**${cleanMarkdown(data.group)}**: ` : ''
8187
s += cleanMarkdown(data.summary)
@@ -92,7 +98,7 @@ function toStringMarkdown (data) {
9298
}
9399

94100
function toStringMessageOnly (data) {
95-
return ` * ${data.summary.trim()}`
101+
return ` * ${data.cveId ? '(' + data.cveId + ') ' : ''}${data.summary.trim()}`
96102
}
97103

98104
export function commitToOutput (commit, format, ghId, commitUrl) {
@@ -110,6 +116,7 @@ export function commitToOutput (commit, format, ghId, commitUrl) {
110116
data.author = (commit.author && commit.author.name) || ''
111117
data.pr = prUrlMatch && ((prUrlMatch[1] !== `${ghId.user}/${ghId.repo}` ? prUrlMatch[1] : '') + urlHash)
112118
data.prUrl = prUrlMatch && commit.prUrl
119+
data.cveId = commit.cveId
113120

114121
if (format === formatType.SIMPLE) {
115122
return toStringSimple(data)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@octokit/graphql": "^7.0.1",
2929
"async": "^3.2.4",
3030
"chalk": "^5.3.0",
31-
"commit-stream": "^2.1.0",
31+
"commit-stream": "^2.2.0",
3232
"debug": "^4.3.4",
3333
"ghauth": "^6.0.0",
3434
"ghissues": "^1.1.4",

test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,12 @@ test('test find-matching-prs', (t) => {
142142
`)
143143
t.end()
144144
})
145+
146+
test('test group, CVE-ID', (t) => {
147+
const out = exec('--md --start-ref=43d428b3d2 --end-ref=43d428b3d2 --group --filter-release')
148+
t.equal(
149+
out,
150+
`* \\[[\`43d428b3d2\`](https://github.com/nodejs/changelog-maker/commit/43d428b3d2)] - **(CVE-2024-22020)** **feat**: add cveId support to commmit output (RafaelGSS) [nodejs/node#55819](https://github.com/nodejs/node/pull/55819)
151+
`)
152+
t.end()
153+
})

0 commit comments

Comments
 (0)