Skip to content

Commit

Permalink
feat: add error handling for non eval result
Browse files Browse the repository at this point in the history
  • Loading branch information
chen-keinan committed Oct 11, 2021
1 parent 371978f commit 573a6f9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion eval/cmdeval.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ func (cv commandEvaluate) evalPolicy(commands []string, cmdExec cmd, evalExpr st
policyEvalResults := make([]utils.PolicyResult, 0)
var policyRes int
if val, ok := resMap[compareComm]; ok {
var policyResult utils.PolicyResult
for _, cmdRes := range val {
res, err := validator.NewPolicyEval().EvaluatePolicy(propertyEval, policy, cmdRes)
if err != nil {
return nil, err
}
policyResult := utils.MatchPolicy(res[0].ExpressionValue[0].Value, ReturnFields)
if len(res) > 0 {
policyResult = utils.MatchPolicy(res[0].ExpressionValue[0].Value, ReturnFields)
} else {
policyResult = utils.PolicyResult{ReturnValues: map[string]string{"allow": "false"}}
}
policyEvalResults = append(policyEvalResults, policyResult)
}
for _, per := range policyEvalResults {
Expand Down

0 comments on commit 573a6f9

Please sign in to comment.