Skip to content

feat: add SubjectExpression CEL field to Identity for dynamic keyless signing#64

Open
jzeng4 wants to merge 1 commit intokyverno:mainfrom
jzeng4:juzeng/cel
Open

feat: add SubjectExpression CEL field to Identity for dynamic keyless signing#64
jzeng4 wants to merge 1 commit intokyverno:mainfrom
jzeng4:juzeng/cel

Conversation

@jzeng4
Copy link

@jzeng4 jzeng4 commented Mar 13, 2026

Summary

  • Add a new optional subjectExpression field to the Identity struct in ImageValidatingPolicy
  • The field accepts a CEL expression evaluated at admission time; the result is used as a regexp match against the certificate SAN URI
  • This is a backward-compatible addition: existing subject, subjectRegExp, issuer, and issuerRegExp fields are unchanged
  • Follows the message/messageExpression convention used elsewhere in Kyverno

Motivation

When verifying keyless (Fulcio/Sigstore) image signatures in multi-tenant clusters, the expected certificate SAN URI often needs to be derived from runtime context — for example, the namespace of the requesting object or the image reference itself. The static subjectRegExp field cannot express this.

Related issue

Fixes kyverno/kyverno#15398

Next PR: kyverno/kyverno#15479

Example

identities:
  - issuer: https://token.actions.githubusercontent.com
    # derive the subject regexp from the namespace at admission time
    subjectExpression: '"^https://github\\.com/my-org/" + object.metadata.namespace + "/.*"'

Test plan

  • Unit tests in pkg/imageverification/variables/attestors_test.go cover static values, subject-from-namespace, subject-from-image, and error cases
  • No changes to existing field types — API compatibility preserved

@jzeng4 jzeng4 force-pushed the juzeng/cel branch 2 times, most recently from 3faccc1 to 37ae598 Compare March 13, 2026 23:57
… signing

Add a new optional SubjectExpression field to the Identity struct, which accepts a CEL expression evaluated at admission time. The result is used as a regexp match against the certificate SAN URI, enabling dynamic subject matching (e.g. based on namespace or image name) without changing existing Subject/SubjectRegExp fields.

Signed-off-by: Junyuan Zeng <jzeng04@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: CEL Expression Support for Identity Fields in ImageValidatingPolicy

1 participant