Created
December 2, 2022 17:21
-
-
Save zachariahtimothy/49d3660fe778b4aea79496b518f3805e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convert(filename) { | |
if (!fs.existsSync(filename)) { | |
debug && log(`File ${filename} does not exist`) | |
} | |
const headerElements = ['Group Name', 'Project Name', 'Scanner Name', 'Status', 'Vulnerability', 'Details', 'Additional Info', 'Severity', 'CVE', 'CWE']; | |
const rows = [headerElements.join(',')]; | |
const contents = JSON.parse(fs.readFileSync(filename, { encoding: 'utf-8' })); | |
contents.forEach((item) => { | |
item.vulnerabilities.forEach((vulnerability, i) => { | |
const { identifiers, name, severityWithCritical } = vulnerability; | |
if (i === 0) { | |
console.log('buln', vulnerability, vulnerability); | |
} | |
const lineItem = [ | |
'Automation Station Internal', | |
'AK Calculator', | |
'Snyk', | |
// Status | |
'', | |
// Vulnerability | |
`${cleanItem(identifiers.CVE[0])} in ${name}`, | |
// Details | |
``, //cleanItem(description.replace('\n', ' ').replace('\r', ' ')), | |
// Additional Info | |
identifiers.CWE.join(' '), | |
// Severity | |
severityWithCritical, | |
// CVE | |
identifiers.CVE.join(' '), | |
// CWE | |
identifiers.CWE.join(' ') | |
]; | |
rows.push(lineItem) | |
}); | |
}); | |
fs.writeFileSync(path.join(cwd(), 'snyk.output.csv'), rows.join('\n'), { encoding: 'utf-8'}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment