-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
--no-color option #1091
Comments
@dmivankov could you share the commands that you are using in trivy? |
mkdir "$CACHE_DIR_WITH_DB"/db # option to set only db dir could be useful to remove extra steps in db unpacking/prep
cp metadata.json trivy.db $CACHE_DIR_WITH_DB/db/
docker save some_image > IMAGE.tar # actually using bazel to build image & tar, but shouldn't matter here
trivy --cache-dir "$CACHE_DIR_WITH_DB" image --skip-update --input IMAGE.tar --exit-code 1 --no-progress --ignore-unfixed can probably add output post-processing to remove color markers too |
This issue is stale because it has been labeled with inactivity. |
@dmivankov you could use other formats like (table, json, template) (default: "table")
|
Any examples you might have to be able to output in table format but with no color? JSON doesn't solve that as it is not what I would call human readable. Good example is running in a Jenkins job as you're not going to get colors to be visible by default. I've also tried to set The only way I can get it to not output color is when using a docker container, to not pass
|
This would be very useful for simple use cases like a simple shell script that calls
|
Bringing #1566 and this one together as feature request: The used color package does a good job in auto detecting whether the output supports ANSI coloring or not. Unfortunately for some use cases (mostly CI or other automation) this fails and needs manual override. Fortunately the color package already has this needed functionality as described in the color readme section for github-actions For the table format of trivy, it would be nice to have a trivy cli option |
How can I force colors? The trivy result in my gitlab pipeline output is not colored. I have set TERM=xterm but it does not make any difference. Is there another way to control it with a flag? |
Why is this closed? I'm missing
It works when using And why is the output on |
This issue is stale because it has been labeled with inactivity. |
Any progress on this? |
Oof I was trying to ignore color and am having a lot of issues. I actually want json format and I see color in my json format. trivy config --tf-vars=dev.tfvars . -f json "Lines": [
{
"Number": 80,
"Content": "resource \"aws_s3_bucket_server_side_encryption_configuration\" \"default\" {",
"IsCause": true,
"Annotation": "",
"Truncated": false,
"Highlighted": "\u001b[0m\u001b[38;5;33mresource\u001b[0m \u001b[38;5;37m\"aws_s3_bucket_server_side_encryption_configuration\"\u001b[0m \u001b[38;5;37m\"default\"\u001b[0m {",
"FirstCause": true,
"LastCause": false
}, I tried setting my TERM env var as well and it doesn't seem respected export TERM=xterm-mono Same with the color package's env var but again it doesn't seem to be respected export NO_COLOR=true I was able to remove the color from the non-json output using this from here but not from the json output cat output | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" |
@nitrocode JSON contains a |
Wow I completely missed that lol. Thanks @nikpivkin |
Last night I kind of went down the rabbit hole of why the colors were being outputted even though I could have simply used the I was able to find a way to disable some of the coloring in iac, but it wasn't coming in from the fitah/color package. It's actually coming from the alecthomas/chroma package. The iac themes are set here trivy/pkg/iac/scan/highlighting.go Line 12 in bf64003
Lines 79 to 82 in bf64003
I set those themes to |
Testing with trivy 0.56.2 as well as main from a few days ago, I'd like to report that NO_COLOR is working, at least for these cases:
The bold text in table headers for example are unaffected by this, so a proper option to prevent all shell formatting would still be really appreciated. |
When output is saved into text files/CI logs color markers make it harder to rid
--no-color, and/or NO_COLOR would be nice to have
The text was updated successfully, but these errors were encountered: