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

fix(assessment): adjust reason accordingly across multiple components #862

Merged
merged 6 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/pkg/common/requirement-store/requirement-store.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ func (r *RequirementStore) GenerateFindings(validationStore *validationstore.Val
message.Debugf("Pass: %v / Fail: %v / Existing State: %s", pass, fail, finding.Target.Status.State)
if finding.Target.Status.State == "not-satisfied" {
state = "not-satisfied"
// If the previous state was not-satisfied but there are RelatedObservations
// Then we want to update the reason or remarks in the event the reason
// was 'other' previously
if finding.RelatedObservations != nil {
reason = "fail"
remarks = "One or more Lula validations are failing"
}
} else if pass > 0 && fail == 0 {
state = "satisfied"
reason = "pass"
Expand All @@ -110,7 +117,6 @@ func (r *RequirementStore) GenerateFindings(validationStore *validationstore.Val
state = "not-satisfied"
reason = "other"
remarks = "No Lula validations were defined for this control"
finding.Remarks = remarks
} else {
state = "not-satisfied"
reason = "fail"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestGenerateFindings(t *testing.T) {
assert.Equal(t, "fail", findings["ID-1"].Target.Status.Reason)
assert.Empty(t, findings["ID-1"].Target.Status.Remarks)

assert.Equal(t, "No Lula validations were defined for this control", findings["ID-2"].Remarks)
assert.Equal(t, "not-satisfied", findings["ID-2"].Target.Status.State)
assert.Equal(t, "other", findings["ID-2"].Target.Status.Reason)
assert.Equal(t, "No Lula validations were defined for this control", findings["ID-2"].Target.Status.Remarks)
Expand Down
Loading