Skip to content

Commit c736f8c

Browse files
sast-snyk-check: added fix for generating stats with ignore files
Resolves: https://issues.redhat.com/browse/OSH-795 The jq command returned null when the scan ignored files and there were findings. That null value is now converted into 0
1 parent 8ed0945 commit c736f8c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

task/sast-snyk-check-oci-ta/0.3/sast-snyk-check-oci-ta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ spec:
233233
234234
# Generation of scan stats
235235
236-
total_files=$(jq '[.runs[0].properties.coverage[].files] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
237-
supported_files=$(jq '[.runs[0].properties.coverage[] | select(.type == "SUPPORTED") | .files] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
236+
total_files=$(jq '[.runs[0].properties.coverage[].files // 0] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
237+
supported_files=$(jq '[.runs[0].properties.coverage[] | select(.type == "SUPPORTED") | .files // 0] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
238238
239239
# We make sure the values are 0 if no supported/total files are found
240240
total_files=${total_files:-0}

task/sast-snyk-check/0.3/sast-snyk-check.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ spec:
210210
211211
# Generation of scan stats
212212
213-
total_files=$(jq '[.runs[0].properties.coverage[].files] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
214-
supported_files=$(jq '[.runs[0].properties.coverage[] | select(.type == "SUPPORTED") | .files] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
213+
total_files=$(jq '[.runs[0].properties.coverage[].files // 0] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
214+
supported_files=$(jq '[.runs[0].properties.coverage[] | select(.type == "SUPPORTED") | .files // 0] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
215215
216216
# We make sure the values are 0 if no supported/total files are found
217217
total_files=${total_files:-0}

0 commit comments

Comments
 (0)