Skip to content
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

feat: add CVE-ID to commit-output #167

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Use Node.js ${{ matrix.node }}
uses: actions/[email protected]
with:
Expand Down
9 changes: 8 additions & 1 deletion commit-to-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export const formatType = {

function toStringPlaintext (data) {
let s = ''

if (data.cveId) {
s += `(${data.cveId})`
}

s += (data.semver || []).length ? `(${data.semver.join(', ').toUpperCase()}) ` : ''

if (data.revert) {
Expand Down Expand Up @@ -76,6 +81,7 @@ function toStringMarkdown (data) {
let s = ''
s += `* \\[[\`${data.sha.substr(0, 10)}\`](${data.shaUrl})] - `
s += (data.semver || []).length ? `**(${data.semver.join(', ').toUpperCase()})** ` : ''
s += data.cveId ? `**(${data.cveId})** ` : ''
s += data.revert ? '***Revert*** "' : ''
s += data.group ? `**${cleanMarkdown(data.group)}**: ` : ''
s += cleanMarkdown(data.summary)
Expand All @@ -92,7 +98,7 @@ function toStringMarkdown (data) {
}

function toStringMessageOnly (data) {
return ` * ${data.summary.trim()}`
return ` * ${data.cveId ? '(' + data.cveId + ') ' : ''}${data.summary.trim()}`
}

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

if (format === formatType.SIMPLE) {
return toStringSimple(data)
Expand Down
9 changes: 9 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,12 @@ test('test find-matching-prs', (t) => {
`)
t.end()
})

test('test group, CVE-ID', (t) => {
const out = exec('--md --start-ref=43d428b3d2 --end-ref=43d428b3d2 --group --filter-release')
t.equal(
out,
`* \\[[\`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)
`)
t.end()
})
Loading