-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cosign: Allow use of regex in CertSubjectEmailVerifier #300
base: main
Are you sure you want to change the base?
Conversation
ce043ee
to
e93beff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, I'm in favor of implementing this change.
The code looks good, but I have some suggestions. These might be a matter of personal taste, hence I'm open to have a discussion about how to proceed.
My proposal would be to change the StringVerifier
from being a trait to be a simple enum. We could have something like StringVerifier::ExactMatch(String)
and StringVerifier::Regex(Regex)
. This would make the code easier to understand for our end consumers and we could get rid of the dynamic dispatch introduced by the usage of the trait.
What do you think?
This allows for either an exact match [StringVerifier::ExactMatch] or it allows for a regular expression [StringVerifier::Regex] This supports the use case of trusting signatures from a collection of email addresses e.g .*@redhat.com and or from a collection of issuers. Fixes: sigstore#299 Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
e93beff
to
c67f5cb
Compare
Makes sense to me. I've updated the patch with your proposal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, thanks for having done the proposed change.
Aside from the nitpick comment (which would be great to see addressed, but I don't consider that mandatory), can you please address the inline docs feedback please?
pub enum StringVerifier { | ||
ExactMatch(String), | ||
Regex(Regex), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some inline docs to be included on docs.rs please?
} | ||
|
||
#[test] | ||
fn cert_email_verifier_only_email_regex() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpicking, using something like rstest
could reduce a lot of this repetitions
issuer: None, | ||
}; | ||
assert!(!vc.verify(&sl).unwrap()); | ||
} | ||
|
||
#[test] | ||
fn cert_email_verifier_email_and_issuer_regex() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
Summary
This allows for either an exact match [StringVerifier::ExactMatch]
or it allows for a regular expression [StringVerifier::Regex]
This supports the use case of trusting signatures from a
collection of email addresses e.g .*@redhat.com and or from a
collection of issuers.
Fixes: #299
Release Note
CertSubjectEmailVerifier
is now constructed using either aStringVerifer
enum. This supports exact string matches or regular expressions.Documentation
Docstrings and examples are updated to show how this is used.