anchore / grype

A vulnerability scanner for container images and filesystems
Apache License 2.0
8.63k stars 560 forks source link

Add JSON lines output #1159

Open ocervell opened 1 year ago

ocervell commented 1 year ago

What would you like to be added: Add JSON line output like grype <INPUT> -o jsonl

Why is this needed: Tail the output of grype to other tools in real-time

Additional context: This would allow pipes like: grype <INPUT> -o jsonl | jq -r '.matches[].vulnerability.id | xargs -I {cve_id} ./cve-search.py {cve_id}

kzantow commented 1 year ago

If we understand the ask properly, to output JSONL, each line would be each match record -- is this what you are expecting? Your jq example wouldn't quite work, as the .matches[] would be the top-level lines -- I think it would be something like this:

grype <INPUT> -o jsonl | xargs -I {cve_id} ./cve-search.py {cve_id}

We probably wouldn't stream each result individually, but only output a JSONL file at the end.

ocervell commented 3 weeks ago

@kzantow sorry for the late response, but yes, this is what I meant ;) Any reason why we can't stream result individually in a more "live" manner ?