Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docker-image/scripts/trustify-da.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,34 @@ for provider in $providers; do
printf " High : %s \n" "$(jq -r --arg provider "$provider" --arg source "$source" '.providers[$provider].sources[$source].summary.high' <<< $report)"
printf " Medium : %s \n" "$(jq -r --arg provider "$provider" --arg source "$source" '.providers[$provider].sources[$source].summary.medium' <<< $report)"
printf " Low : %s \n" "$(jq -r --arg provider "$provider" --arg source "$source" '.providers[$provider].sources[$source].summary.low' <<< $report)"
remediations_count=$(jq -r --arg provider "$provider" --arg source "$source" '.providers[$provider].sources[$source].summary.remediations' <<< $report)
printf " Remediations : %s \n" "$remediations_count"
if [ "$remediations_count" -gt 0 ] 2>/dev/null; then
jq -r --arg provider "$provider" --arg source "$source" '
[.providers[$provider].sources[$source].dependencies[] |
. as $dep |
[(.issues // [])[] | select(.remediation.trustedContent.ref != null) |
{ref: $dep.ref, tc: .remediation.trustedContent.ref, cves: ((.cves // [.id]) | join(", "))}
] + [(.transitive // [])[] | . as $t |
(.issues // [])[] | select(.remediation.trustedContent.ref != null) |
{ref: $t.ref, tc: .remediation.trustedContent.ref, cves: ((.cves // [.id]) | join(", "))}
]
] | flatten | unique_by(.ref + .tc) | .[] |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Avoid potential collisions in unique_by(.ref + .tc) by using a composite key.

Concatenating ref and tc can cause collisions when different (ref, tc) pairs produce the same string (e.g. "ab" + "c" vs "a" + "bc"). Use a composite key instead:

unique_by({ref, tc})

This keeps the intended behavior while ensuring correct deduplication.

Suggested change
] | flatten | unique_by(.ref + .tc) | .[] |
] | flatten | unique_by({ref, tc}) | .[] |

" \(.ref)\n → \(.tc)\n CVEs: \(.cves)"
' <<< "$report"
fi
done

rec_sources=$(jq -r --arg provider "$provider" '.providers[$provider].recommendations // {} | keys[]' <<< "$report" 2>/dev/null)
for rec_source in $rec_sources; do
rec_total=$(jq -r --arg provider "$provider" --arg rs "$rec_source" '.providers[$provider].recommendations[$rs].summary.total // 0' <<< "$report")
printf " Recommendations (%s): %s\n" "$rec_source" "$rec_total"
if [ "$rec_total" -gt 0 ] 2>/dev/null; then
jq -r --arg provider "$provider" --arg rs "$rec_source" '
.providers[$provider].recommendations[$rs].dependencies[]? |
" \(.ref)\n → \(.recommendation)"
' <<< "$report"
fi
done
fi
done
Expand Down
Loading