feat: add merge-sarif
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
name: "Merge SARIF Files"
|
||||
description: "Merge multiple SARIF files into a single SARIF file"
|
||||
author: "Timo Behrendt <t.behrendt@t00n.de>"
|
||||
branding:
|
||||
icon: "database"
|
||||
color: "blue"
|
||||
|
||||
inputs:
|
||||
files:
|
||||
description: "Paths to SARIF files to merge"
|
||||
required: true
|
||||
output-file:
|
||||
description: "Output file path"
|
||||
required: true
|
||||
default: "merged.sarif"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- id: merge
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
files="${{ inputs.files }}"
|
||||
output-file="${{ inputs.output-file }}"
|
||||
|
||||
# Sarif files are easy to merge. They contain a "runs" array. We just need to concat the runs arrays and write the result to the output file.
|
||||
# Collect all the runs from all
|
||||
runs=()
|
||||
for file in $files; do
|
||||
runs+=($(jq -r '.runs' $file))
|
||||
done
|
||||
|
||||
# Write the merged runs to the output file.
|
||||
echo '{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/sarif-2.1/schema/sarif-schema-2.1.0.json","runs":[' > $output-file
|
||||
echo "${runs[@]}" | jq -s '.' >> $output-file
|
||||
echo ']}' >> $output-file
|
||||
Reference in New Issue
Block a user