Skip to content

Commit

Permalink
sast-snyk-check: added fix for generating stats with ignore files
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jperezdealgaba committed Jan 9, 2025
1 parent b4f75de commit f1fa948
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions task/sast-snyk-check-oci-ta/0.3/sast-snyk-check-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ spec:
# Generation of scan stats
total_files=$(jq '[.runs[0].properties.coverage[].files] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
supported_files=$(jq '[.runs[0].properties.coverage[] | select(.type == "SUPPORTED") | .files] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
total_files=$(jq '[.runs[0].properties.coverage[].files // 0] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
supported_files=$(jq '[.runs[0].properties.coverage[] | select(.type == "SUPPORTED") | .files // 0] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
# We make sure the values are 0 if no supported/total files are found
total_files=${total_files:-0}
Expand Down
4 changes: 2 additions & 2 deletions task/sast-snyk-check/0.3/sast-snyk-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ spec:
# Generation of scan stats
total_files=$(jq '[.runs[0].properties.coverage[].files] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
supported_files=$(jq '[.runs[0].properties.coverage[] | select(.type == "SUPPORTED") | .files] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
total_files=$(jq '[.runs[0].properties.coverage[].files // 0] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
supported_files=$(jq '[.runs[0].properties.coverage[] | select(.type == "SUPPORTED") | .files // 0] | add' "${SOURCE_CODE_DIR}"/sast_snyk_check_out.json)
# We make sure the values are 0 if no supported/total files are found
total_files=${total_files:-0}
Expand Down

0 comments on commit f1fa948

Please sign in to comment.