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

Disable color codes in CLI output #858

Open
thomascube opened this issue Mar 4, 2024 · 2 comments
Open

Disable color codes in CLI output #858

thomascube opened this issue Mar 4, 2024 · 2 comments
Labels
status:new This issue needs to be reviewed type:feature Feature request

Comments

@thomascube
Copy link

Is your feature request related to a problem? Please describe.

We're running ggshield in a shell environment where color codes are not supported. The output is collected in a log file and when viewing that file the output is hard to read. See the example below.

Describe the solution you'd like

An option to enable/disable colored output (e.g. --no-colors) or an according environment variable would be helpful to disable colors where not desired.

Additional context

This is how the output looks in our environment:

[ggshield-scan - scan]  �[93m�[22m�[22m
[ggshield-scan - scan]  commit 120xxxxxxxxxxxxxxxxxxxxxxxxx
[ggshield-scan - scan]  �[0mAuthor: xxxxxxx <[email protected]>
[ggshield-scan - scan]  Date: Mon Mar 4 12:20:57 2024 +0100
[ggshield-scan - scan] 
[ggshield-scan - scan]  �[36m�[22m�[22m>�[0m �[93m�[1m�[22mcommit://670ee851eb490c9af1b9ddc54f6a646277bcb9d4/charts/test-chart/values.yaml�[0m: 1 incident detected
[ggshield-scan - scan] 
[ggshield-scan - scan]  �[36m�[22m�[22m>>�[0m Secret detected: �[93m�[1m�[22mMicrosoft Teams webhook�[0m
[ggshield-scan - scan]     Validity: �[93m�[1m�[22mValid�[0m
[ggshield-scan - scan]     Occurrences: �[93m�[1m�[22m1�[0m
[ggshield-scan - scan]     Known by GitGuardian dashboard: YES
[ggshield-scan - scan]     Incident URL: https://ccccccccccccc
[ggshield-scan - scan]     Secret SHA: �[93m�[1m�[22mba1b5876828384cd247fcada027883ed01a05fe10e03afc13ce97d0f6544f568�[0m
[ggshield-scan - scan] 
[ggshield-scan - scan]  �[37m�[22m�[2m  �[0m �[37m�[22m�[2m83�[0m | �[37m�[22m�[22m�[0m
[ggshield-scan - scan]  �[37m�[22m�[2m  �[0m �[37m�[22m�[2m84�[0m | �[37m�[22m�[22mhoneypot:�[0m
[ggshield-scan - scan]  �[33m�[22m�[22m  �[0m �[33m�[22m�[22m85�[0m | �[37m�[22m�[22m…_WEBHOOK: �[0m�[91m�[22m�[22mhttps://xxxxxx.webhook.office.com/we****************-****-****-****-*********************-****-****-****-***********************************************************9c6ea-782f-4fcf-a099-bea8471a6177�[0m�[37m�[22m�[22m"…�[0m
[ggshield-scan - scan]          �[93m�[1m�[22m           �[93m�[1m�[22m�[0m
[ggshield-scan - scan]  �[0m
@thomascube thomascube added status:new This issue needs to be reviewed type:feature Feature request labels Mar 4, 2024
@thomascube
Copy link
Author

Although not documented (or I wasn't able to find it) but setting the NO_COLOR env var does the trick. You can therefore close the issue but adding this to the documentation would maybe help others.

@agateau-gg
Copy link
Collaborator

Hi, thanks for your feedback.

NO_COLOR is indeed not documented. I am going to file an issue against our doc to fix this.

Right now ggshield disables color when the output is redirected to a file, unless it recognizes it's running in a CI with color support. This needs to be changed so that color is not enabled when redirected to a file even if it's running in a CI with color support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:new This issue needs to be reviewed type:feature Feature request
Projects
None yet
Development

No branches or pull requests

2 participants