-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle conflicting SARIF results (#473)
If a user accidentally feeds multiple identical SARIFs, we should gracefully handle the situation.
- Loading branch information
Showing
11 changed files
with
166,855 additions
and
24 deletions.
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
44 changes: 44 additions & 0 deletions
44
...lugin-codeql/src/test/java/io/codemodder/providers/sarif/codeql/ConflictingSarifTest.java
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.codemodder.providers.sarif.codeql; | ||
|
||
import io.codemodder.*; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
final class ConflictingSarifTest { | ||
|
||
/** | ||
* Test that conflicting SARIFs can be combined, and will fail gracefully, only honoring the first | ||
* set of results found. | ||
*/ | ||
@Test | ||
void it_combines_sarifs_with_overlapping_keys(@TempDir Path tempDir) { | ||
List<Path> sarifFiles = | ||
List.of( | ||
Path.of("src/test/resources/conflicting-sarifs/codeql-0.sarif"), | ||
Path.of("src/test/resources/conflicting-sarifs/codeql-1.sarif"), | ||
Path.of("src/test/resources/conflicting-sarifs/codeql-2.sarif"), | ||
Path.of("src/test/resources/conflicting-sarifs/codeql-3.sarif"), | ||
Path.of("src/test/resources/conflicting-sarifs/codeql-4.sarif"), | ||
Path.of("src/test/resources/conflicting-sarifs/codeql-5.sarif")); | ||
|
||
Map<String, List<RuleSarif>> pathSarifMap = | ||
SarifParser.create().parseIntoMap(sarifFiles, CodeDirectory.from(tempDir)); | ||
|
||
new CodemodLoader( | ||
List.of(), | ||
CodemodRegulator.of(DefaultRuleSetting.ENABLED, List.of()), | ||
tempDir, | ||
List.of(), | ||
List.of(), | ||
List.of(), | ||
pathSarifMap, | ||
List.of(), | ||
List.of(), | ||
List.of(), | ||
null, | ||
null); | ||
} | ||
} |
51,061 changes: 51,061 additions & 0 deletions
51,061
plugins/codemodder-plugin-codeql/src/test/resources/conflicting-sarifs/codeql-0.sarif
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.