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

Introduce new statuses: SKIP, MANU, ERRO #1035

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hypnoglow
Copy link

This changeset introduces new statuses as proposed in #916

Probably I missed something, so I would be grateful any feedback and help 🙏

@CLAassistant
Copy link

CLAassistant commented Oct 31, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@yoavrotems yoavrotems left a comment

Choose a reason for hiding this comment

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

First of all thanks for contributing !
Ok it seems good and nice :) there are a small changes I requested just a bit around the logic and about maybe change warn_reason in the json output but I'm not sure about since it will break backward compatibility but on the other hand we are changing a lot here.

colors[check.WARN].Printf("== Remediations %s ==\n", r.Type)
for _, g := range r.Groups {
for _, c := range g.Checks {
if c.State == check.FAIL {
if c.State == check.FAIL || c.State == check.ERRO {
fmt.Printf("%s %s\n", c.ID, c.Remediation)
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be different output from error to fail, because fail is fine and you just need to run remediation but error means something ran incorrectly, like the command doesn't even exist so remediation won't help here but stderr will.

Copy link
Author

Choose a reason for hiding this comment

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

@yoavrotems Could you elaborate on this? The error is stored in Reason, is that right?

Do you mean something like this?

if c.State == check.ERRO {
    fmt.Printf("%s audit test error: %s\n", c.ID, c.Reason)
}

cmd/common.go Outdated
fmt.Printf("%s %s\n", c.ID, c.Remediation)
}
if c.State == check.WARN {
if c.State == check.WARN || c.State == check.MANU {
// Print the error if test failed due to problem with the audit command
if c.Reason != "" && c.Type != "manual" {
Copy link
Contributor

Choose a reason for hiding this comment

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

WARN should be with FAIL and here it should be ERRO since Reason was a warn_reason which is why a test returned error, now WARN is just a fail test with no score. and ERRO is the test with reasons like command not exist or invalid parameter.
I think maybe we should consider change 'warn_reason' in the json output to error_reason or something like this.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure I understood what warn_reason is, since there is only reason in json output.

cmd/common.go Outdated
@@ -173,7 +173,9 @@ func prettyPrint(r *check.Controls, summary check.Summary) {
for _, c := range g.Checks {
colorPrint(c.State, fmt.Sprintf("%s %s\n", c.ID, c.Text))

if includeTestOutput && c.State == check.FAIL && len(c.ActualValue) > 0 {
if includeTestOutput &&
(c.State == check.FAIL || c.State == check.ERRO) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Also WARN should be printed since starting now WARN is a fail just not scored.

Copy link
Author

Choose a reason for hiding this comment

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

Did I understand you correctly?

Suggested change
(c.State == check.FAIL || c.State == check.ERRO) &&
(c.State == check.FAIL || c.State == check.WARN || c.State == check.ERRO) &&

@codecov
Copy link

codecov bot commented Nov 1, 2021

Codecov Report

Merging #1035 (85e4b94) into main (cc619e5) will decrease coverage by 0.22%.
The diff coverage is 65.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1035      +/-   ##
==========================================
- Coverage   63.56%   63.34%   -0.23%     
==========================================
  Files          14       14              
  Lines        1905     1934      +29     
==========================================
+ Hits         1211     1225      +14     
- Misses        633      647      +14     
- Partials       61       62       +1     
Impacted Files Coverage Δ
cmd/util.go 67.23% <ø> (ø)
cmd/common.go 54.54% <57.14%> (+0.20%) ⬆️
check/controls.go 75.68% <70.37%> (-3.92%) ⬇️
check/check.go 83.54% <80.00%> (+1.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc619e5...85e4b94. Read the comment docs.

@hypnoglow
Copy link
Author

@yoavrotems I've made a few changes based on your comments, PTAL. Although I'm not sure I got everything correct 🙄

@yoavrotems
Copy link
Contributor

Before I'm reviewing those new changes, we talked about it with some kube-bench users, and those changes are breaking the output for automation and other projects using kube-bench so lets do it for now as a flag, for example --enhancedoutput, and then it will be default to true, and if someone needs backward compatibility they could run it as ./kube-bench --enhancedoutput=false .
It's important to say that this output with more status will be the default, and returning to the old status will have to be specifically chosen.
It will be part of 0.7.0 and in the next versions we will deprecate the old output once most of our consumers adjust the new output

@yoavrotems yoavrotems added this to the v0.7.0 milestone Jan 12, 2022
@mozillazg
Copy link
Collaborator

mozillazg commented Feb 23, 2022

Before I'm reviewing those new changes, we talked about it with some kube-bench users, and those changes are breaking the output for automation and other projects using kube-bench so lets do it for now as a flag, for example --enhancedoutput, and then it will be default to true, and if someone needs backward compatibility they could run it as ./kube-bench --enhancedoutput=false . It's important to say that this output with more status will be the default, and returning to the old status will have to be specifically chosen. It will be part of 0.7.0 and in the next versions we will deprecate the old output once most of our consumers adjust the new output

@hypnoglow Hi, Igor, Are you still working on this?

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.

4 participants