Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachariahtimothy/49d3660fe778b4aea79496b518f3805e to your computer and use it in GitHub Desktop.
Save zachariahtimothy/49d3660fe778b4aea79496b518f3805e to your computer and use it in GitHub Desktop.
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