feat(policy-devel): extend eval command to show raw evaluation of messages#2357
Conversation
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
|
|
app/cli/cmd/policy_develop_eval.go
Outdated
| cmd.Flags().StringVarP(&policyPath, "policy", "p", "policy.yaml", "Path to custom policy file") | ||
| cmd.Flags().StringSliceVar(&inputs, "input", []string{}, "Key-value pairs of policy inputs (key=value)") | ||
| cmd.Flags().StringSliceVar(&allowedHostnames, "allowed-hostnames", []string{}, "Additional hostnames allowed for http.send requests in policies") | ||
| cmd.Flags().BoolVarP(&debug, "debug", "", false, "Enable debug/verbose output and logging mode") |
There was a problem hiding this comment.
We could probably be more explicit here, currently, the description seems like a generic debug mode, when in reality it does more than that.
| SkipReasons []string `json:"skip_reasons"` | ||
| Skipped bool `json:"skipped"` | ||
| Ignored bool `json:"ignored,omitempty"` | ||
| Violations []string `json:"violations"` |
There was a problem hiding this comment.
in your example in the description it seems that the json keys where capitalized, aren't they using these annotations?
pkg/policies/engine/rego/rego.go
Outdated
|
|
||
| // Try the main rule first | ||
| if err := executeQuery(mainRule, r.operatingMode == EnvironmentModeRestrictive); err != nil { | ||
| if err := executeQuery(fmt.Sprintf("%v.%s\n", parsedModule.Package.Path, mainRule), r.operatingMode == EnvironmentModeRestrictive); err != nil { |
There was a problem hiding this comment.
fmt.Sprintf("%v.%s\n", parsedModule.Package.Path, mainRule looks likke it could be in a function
| } | ||
|
|
||
| return parseViolationsRule(res, policy) | ||
| return parseViolationsRule(res, policy, rawData) |
There was a problem hiding this comment.
should we make this optional? Meaning that you can initialize the engine to return raw data too but optionally?
There was a problem hiding this comment.
Makes sense due to only policy devel eval making use of it, thanks
… desc Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
| for _, policyEv := range policyEvs { | ||
| result := &EvalResult{ | ||
| // Only one evaluation expected for a single policy attachment | ||
| policyEv := policyEvs[0] |
There was a problem hiding this comment.
you sure about this? Can't an evaluation contain info from multiple paths?
There was a problem hiding this comment.
Results from a single policy attachment, evaluated against a single material, are merged into one evaluation result. So results from each path in the policy will be merged in the end.
There was a problem hiding this comment.
nitpick. ok, should we protect the code?
migmartri
left a comment
There was a problem hiding this comment.
double check my comment about number of evaluations. Thanks!
| for _, policyEv := range policyEvs { | ||
| result := &EvalResult{ | ||
| // Only one evaluation expected for a single policy attachment | ||
| policyEv := policyEvs[0] |
There was a problem hiding this comment.
nitpick. ok, should we protect the code?
| string org_name = 4; | ||
| } | ||
|
|
||
| repeated google.protobuf.Struct raw_results = 19; |
There was a problem hiding this comment.
add a comment explainign what this is please
pkg/policies/engine/engine.go
Outdated
| RawData *RawData | ||
| } | ||
| type RawData struct { | ||
| Input interface{} |
There was a problem hiding this comment.
Updated types for RawData in the engine and also in proto file
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
This PR changes the format of
policy devel evaland adds additional feature to--debugflag.policy devel evaloutput is now an object instead of array of objects:Before
After
--debugflag adds additional information to output in adebug_infofield. It containsinputsfield that holds json input material enriched with passed input args and chainloop metadata. Alsoraw_resultsfield that contains full output out of opa eval which includes all rules.Closes #2353