-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Support multiple outputs in a single run #3243
Comments
This issue is stale because it has been labeled with inactivity. |
It'd still be nice to have this feature, judging by the 👍 this is something that lots of people would find useful |
We also need this feature |
I would love to have this too. JSON + HTML or TXT. |
We actually run Trivy five times for that reason:
So while with most projects the duration is still reasonable a slow scan literally multiples itself. Besides multiple outputs during a single run somehow caching the results for re-runs would also work but has other caveats obviously. //edit: Hmm, bad research on my end: https://aquasecurity.github.io/trivy/v0.37/docs/vulnerability/examples/cache/#cache-directory |
+1 |
+1 |
Trivy is using a robust cache so running the same scan multiple time essentially doesn't perform a rescan, just reformats the output. Given this information, do you still think multiple outputs are necessary or it's reasonable to run trivy again to get another output (will not rescan). |
IMHO I think is better to have a support for multi-outputs in a single run because this makes it easier to maintain the command that is being run in the pipeline for when it comes to flags being deprecated (as the --scanners flag recently did with the --security-checks flag). |
A lot of people seem to want it, so we decided to change our minds and support this feature. What if adding a new flag
The existing flags We need to think about templates as it also needs template strings or files. We'd love to hear your thoughts. Thanks. |
On our end, it would greatly improve the experience to have a stdout as a given format (we use table so the developer can easy spot the packages and their respective fixes) and also generate a JSON file containing the vulnerabilities that were found, so we can create security tickets for the developers to fix their repositories. The |
ChatGPT suggested this UI, and it looks good.
The default output is stdout, like the table in the above example. For templates, you can pass the template path in the form of |
it's close to what we have in tracee, only difference is in the template example which in tracee is about the flag name - is there a way we can keep it
Yes we will need do some smart detection of the flag value, but as far as I understand the proposal we will need to do it anyway in the new |
After thinking for a while, I'm leaning towards the Buildkit approach. Something like the following:
This is because we might have more options for each output. For example, we might add support for template URLs.
Also, I have a plan to generate SBOM and VEX referencing the SBOM.
SBOM and VEX formats can be specified independently:
It is hard to represent these structured options with
I'm also sure many Linux tools use the
I want to keep the current behavior of
I thought a new flag was more intuitive for users, but we can use the existing
The downside of the detection is file paths can include |
Makes sense, I think the two suggestions are closer than it seems, except the colon divider. |
@knqyf263 I'm summarizing your suggestion and tweaking it a bit to address my wishlist, let me know what you think: Requirements
Usage
PluginsWe need to discuss plugins in a separate issue, but since this proposal takes into account the future design of plugins, I'd address the relevant assumptions I'm making:
Builtin formats
Builtin destinations
|
It basically looks good. There are some things to discuss. Usage
It doesn't seem to be very easy. I want to keep the current behavior of
The above rule must be satisfied. Plugins
Is there any advantage to distinguishing between formatting and destination? What if using
is the same as
Applying to formatting plugins as well.
would be
We would expect the plugin also works standalone.
Several plugins are accepted.
Template URLsAlso, we have to think about remote templates. Or we deny this suggestion and ask people to create plugins rather than templates? |
After starting the implementation, I realized that in
It is treated as
In the above case, the outputs would be I have some ideas.
I'm not sure if 2 and 3 work, as the comma might be separated inside the brackets. Any idea is welcome. UPDATE: 2 and 3 didn't work. Viper reads values as csv. |
I found k8s defined a custom flag. We can probably do the same thing. |
I had in mind more destinations other than
I thought it's the same motivation as having separate |
after discussing this in length offline, we have realized that we were conflating different solutions. |
For reference -- all those issue links sent me down some loopy loops! -- the answer as of today is: create Trivy JSON format, then use |
Thanks so much for producing and maintaining this excellent tool!
Summary
When running in build systems, it would be convenient to generate a report to output the UI as well as save a report to a file, sometimes also in a different format.
Current behavior
Only one format/output pair can be specified, so we can output to a table or JSON in a given trivy run, but not both. Additionally, we can output results to the terminal or to a file, but not both.
Desired behavior
Configure format/file as a single variable, and allow multiple such values to be passed. For example:
trivy image --output=json=out.json --output=table=- --output=cyclonedx=sbom.cdx
Workaround
If we want to log and show the same output format (for example, a table shown to stdout as well as recorded in a txt file), then we can use
tee
.If we have different desired output formats, then there are a few workarounds:
The text was updated successfully, but these errors were encountered: