hashicorp / go-secure-stdlib

Mozilla Public License 2.0
64 stars 24 forks source link

feat(parseutil) Add Safe variants of ParseInt* #37

Closed cipherboy closed 2 years ago

cipherboy commented 2 years ago

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.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

--

https://hashicorp.atlassian.net/browse/VAULT-3892 has some context around this change for those with access.

cipherboy commented 2 years ago

Added tests for the feature.

cipherboy commented 2 years ago

Thanks for the feedback, updated. :-)