-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat(parseutil) Add Safe variants of ParseInt* #37
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sgmiller
previously approved these changes
Mar 21, 2022
cipherboy
force-pushed
the
add-safe-variants
branch
from
March 22, 2022 13:56
e6e459a
to
f33f5fe
Compare
Added tests for the feature. |
sgmiller
previously approved these changes
Mar 22, 2022
jefferai
reviewed
Apr 25, 2022
jefferai
previously approved these changes
Apr 25, 2022
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.
LGTM but please add method comments
cipherboy
force-pushed
the
add-safe-variants
branch
from
April 25, 2022 20:23
f33f5fe
to
84920c7
Compare
Thanks for the feedback, updated. :-) |
briankassouf
previously approved these changes
Apr 26, 2022
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.
Thanks for adding all the doc comments
These proposed variants allow parsing smaller data types (such as ints) from larger data types (the int64 returned by ParseInt{,Slice}(...)), validating that they are within the requested range prior to casting. With the SafeParseIntRange(...) helper, we also allow validation of the maximum expected number of elements in the slice. Added missing method doc strings to all methods. Signed-off-by: Alexander Scheel <[email protected]>
cipherboy
force-pushed
the
add-safe-variants
branch
from
April 27, 2022 13:29
84920c7
to
82f6afd
Compare
cipherboy
commented
Apr 27, 2022
sgmiller
approved these changes
Apr 27, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These proposed variants allow parsing smaller data types (such as
int
s)from larger data types (the
int64
returned byParseInt{,Slice}(...)
),validating that they are within the requested range prior to casting.
With the
SafeParseIntRange(...)
helper, we also allow validation of themaximum expected number of elements in the slice.
Signed-off-by: Alexander Scheel <[email protected]>
--
https://hashicorp.atlassian.net/browse/VAULT-3892 has some context around this change for those with access.