Skip to content

Commit fbfa538

Browse files
committed
More guardrails
1 parent 73fef22 commit fbfa538

File tree

3 files changed

+56
-13
lines changed

3 files changed

+56
-13
lines changed

dist/index.js

Lines changed: 28 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/summary.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,39 @@ export async function generateSummary(opts: ActionInputs, data: Report, filters?
2626
}
2727

2828
function addVulnTableToSummary(data: Report) {
29-
let totalVuln = data.result.vulnTotalBySeverity;
30-
let fixableVuln = data.result.fixableVulnTotalBySeverity;
29+
// Fallback to empty object if undefined
30+
const totalVuln = data.result.vulnTotalBySeverity ?? {};
31+
const fixableVuln = data.result.fixableVulnTotalBySeverity ?? {};
3132

3233
core.summary.addBreak();
3334
core.summary.addTable([
34-
[{ data: '', header: true }, { data: '🟣 Critical', header: true }, { data: '🔴 High', header: true }, { data: '🟠 Medium', header: true }, { data: '🟡 Low', header: true }, { data: '⚪ Negligible', header: true }],
35-
[{ data: '⚠️ Total Vulnerabilities', header: true }, `${totalVuln.critical ?? 0}`, `${totalVuln.high ?? 0}`, `${totalVuln.medium ?? 0}`, `${totalVuln.low ?? 0}`, `${totalVuln.negligible ?? 0}`],
36-
[{ data: '🔧 Fixable Vulnerabilities', header: true }, `${fixableVuln.critical ?? 0}`, `${fixableVuln.high ?? 0}`, `${fixableVuln.medium ?? 0}`, `${fixableVuln.low ?? 0}`, `${fixableVuln.negligible ?? 0}`],
35+
[
36+
{ data: '', header: true },
37+
{ data: '🟣 Critical', header: true },
38+
{ data: '🔴 High', header: true },
39+
{ data: '🟠 Medium', header: true },
40+
{ data: '🟡 Low', header: true },
41+
{ data: '⚪ Negligible', header: true }
42+
],
43+
[
44+
{ data: '⚠️ Total Vulnerabilities', header: true },
45+
`${totalVuln.critical ?? 0}`,
46+
`${totalVuln.high ?? 0}`,
47+
`${totalVuln.medium ?? 0}`,
48+
`${totalVuln.low ?? 0}`,
49+
`${totalVuln.negligible ?? 0}`
50+
],
51+
[
52+
{ data: '🔧 Fixable Vulnerabilities', header: true },
53+
`${fixableVuln.critical ?? 0}`,
54+
`${fixableVuln.high ?? 0}`,
55+
`${fixableVuln.medium ?? 0}`,
56+
`${fixableVuln.low ?? 0}`,
57+
`${fixableVuln.negligible ?? 0}`
58+
],
3759
]);
3860
}
3961

40-
4162
function addVulnsByLayerTableToSummary(data: Report) {
4263
if (!data.result.layers) {
4364
return

0 commit comments

Comments
 (0)