Skip to content

Commit c0577a7

Browse files
authored
print per line zizmor results with repo name
Parse sarif results from zizmor and print relevant fields from each finding as a separate line to stdout.
2 parents 44e233d + 9fd6cbf commit c0577a7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/workflows/periodic-zizmor.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,35 @@ jobs:
102102
RESULTS=$(gzip -c results.sarif | base64 -w 0)
103103
echo "results=${RESULTS}" >> $GITHUB_OUTPUT
104104
105+
- name: Print SARIF results to stdout
106+
id: print-results
107+
env:
108+
REPO: ${{ matrix.repository.repo }}
109+
shell: python
110+
run: |
111+
import json
112+
import os
113+
114+
repo = os.environ['REPO']
115+
116+
with open('results.sarif', 'r') as f:
117+
sarif_data = json.load(f)
118+
119+
results = []
120+
for result in sarif_data['runs'][0]['results']:
121+
item = {
122+
'repo': repo,
123+
'kind': result['kind'],
124+
'level': result['level'],
125+
'message': result['message']['text'],
126+
'annotation': result['locations'][0]['logicalLocations'][0]['properties']['symbolic']['annotation'],
127+
'path': result['locations'][0]['logicalLocations'][0]['properties']['symbolic']['key']['Local']['given_path']
128+
}
129+
results.append(item)
130+
131+
for item in results:
132+
print(f"repo={item['repo']}, kind={item['kind']}, level={item['level']}, message={item['message']}, annotation={item['annotation']}, path={item['path']}")
133+
105134
- name: Upload SARIF results
106135
uses: actions/github-script@v7
107136
env:

0 commit comments

Comments
 (0)