Skip to content

Instantly share code, notes, and snippets.

@TheKinrar
Created August 25, 2022 13:20
Show Gist options
  • Save TheKinrar/8fd0b0555cda0e9af2d73689b268ab07 to your computer and use it in GitHub Desktop.
Save TheKinrar/8fd0b0555cda0e9af2d73689b268ab07 to your computer and use it in GitHub Desktop.
Script for converting Semgrep JSON output into CSV
import fs from 'fs';
import {format} from '@fast-csv/format';
const input = JSON.parse(fs.readFileSync(process.argv[2]));
const output = format();
output.pipe(process.stdout);
for(let result of input.results) {
output.write([
result.path.substring(result.path.lastIndexOf('/') + 1),
result.start.line + ':' + result.start.col,
result.extra.lines.trim(),
result.extra.metadata.cwe || 'N/A',
result.extra.message,
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment