diff --git a/src/lib/writers/ResultsWriter.ts b/src/lib/writers/ResultsWriter.ts index 0f6acf073..fd16b4806 100644 --- a/src/lib/writers/ResultsWriter.ts +++ b/src/lib/writers/ResultsWriter.ts @@ -35,7 +35,7 @@ export class ResultsFileWriter implements ResultsWriter { } else if (['.html', '.htm'].includes(ext)) { this.format = OutputFormat.HTML; } else if (ext === '.sarif' || file.toLowerCase().endsWith('.sarif.json')) { - throw new Error('TODO: Support SARIF-type output'); + this.format = OutputFormat.SARIF;'' // Check for `.json` AFTER checking for `.sarif.json`! } else if (ext === '.json') { this.format = OutputFormat.JSON; diff --git a/test/lib/writers/ResultsWriter.test.ts b/test/lib/writers/ResultsWriter.test.ts index b8f2ca632..a8f9fb9a0 100644 --- a/test/lib/writers/ResultsWriter.test.ts +++ b/test/lib/writers/ResultsWriter.test.ts @@ -23,8 +23,8 @@ describe('ResultsWriter implementations', () => { {ext: '.html', expectedOutput: `Results formatted as ${OutputFormat.HTML}`}, {ext: '.htm', expectedOutput: `Results formatted as ${OutputFormat.HTML}`}, {ext: '.json', expectedOutput: `Results formatted as ${OutputFormat.JSON}`}, - //{ext: '.sarif', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`}, - //{ext: '.sarif.json', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`}, + {ext: '.sarif', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`}, + {ext: '.sarif.json', expectedOutput: `Results formatted as ${OutputFormat.SARIF}`}, {ext: '.xml', expectedOutput: `Results formatted as ${OutputFormat.XML}`} ])('Accepts and outputs valid file format: *$ext', ({ext, expectedOutput}) => { const validFile = `beep${ext}`;