Skip to content

Instantly share code, notes, and snippets.

@jijosg
Last active August 18, 2021 18:36
Show Gist options
  • Save jijosg/ac417d9c2918a21a5e9dbfe20f9d9f5f to your computer and use it in GitHub Desktop.
Save jijosg/ac417d9c2918a21a5e9dbfe20f9d9f5f to your computer and use it in GitHub Desktop.
JQ utils

create table from json

cat vuln.json |jq -r '(["ID","NAME"] | (., map(length*"-"))), (.vulnerabilities[] | [.package_name,.package_path]) | @tsv' |column -ts $'\t'

Get number of vulnerabilities from trivy JSON report

❯ trivy --version                                       
Version: 0.19.2
Vulnerability DB:
  Type: Light
  Version: 1
  UpdatedAt: 2021-08-18 12:09:36.660946762 +0000 UTC
  NextUpdate: 2021-08-18 18:09:36.660945662 +0000 UTC
  DownloadedAt: 2021-08-18 18:08:11.3410535 +0000 UTC

❯ TRIVY_NEW_JSON_SCHEMA=true trivy image -f json -o result.json ubuntu:latest
2021-08-19T00:03:12.221+0530    INFO    Detected OS: ubuntu
2021-08-19T00:03:12.222+0530    INFO    Detecting Ubuntu vulnerabilities...
2021-08-19T00:03:12.222+0530    INFO    Number of language-specific files: 0

❯ jq -r '.Results[].Vulnerabilities[].Severity' result.json | uniq -c
     25 LOW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment