Skip to content

Commit fdb5097

Browse files
committed
Add finding when good
1 parent 51ea8d9 commit fdb5097

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

main.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (l *AptVersion) PrepareForEval(req *proto.PrepareForEvalRequest) (*proto.Pr
132132
// Azure VM Label Plugin: Collect all the VMs from the Azure API so they can be evaluated against policies
133133

134134
data, output, err := GetInstalledPackages(l)
135-
l.logger.Debug(fmt.Sprintf("JSON OUTPUT 0.1.6: %s", output))
135+
l.logger.Debug(fmt.Sprintf("JSON OUTPUT: %s", output))
136136
if err != nil {
137137
return nil, fmt.Errorf("error getting installed packages: %w", err)
138138
}
@@ -171,7 +171,7 @@ func (l *AptVersion) Eval(request *proto.EvalRequest) (*proto.EvalResponse, erro
171171
// There are no violations reported from the policies.
172172
// We'll send the observation back to the agent
173173
if len(result.Violations) == 0 {
174-
response.AddObservation(&proto.Observation{
174+
observation := &proto.Observation{
175175
Id: uuid.New().String(),
176176
Title: "The plugin succeeded. No compliance issues to report.",
177177
Description: "The plugin policies did not return any violations. The configuration is in compliance with policies.",
@@ -182,6 +182,15 @@ func (l *AptVersion) Eval(request *proto.EvalRequest) (*proto.EvalResponse, erro
182182
Description: fmt.Sprintf("Policy %v was evaluated, and no violations were found on machineId: %s", result.Policy.Package.PurePackage(), "ARN:12345"),
183183
},
184184
},
185+
}
186+
response.AddObservation(observation)
187+
response.AddFinding(&proto.Finding{
188+
Id: uuid.New().String(),
189+
Title: fmt.Sprintf("No violations found on %s", result.Policy.Package.PurePackage()),
190+
Description: fmt.Sprintf("Policy %v was evaluated, and no violations were found on machineId: %s", result.Policy.Package.PurePackage(), "ARN:12345"),
191+
RelatedObservations: []string{observation.Id},
192+
Status: proto.FindingStatus_MITIGATED.String(),
193+
Tasks: []*proto.Task{},
185194
})
186195
}
187196

0 commit comments

Comments
 (0)