conditions: verify that AST condition result is bool
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/go-jose/go-jose/v4/jwt"
|
||||
"github.com/goccy/go-yaml/ast"
|
||||
"github.com/google/cel-go/cel"
|
||||
"github.com/google/cel-go/common/types"
|
||||
"io"
|
||||
"math/rand/v2"
|
||||
"net/http"
|
||||
@@ -71,6 +72,13 @@ func (r Register) Create(state StateInterface, name string, pol policy.Challenge
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("error compiling conditions: %v", err)
|
||||
}
|
||||
|
||||
if out := ast.OutputType(); out == nil {
|
||||
return nil, 0, fmt.Errorf("error compiling conditions: no output")
|
||||
} else if out != types.BoolType {
|
||||
return nil, 0, fmt.Errorf("error compiling conditions: output type is not bool")
|
||||
}
|
||||
|
||||
reg.Condition, err = http_cel.ProgramAst(state.ProgramEnv(), ast)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("error compiling program: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user