Skip to content

Commit

Permalink
Update entrypoint.js
Browse files Browse the repository at this point in the history
  • Loading branch information
cuongquay authored Apr 30, 2021
1 parent f5c1d6b commit f1069c8
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,23 +408,27 @@ const processReport = function () {
try {
if (cmdOPS === 'REPORT') {
const vulnerabilities = securityReports.vulnerabilities || []
utilities.printTableWithJSON(vulnerabilities.map((v, idx) => {
securityServerity.critical += v.severity == 'Critical' ? 1 : 0
securityServerity.high += v.severity == 'High' ? 1 : 0
securityServerity.medium += v.severity == 'Medium' ? 1 : 0
securityServerity.low += v.severity == 'Low' ? 1 : 0
securityServerity.info += v.severity == 'Unknown' ? 1 : 0
return {
index: idx + 1,
name: v.name.truncateLeft(30),
severity: v.severity == 'Unknown' ? 'Information' : (v.severity || ''),
category: v.category || '',
identifier: (v.identifiers || []).map(i => i.type == 'cwe' ? undefined : i.value).filter(o => o),
location: v.location.file.truncateLeft(30)
if (vulnerabilities.length) {
utilities.printTableWithJSON(vulnerabilities.map((v, idx) => {
securityServerity.critical += v.severity == 'Critical' ? 1 : 0
securityServerity.high += v.severity == 'High' ? 1 : 0
securityServerity.medium += v.severity == 'Medium' ? 1 : 0
securityServerity.low += v.severity == 'Low' ? 1 : 0
securityServerity.info += v.severity == 'Unknown' ? 1 : 0
return {
index: idx + 1,
name: v.name.truncateLeft(30),
severity: v.severity == 'Unknown' ? 'Information' : (v.severity || ''),
category: v.category || '',
identifier: (v.identifiers || []).map(i => i.type == 'cwe' ? undefined : i.value).filter(o => o),
location: v.location.file.truncateLeft(30)
}
}))
if (securityServerity.critical || securityServerity.high) {
throw (`${RED}ERROR ${RESET}from ${RESET}${configInputFile}${RESET} - There are ${securityServerity.critical} ${VIOLET}(CRITICAL)${RESET} and ${securityServerity.high} ${YELLOW}(HIGH)${RESET} severity findings.${RESET}`)
}
}))
if (securityServerity.critical || securityServerity.high) {
throw (`${RED}ERROR ${RESET}from ${RESET}${configInputFile}${RESET} - There are ${securityServerity.critical} ${VIOLET}(CRITICAL)${RESET} and ${securityServerity.high} ${YELLOW}(HIGH)${RESET} severity findings.${RESET}`)
} else {
simplify.consoleWithMessage(`${opName}-Report`, `There was no finding has been found yet.`)
}
}
} catch (err) {
Expand Down

0 comments on commit f1069c8

Please sign in to comment.