feat: add SubjectExpression CEL field to Identity for dynamic keyless signing#64
feat: add SubjectExpression CEL field to Identity for dynamic keyless signing#64jzeng4 wants to merge 3 commits intokyverno:mainfrom
Conversation
3faccc1 to
37ae598
Compare
… 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>
|
@eddycharly Could you take a look and merge when you get a chance? This has been approved by @fjogeleit. Thanks! |
…ession Update the Identity struct in the kyverno/api local fork so that Subject and SubjectRegExp accept either a static string value or a CEL expression, matching the pattern already used by cert/certChain. - Subject string -> Subject *StringOrExpression - SubjectRegExp string -> SubjectRegExp *StringOrExpression - Update DeepCopyInto to handle the new pointer fields - Add go.mod replace directive pointing to local fork Implements: kyverno/api#64 Related: kyverno#15398 Signed-off-by: NETIZEN_11 <niteshkumar121411@gmail.com>
- Remove local ../kyverno-api replace directive; use jzeng4/api VCS pseudo-version (kyverno/api#64) so CI can resolve the dependency - Adapt code to jzeng4/api API design: SubjectExpression string field instead of Subject/SubjectRegExp as *StringOrExpression - Fix CompileAttestors: remove identity compilation using wrong env; identity expressions are compiled via CompileAttestorIdentities with the dedicated NewIdentityExprEnv() only - Fix identPath in CompileAttestorIdentities: add missing 'cosign' segment so field errors point to correct path - Remove stale 'no-op' NOTE comment from CompileAttestorIdentities - Fix ImageKey constant: alias ImageDataKey instead of duplicating the string literal to avoid ambiguity - Update all tests to use plain string fields and SubjectExpression
…ession Update the Identity struct in the kyverno/api local fork so that Subject and SubjectRegExp accept either a static string value or a CEL expression, matching the pattern already used by cert/certChain. - Subject string -> Subject *StringOrExpression - SubjectRegExp string -> SubjectRegExp *StringOrExpression - Update DeepCopyInto to handle the new pointer fields - Add go.mod replace directive pointing to local fork Implements: kyverno/api#64 Related: kyverno#15398 Signed-off-by: NETIZEN_11 <niteshkumar121411@gmail.com>
- Remove local ../kyverno-api replace directive; use jzeng4/api VCS pseudo-version (kyverno/api#64) so CI can resolve the dependency - Adapt code to jzeng4/api API design: SubjectExpression string field instead of Subject/SubjectRegExp as *StringOrExpression - Fix CompileAttestors: remove identity compilation using wrong env; identity expressions are compiled via CompileAttestorIdentities with the dedicated NewIdentityExprEnv() only - Fix identPath in CompileAttestorIdentities: add missing 'cosign' segment so field errors point to correct path - Remove stale 'no-op' NOTE comment from CompileAttestorIdentities - Fix ImageKey constant: alias ImageDataKey instead of duplicating the string literal to avoid ambiguity - Update all tests to use plain string fields and SubjectExpression Signed-off-by: NETIZEN_11 <niteshkumar121411@gmail.com>
…ession Update the Identity struct in the kyverno/api local fork so that Subject and SubjectRegExp accept either a static string value or a CEL expression, matching the pattern already used by cert/certChain. - Subject string -> Subject *StringOrExpression - SubjectRegExp string -> SubjectRegExp *StringOrExpression - Update DeepCopyInto to handle the new pointer fields - Add go.mod replace directive pointing to local fork Implements: kyverno/api#64 Related: kyverno#15398 Signed-off-by: NETIZEN_11 <niteshkumar121411@gmail.com>
- Remove local ../kyverno-api replace directive; use jzeng4/api VCS pseudo-version (kyverno/api#64) so CI can resolve the dependency - Adapt code to jzeng4/api API design: SubjectExpression string field instead of Subject/SubjectRegExp as *StringOrExpression - Fix CompileAttestors: remove identity compilation using wrong env; identity expressions are compiled via CompileAttestorIdentities with the dedicated NewIdentityExprEnv() only - Fix identPath in CompileAttestorIdentities: add missing 'cosign' segment so field errors point to correct path - Remove stale 'no-op' NOTE comment from CompileAttestorIdentities - Fix ImageKey constant: alias ImageDataKey instead of duplicating the string literal to avoid ambiguity - Update all tests to use plain string fields and SubjectExpression Signed-off-by: NETIZEN_11 <niteshkumar121411@gmail.com>
|
@fjogeleit — could you please share the plan or timeline for merging and releasing this version with the PR included? Thank you! |
Head branch was pushed to by a user without write access
…ield Signed-off-by: Junyuan Zeng <jzeng04@gmail.com>
|
@aerosouund @JimBugwadia @lucchmielowski @fjogeleit Hi team, could one of you approve the pending workflow runs? I force-pushed to add the missing make codegen output (regenerated CRDs, helm charts, and API docs) that was causing the verify-codegen check to fail. The only new commit is the codegen output — no logic changes. Thanks! |
|
@aerosouund @JimBugwadia @lucchmielowski @fjogeleit All checks are passing now. Could you help merge this when you get a chance? Thanks! |
Summary
subjectExpressionfield to theIdentitystruct inImageValidatingPolicysubject,subjectRegExp,issuer, andissuerRegExpfields are unchangedmessage/messageExpressionconvention used elsewhere in KyvernoMotivation
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
subjectRegExpfield cannot express this.Related issue
Fixes kyverno/kyverno#15398
Next PR: kyverno/kyverno#15479
Example
Test plan
pkg/imageverification/variables/attestors_test.gocover static values, subject-from-namespace, subject-from-image, and error cases