From e8cc66ad5dcb7cbbf0b24d67ed6d695e8df5ea2e Mon Sep 17 00:00:00 2001 From: Joshua Feingold Date: Thu, 5 Dec 2024 12:27:34 -0600 Subject: [PATCH] @W-17159591@ Enabled SARIF output format --- src/lib/writers/ResultsWriter.ts | 2 +- test/lib/writers/ResultsWriter.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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}`;