Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an option to output the report into a file rather than redirecting the output #207

Closed
wagde-orca opened this issue Nov 13, 2020 · 3 comments · Fixed by #442
Closed
Assignees
Labels
enhancement New feature or request

Comments

@wagde-orca
Copy link

What would you like to be added:
I would like to have an option to output the report (json) into a file with an option in the commad line like
grype "dir:/xxx" -o json -f report.json
Why is this needed:
it's easier with this option to integrate grype in python code rather than running and getting the output with subprocess
Additional context:

@wagde-orca wagde-orca added the enhancement New feature or request label Nov 13, 2020
@wagoodman
Copy link
Contributor

@wagde-orca today we report all status output (e.g. "loading image", "parsing image", etc...) to stderr and all report data to stdout. In this way if you have an integration where you are trying to wrap grype and get the output you can safely grab all of stdout.

Using a redirect with bash:

# this will ignore all stderr status-like output
grype some-image:latest -o json > report.json

Or subprocess in python:

import subprocess
result = subprocess.run(['grype', 'some-image:latest', '-o', 'json'], stdout=subprocess.PIPE)
result.stdout # <--- the full json report

Shout out if you were intending something different or if this doesn't fit your needs.

@wagde-orca
Copy link
Author

@wagoodman thanx
This is the way I do it right now and it is not so bad... but i still believe that having an option to dump the output to a file can be helpful

@wagoodman
Copy link
Contributor

Tracking additional context from a duplicate issue #418:

What would you like to be added:
An official docker image for Grype that either has a shell, or an option to output findings to a file.

Why is this needed:
We're using Kubernetes native tooling for CI/CD (Tekton), and there isn't really an option to use Grype's official docker containers, because we need to output to a file, and it only outputs to stdout. Of course, an easy fix would be to just forward STDOUT to a file, but you can't do that in the docker container, because it has no shell.

There was a PR for a solution for this in Tekton but it's been closed and no ETA: tektoncd/pipeline#3103
Similar situation with k8s: kubernetes/kubernetes#94892

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants