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

Added empty actual value and expected value and non-empty flagName test #1517

Conversation

arjunkhunti-cds
Copy link

@arjunkhunti-cds arjunkhunti-cds commented Oct 31, 2023

Kube-bench checks fail when the flagVal and compareValue are empty strings and flagName is given. To resolve this, I have updated the code where flagName is assigned to the compareVal and added a test for the same.

Expected Outcome

{label: “empty - val”, op: “eq”, flagVal: “”, compareValue: “”, expectedResultPattern: “‘flagName’ is equal to ‘’“, testResult: true, flagName: “flagName”}

Actual Outcome

{label: "empty - val", op: "eq", flagVal: "", compareValue: "", expectedResultPattern: "'flagName' is equal to ''", testResult: false, flagName: "flagName"}

@CLAassistant
Copy link

CLAassistant commented Oct 31, 2023

CLA assistant check
All committers have signed the CLA.

@arjunkhunti-cds arjunkhunti-cds changed the title Added empty op val and non-empty flagName test Added empty actual value and expected. value and non-empty flagName test Oct 31, 2023
@arjunkhunti-cds arjunkhunti-cds changed the title Added empty actual value and expected. value and non-empty flagName test Added empty actual value and expected value and non-empty flagName test Oct 31, 2023
Copy link
Collaborator

@mozillazg mozillazg left a comment

Choose a reason for hiding this comment

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

@arjunkhunti-crest Could you please fix the e2e test? Thanks.

@@ -143,7 +143,11 @@ func (t flagTestItem) findValue(s string) (match bool, value string, err error)
if strings.HasPrefix(t.Flag, "--") {
value = "true"
} else {
value = vals[1]
if t.Compare.Op == "eq" && !strings.Contains(t.Flag, ":") {
Copy link
Collaborator

@mozillazg mozillazg Nov 7, 2023

Choose a reason for hiding this comment

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

IMHO, adding a workaround code (!strings.Contains(t.Flag, ":")) is not a good idea.

How about adding a new op like isempty instead of changing the eq op for your cases to support empty value?

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 familiar with the process of adding a new operation, and I'm thinking about closing this pull request. I'll communicate this process in the corresponding issue to encourage others to contribute instead.

@arjunkhunti-cds
Copy link
Author

As the suggested approach is different as implemented in this PR. Hence closing this PR.

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.

kube-bench checks are failing in case of the expected value and actual value is empty string.
3 participants