defenseunicorns / lula

The Compliance Validator
Apache License 2.0
124 stars 21 forks source link

Add enhanced logging to OPA provider #255

Open brandtkeller opened 4 months ago

brandtkeller commented 4 months ago

For debug or above logging - it might benefit Lula to produce insights into:

Goal here being to improve debugging processes for payload developer experience.

meganwolf0 commented 4 months ago

Have been trying to pull some data on what was going into the rego function for this purpose - it might be nice to implement like a dryrun on validate to print the rego and expected payload so a dev could take those two and paste them in like the rego playground and then interrogate the rego script a bit more there - I used this snippet in the opa.go GetValidatedAssets and it worked well

jsonData, err := json.MarshalIndent(dataset, "", "    ")
if err != nil {
    log.Fatalf("Error marshaling to JSON: %v", err)
}

// Print JSON string
fmt.Printf("Dataset: %s\n", string(jsonData))
fmt.Printf("Rego Policy: %+v\n", regoPolicy)

I think it's hard to get specific rego outcomes this way, the playground is where I go personally to break things down more. I think the completion of this issue might help at least printing more variables to the assessment results