-
Notifications
You must be signed in to change notification settings - Fork 48
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-11111352@: SARIF and Table format now properly format output in the event of SFGE errors. #679
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,6 +244,28 @@ const allFakeDfaRuleResults: RuleResult[] = [ | |
} | ||
]; | ||
|
||
const fakeDfaWithError: RuleResult[] = [ | ||
{ | ||
engine: 'sfge', | ||
fileName: sampleFile5, | ||
violations: [{ | ||
"sourceLine": 15, | ||
"sourceColumn": 8, | ||
"sourceType": "BearController", | ||
"sourceMethodName": "getAllBears", | ||
"sinkFileName": null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would empty strings be safer than nulls? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably. Stand by for that. |
||
"sinkLine": null, | ||
"sinkColumn": null, | ||
"ruleName": "InternalExecutionError", | ||
"severity": 3, | ||
"message": "Path evaluation timed out after 40 ms", | ||
"url": "https://thisurldoesnotmatter.com", | ||
"category": "InternalExecutionError" | ||
}] | ||
} | ||
] | ||
|
||
|
||
const allFakeDfaRuleResultsNormalized: RuleResult[] = [ | ||
{ | ||
engine: 'sfge', | ||
|
@@ -525,7 +547,7 @@ describe('RuleResultRecombinator', () => { | |
expect(invocation.toolExecutionNotifications).to.have.lengthOf(0, 'Tool Execution'); | ||
} | ||
|
||
function validateSfgeSarif(run: unknown, normalizeSeverity: boolean): void { | ||
function validateSfgeSarif(run: unknown, normalizeSeverity: boolean, expectingErrors: boolean): void { | ||
const driver = run['tool']['driver']; | ||
expect(driver.name).to.equal(ENGINE.SFGE); | ||
expect(driver.version).to.equal(SFGE_VERSION); | ||
|
@@ -534,7 +556,11 @@ describe('RuleResultRecombinator', () => { | |
|
||
// tool.driver.rules | ||
expect(driver['rules']).to.have.lengthOf(1, 'Incorrect rule count'); | ||
expect(driver['rules'][0].id).to.equal('ApexFlsViolationRule'); | ||
if (expectingErrors) { | ||
expect(driver['rules'][0].id).to.equal('InternalExecutionError'); | ||
} else { | ||
expect(driver['rules'][0].id).to.equal('ApexFlsViolationRule'); | ||
} | ||
if (normalizeSeverity) { | ||
expect(driver['rules'][0].properties.normalizedSeverity).to.equal(1); | ||
} else { | ||
|
@@ -546,7 +572,11 @@ describe('RuleResultRecombinator', () => { | |
expect(run['results']).to.have.lengthOf(1, 'Incorrect result count'); | ||
const results = run['results']; | ||
expect(results[0].ruleIndex).to.equal(0); | ||
expect(results[0].relatedLocations).to.exist; | ||
if (expectingErrors) { | ||
expect(results[0].relatedLocations).to.not.exist; | ||
} else { | ||
expect(results[0].relatedLocations).to.exist; | ||
} | ||
|
||
// Invocations | ||
expect(run['invocations']).to.have.lengthOf(1, 'Invocations'); | ||
|
@@ -613,7 +643,7 @@ describe('RuleResultRecombinator', () => { | |
const run = runs[i]; | ||
const engine = run['tool']['driver']['name']; | ||
if (engine === ENGINE.SFGE) { | ||
validateSfgeSarif(run, false); | ||
validateSfgeSarif(run, false, false); | ||
} else { | ||
fail(`Unexpected engine: ${engine}`); | ||
} | ||
|
@@ -634,7 +664,7 @@ describe('RuleResultRecombinator', () => { | |
const run = runs[i]; | ||
const engine = run['tool']['driver']['name']; | ||
if (engine === ENGINE.SFGE) { | ||
validateSfgeSarif(run, true); | ||
validateSfgeSarif(run, true, false); | ||
} else { | ||
fail(`Unexpected engine: ${engine}`); | ||
} | ||
|
@@ -645,6 +675,27 @@ describe('RuleResultRecombinator', () => { | |
expect(summaryMap.get('sfge')).to.deep.equal({fileCount: 1, violationCount: 1}, 'Sfge summary should be correct'); | ||
}); | ||
|
||
it ('DFA with timeout error', async () => { | ||
const {minSev, results, summaryMap} = await RuleResultRecombinator.recombineAndReformatResults(fakeDfaWithError, OUTPUT_FORMAT.SARIF, new Set(['sfge'])); | ||
const sarifResults: unknown[] = JSON.parse(results as string); | ||
expect(sarifResults['runs']).to.have.lengthOf(1, 'Runs'); | ||
const runs = sarifResults['runs']; | ||
|
||
for (let i = 0; i < runs.length; i++) { | ||
const run = runs[i]; | ||
const engine = run['tool']['driver']['name']; | ||
if (engine === ENGINE.SFGE) { | ||
validateSfgeSarif(run, false, true); | ||
} else { | ||
fail(`Unexpected engine: ${engine}`); | ||
} | ||
} | ||
|
||
expect(minSev).to.equal(3, 'Most severe problem'); | ||
expect(summaryMap.size).to.equal(1, 'Each supposedly executed engine needs a summary'); | ||
expect(summaryMap.get('sfge')).to.deep.equal({fileCount: 1, violationCount: 1}, 'Sfge summary should be correct'); | ||
}); | ||
|
||
it('Handles all pathless engines', async () => { | ||
const allEngines = PathlessEngineFilters.map(engine => engine.valueOf()); | ||
for (const engine of allEngines) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with these nulls as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want the line and column to still be null, since those are supposed to be numbers. But the location can be an empty string, I believe.