Skip to content

Commit 524e5aa

Browse files
authored
Merge pull request #71 from codacy/fix-sarif-merging
fix: Merge the full runs information when merging SARIF
2 parents 6e58a23 + 64ea54d commit 524e5aa

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

utils/sarif.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,18 @@ func createEmptySarifReport() []byte {
181181
return sarifData
182182
}
183183

184+
type SimpleSarifReport struct {
185+
Version string `json:"version"`
186+
Schema string `json:"$schema"`
187+
Runs []json.RawMessage `json:"runs"`
188+
}
189+
184190
// MergeSarifOutputs combines multiple SARIF files into a single output file
185191
func MergeSarifOutputs(inputFiles []string, outputFile string) error {
186-
var mergedSarif SarifReport
192+
var mergedSarif SimpleSarifReport
187193
mergedSarif.Version = "2.1.0"
188194
mergedSarif.Schema = "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json"
189-
mergedSarif.Runs = make([]Run, 0)
195+
mergedSarif.Runs = make([]json.RawMessage, 0)
190196

191197
for _, file := range inputFiles {
192198
data, err := os.ReadFile(file)
@@ -198,7 +204,7 @@ func MergeSarifOutputs(inputFiles []string, outputFile string) error {
198204
return fmt.Errorf("failed to read SARIF file %s: %w", file, err)
199205
}
200206

201-
var sarif SarifReport
207+
var sarif SimpleSarifReport
202208
if err := json.Unmarshal(data, &sarif); err != nil {
203209
return fmt.Errorf("failed to parse SARIF file %s: %w", file, err)
204210
}

0 commit comments

Comments
 (0)