Skip to content

Instantly share code, notes, and snippets.

@DavidHoenisch
Last active July 25, 2024 16:56
Show Gist options
  • Select an option

  • Save DavidHoenisch/74891a33b93331c852c095d0d0c505db to your computer and use it in GitHub Desktop.

Select an option

Save DavidHoenisch/74891a33b93331c852c095d0d0c505db to your computer and use it in GitHub Desktop.
Automatically create github issues with the results from a trivy scan
trivy config . --format json | jq -c '.Results.[]| select(.Misconfigurations != null) |.Misconfigurations.[]' | zq -j 'cut Message, Resolution, Severity, CauseMetadata.Resource' - | parallel --delimiter '\\n' --quote issuefromscan
#!/bin/bash
function create_issue() {
local input_json="$1"
TITLE=$(echo "$input_json" | jq -r '.Message')
SEVERITY=$(echo "$input_json" | jq -r '.Severity')
RESOLUTION=$(echo "$input_json" | jq -r '.Resolution')
CAUSE=$(echo "$input_json" | jq -r '.CauseMetadata.Resource')
BODYFINAL=$(printf "Severity: %s\nHow to fix:\n%s\nRoot Cause:\n%s" "$SEVERITY" "$RESOLUTION" "$CAUSE")
echo "$BODYFINAL"
gh issue create --title "$TITLE" --body "$BODYFINAL"
}
if [ -z "$1" ]; then
echo "no input"
exit 1
fi
create_issue "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment