-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add proto validation for cursor indexes #4891
Conversation
proto/minder/v1/minder.proto
Outdated
// an per-rpc basis. Note it is base64 encoded. | ||
string cursor = 1 [ | ||
(buf.validate.field).string = { | ||
pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", |
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 we simplify this to "^[[:word:]=]*$"
?
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.
The one you suggest seems more loose?
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.
It is. We're concerned with very unexpected input, but presumably we will validate the cursor more completely after base64-decoding it, so we just want to rule out truly unexpected characters here.
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 see. Alright, makes sense 👍
53be786
to
12fd187
Compare
Pull Request Test Coverage Report for Build 11708419494Details
💛 - Coveralls |
Signed-off-by: Radoslav Dimitrov <[email protected]>
12fd187
to
3b239ac
Compare
Signed-off-by: Radoslav Dimitrov <[email protected]>
3b239ac
to
86b23d0
Compare
pattern: "^[[:word:]=]*$", | ||
max_len: 200, | ||
}, | ||
(buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE |
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.
If you use *
as the pattern, you don't actually need this, since it will match a zero-length string. It's fine to leave it, though.
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.
Fixed it in #4895 👍
Summary
The following PR adds proto validation for cursor indexes ensuring only base64 encoded strings are accepted.
Ref https://github.com/stacklok/minder-stories/issues/94
Change Type
Mark the type of change your PR introduces:
Testing
Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.
Review Checklist: