Skip to content

Prevent type-checking of a message create expression with a type variable #1135

Open
@l46kok

Description

@l46kok

Describe the bug
An expression of the following form will type-check just fine, if the identifier x is declared as a type containing a struct type reference to a fully qualified protobuf message name:

x{ auth: google.rpc.context.AttributeContext.Auth{} }
env, err := cel.NewEnv(
	cel.Types(&rpcpb.AttributeContext_Request{}),
)
provider := env.CELTypeProvider()
attributeCtxType, _ := provider.FindStructType("google.rpc.context.AttributeContext.Request")
env, err = env.Extend(
	cel.Variable("x", attributeCtxType),
)

ast, _ := env.Compile(`x{ auth: google.rpc.context.AttributeContext.Auth{} }`)

To Reproduce
Check which components this affects:

  • parser
  • [ x ] checker
  • interpreter

Expected behavior
No runtimes across all CEL stacks can consume this AST to produce a new message, nor is it planned to do so. Type-checker should be made to explicitly fail in this scenario.

Additional context
java xref b/398261303

The issue is less pronounced in CEL-Go, since it requires an additional step of declaring the type variable fetched from a type provider, but the issue is still present nonetheless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions