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

How to print results to both stdout and a file? #809

Closed
Dentrax opened this issue Jun 27, 2022 · 3 comments
Closed

How to print results to both stdout and a file? #809

Dentrax opened this issue Jun 27, 2022 · 3 comments
Assignees
Labels
duplicate This issue or pull request already exists enhancement New feature or request

Comments

@Dentrax
Copy link

Dentrax commented Jun 27, 2022

By default, grype prints all results in table format to stdout. In the pipeline I want to show the vulnerabilities in human-readable table format and also exporting the scan results into a file but audit/provenance purposes.

$ grype oci-dir:output --fail-on critical -o json --file result.json

Report written to "result.json"
1 error occurred:
	* discovered vulnerabilities at or above the severity threshold

Current workaround is to run grype twice with different flags (which decreases UX and increases pipeline duration):

$ grype oci-dir:output || true
$ grype oci-dir:output --fail-on critical -o json --file result.json

I could $ cat result.json here to show content of file, but it's too verbose and does not make sense to print the entire file into stdout.

Any thoughts how to achieve this?

cc @developer-guy

@spiffcs spiffcs added this to OSS Jun 27, 2022
@spiffcs
Copy link
Contributor

spiffcs commented Jun 27, 2022

@Dentrax I think we could update the commands surface area to give you the ability to both print the results and write to some destination. @wagoodman would you want this to be added as an additional flag?

@spiffcs spiffcs moved this to In Progress (Actively Resolving) in OSS Jun 27, 2022
@spiffcs spiffcs self-assigned this Jun 27, 2022
@spiffcs spiffcs moved this from In Progress (Actively Resolving) to Triage (Comments or Progress Made) in OSS Jun 28, 2022
@joshbressers
Copy link
Contributor

This could be accomplished with the request in #648 (syft already can do this)
That issue also has example output flags

@spiffcs spiffcs added the enhancement New feature or request label Jul 5, 2022
@kzantow
Copy link
Contributor

kzantow commented Nov 8, 2022

Thanks for the issue @Dentrax! I'm going to close this as a duplicate of #648, as it was opened first and has a little more detail -- but please let me know if I've missed something!

@kzantow kzantow closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2022
Repository owner moved this from Parking Lot (Comments or Progress) to Done in OSS Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

4 participants