Skip to content

Commit

Permalink
feat: add cveId support to commmit output
Browse files Browse the repository at this point in the history
Fake PR-URL for testing

CVE-ID: CVE-2024-22020
PR-URL: nodejs/node#55819
  • Loading branch information
RafaelGSS committed Nov 21, 2024
1 parent 35b762c commit 43d428b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 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) {
const pr = data.pr ? data.prUrl : ''
return ` * ${data.cveId} - ${data.summary.trim()} - ${pr}`
}

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,11 @@ function toStringMarkdown (data) {
}

function toStringMessageOnly (data) {
return ` * ${data.summary.trim()}`
let cveData
if (data.cveId) {
cveData = `${data.cveId} - `
}
return ` * ${cveData}${data.summary.trim()}`
}

export function commitToOutput (commit, format, ghId, commitUrl) {
Expand All @@ -110,6 +120,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

0 comments on commit 43d428b

Please sign in to comment.