Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@W-17159591@ Enabled SARIF output format #1690

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/writers/ResultsWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 2 additions & 16 deletions test/lib/writers/ResultsWriter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand All @@ -40,20 +40,6 @@ describe('ResultsWriter implementations', () => {
}]);
});

/**
* All of these extensions are ones we intend to support long-term, but don't yet. When we add support for one of
* these extensions, we should remove it from the cases array here and uncomment the corresponding line
* in the case array for the valid format tests.
*/
it.each([
{ext: '.sarif'},
{ext: '.sarif.json'}
])('Throws TODO error for not-yet-supported format: *$ext', ({ext}) => {
const notYetSupportedFile = `beep${ext}`;
// Expect the error message to include an indication that the functionality will be implemented eventually.
expect(() => new ResultsFileWriter(notYetSupportedFile)).toThrow('TODO');
});

it('Writes file even when results are empty', () => {
const expectations = {
file: 'beep.csv',
Expand Down
Loading