-
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
fix: Add --color flag to Trivy CLI #8250
base: main
Are you sure you want to change the base?
Conversation
Fixes aquasecurity#1566 Add a new CLI option `--color` to enable or disable color output in Trivy. * **Flag Definition:** - Add `ColorFlag` in `pkg/flag/report_flags.go` to handle color settings. - Update `ReportFlagGroup` to include the new `ColorFlag`. * **Command Integration:** - Update `NewApp` function in `pkg/commands/app.go` to include the new `ColorFlag`. - Modify `cmd/trivy/main.go` to initialize the color settings based on the `--color` flag. * **Documentation:** - Update `docs/docs/references/configuration/cli/trivy_image.md` to include the new `--color` option. - Update `docs/docs/references/configuration/cli/trivy_filesystem.md` to include the new `--color` option. - Update `docs/docs/references/configuration/cli/trivy_config.md` to include the new `--color` option. - Update `docs/docs/references/configuration/cli/trivy.md` to include the new `--color` option. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/aquasecurity/trivy/issues/1566?shareId=XXXX-XXXX-XXXX-XXXX).
As commented here, |
} | ||
|
||
func NewReportFlagGroup() *ReportFlagGroup { | ||
return &ReportFlagGroup{ | ||
Format: FormatFlag.Clone(), | ||
ReportFormat: ReportFormatFlag.Clone(), | ||
Template: TemplateFlag.Clone(), | ||
Template: TemplateFlag.Clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need to run go fmt
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will affect all areas of the code base.
You can see custom packages like chroma which add color and this color flag should also impact these libraries to ensure color either remains or is removed when running the trivy cli
trivy/pkg/iac/scan/highlighting.go
Line 12 in bf64003
"github.com/alecthomas/chroma/styles" |
See this comment for more information #1091 (comment)
Fixes #1566
Add a new CLI option
--color
to enable or disable color output in Trivy.Flag Definition:
ColorFlag
inpkg/flag/report_flags.go
to handle color settings.ReportFlagGroup
to include the newColorFlag
.Command Integration:
NewApp
function inpkg/commands/app.go
to include the newColorFlag
.cmd/trivy/main.go
to initialize the color settings based on the--color
flag.Documentation:
docs/docs/references/configuration/cli/trivy_image.md
to include the new--color
option.docs/docs/references/configuration/cli/trivy_filesystem.md
to include the new--color
option.docs/docs/references/configuration/cli/trivy_config.md
to include the new--color
option.docs/docs/references/configuration/cli/trivy.md
to include the new--color
option.For more details, open the Copilot Workspace session.