Skip to content

Conversation

@hectorj2f
Copy link
Contributor

Signed-off-by: Hector Fernandez [email protected]

Summary

This PR adds support for handling more complex evaluation rules in Rego. It enables to return custom warning or error messages following a new template:

package sigstore

isComplaint[response] {
   result := ( ... Rego logic evaluated here to a boolean ....) 
   
   errorMsg := "Your custom error message..."
   warnMsg := ""
   response :={
	"result" : result,
	"warnings" warnMsg,
	"errors" : errorMsg,
  }
}

closes: #2570

Release Note

Documentation

@hectorj2f hectorj2f added the enhancement New feature or request label Dec 27, 2022
@hectorj2f hectorj2f requested review from mattmoor and vaikas December 27, 2022 14:03
@hectorj2f hectorj2f self-assigned this Dec 27, 2022
@codecov-commenter
Copy link

codecov-commenter commented Dec 27, 2022

Codecov Report

Merging #2577 (b025afd) into main (7bbfea7) will increase coverage by 0.10%.
The diff coverage is 69.04%.

@@            Coverage Diff             @@
##             main    #2577      +/-   ##
==========================================
+ Coverage   30.05%   30.15%   +0.10%     
==========================================
  Files         141      141              
  Lines        8662     8688      +26     
==========================================
+ Hits         2603     2620      +17     
- Misses       5678     5684       +6     
- Partials      381      384       +3     
Impacted Files Coverage Δ
pkg/cosign/rego/rego.go 68.96% <64.70%> (-2.01%) ⬇️
pkg/policy/eval.go 79.48% <87.50%> (+0.53%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@hectorj2f hectorj2f force-pushed the rego_custom_response_msgs branch from 1e97ded to a4785c9 Compare December 27, 2022 14:11
dlorenc
dlorenc previously approved these changes Dec 27, 2022
mattmoor
mattmoor previously approved these changes Dec 27, 2022
Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Mostly nits, excited to play around this this!

Do we need to update any published docs to cover this?

Signed-off-by: Hector Fernandez <[email protected]>
Signed-off-by: Hector Fernandez <[email protected]>
Signed-off-by: Hector Fernandez <[email protected]>
@hectorj2f hectorj2f requested a review from mattmoor December 28, 2022 14:37
@hectorj2f hectorj2f merged commit b2cea0c into sigstore:main Dec 28, 2022
@hectorj2f hectorj2f deleted the rego_custom_response_msgs branch December 28, 2022 15:34
@github-actions github-actions bot added this to the v1.14.0 milestone Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support custom error messages when evaluating Rego policies

4 participants