Skip to content

set console mode on windows so colors render #427

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

Merged
merged 1 commit into from
Dec 11, 2020

Conversation

acc-jon
Copy link
Contributor

@acc-jon acc-jon commented Dec 9, 2020

No description provided.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 9, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Dec 9, 2020

Codecov Report

Merging #427 (e6af151) into master (e3bb0bd) will increase coverage by 2.70%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #427      +/-   ##
==========================================
+ Coverage   63.50%   66.21%   +2.70%     
==========================================
  Files          76       85       +9     
  Lines        1677     1915     +238     
==========================================
+ Hits         1065     1268     +203     
- Misses        520      535      +15     
- Partials       92      112      +20     
Impacted Files Coverage Δ
pkg/iac-providers/register.go 66.66% <0.00%> (-33.34%) ⬇️
pkg/utils/yaml.go 71.92% <0.00%> (-1.41%) ⬇️
pkg/runtime/validate.go 81.08% <0.00%> (ø)
pkg/policy/cloud-providers.go 100.00% <0.00%> (ø)
pkg/iac-providers/providers.go 100.00% <0.00%> (ø)
pkg/iac-providers/terraform.go 100.00% <0.00%> (ø)
pkg/iac-providers/kubernetes.go 100.00% <0.00%> (ø)
pkg/iac-providers/kubernetes/v1/normalize.go 74.46% <0.00%> (ø)
pkg/iac-providers/kustomize/v3/load-dir.go 73.07% <0.00%> (ø)
pkg/policy/helm.go 100.00% <0.00%> (ø)
... and 12 more

)

// In order for colored output to work on Windows, we need to explicitly
// enable the virtual terminal processing console mode. This is needed for
Copy link
Contributor

@williepaul williepaul Dec 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Jon,

One suggestion--can we detect if virtual terminal processing console mode is disabled, and either switch to no-color automatically, issue a warning, or both?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Willie, the PreRun func for scanCmd in cli/scan.go will disable colored output mode if the terminal is not a tty.

This code just ensures that Windows users will be able to see colored output. The default mode is disabled, probably for historical reasons that are no longer relevant.

Note that Terrascan uses third-party packages like zap that also expect a color-capable terminal. If we wanted to disable colors then we would need to figure out how/if those could be forced to a non-color mode.

@williepaul williepaul merged commit 9c5476c into tenable:master Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants