Add KEYVIZ_KEY_BUCKETS_PER_ROUTE validation#844
Conversation
|
Warning Review limit reached
More reviews will be available in 58 minutes and 22 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces the KEYVIZ_KEY_BUCKETS_PER_ROUTE configuration to scripts/rolling-update.sh to support sub-range buckets per route in KeyViz. Feedback suggests improving the validation logic for this variable by restricting it to a range of 1 to 256 via a precise regular expression, preventing potential integer overflow or silent clamping issues.
| if [[ -n "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" && ! "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" =~ ^[1-9][0-9]*$ ]]; then | ||
| echo "rolling-update: KEYVIZ_KEY_BUCKETS_PER_ROUTE must be empty or a positive integer, got '$KEYVIZ_KEY_BUCKETS_PER_ROUTE'" >&2 | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
The current validation checks if KEYVIZ_KEY_BUCKETS_PER_ROUTE is a positive integer, but it does not enforce the maximum limit of 256 (defined as MaxKeyBucketsPerRoute in keyviz/sampler.go).
If an operator configures a value larger than 256, it will be silently clamped by the Go binary. More importantly, if they enter an extremely large number that overflows a standard integer, the Go flag parser will fail to parse it, leading to a container crash-loop. This defeats the purpose of pre-validating the flag in this script.
We can use a precise regular expression to restrict the value to the valid range of 1 to 256 inclusive, which is also completely immune to integer overflow.
| if [[ -n "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" && ! "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" =~ ^[1-9][0-9]*$ ]]; then | |
| echo "rolling-update: KEYVIZ_KEY_BUCKETS_PER_ROUTE must be empty or a positive integer, got '$KEYVIZ_KEY_BUCKETS_PER_ROUTE'" >&2 | |
| exit 1 | |
| fi | |
| if [[ -n "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" && ! "$KEYVIZ_KEY_BUCKETS_PER_ROUTE" =~ ^([1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-6])$ ]]; then | |
| echo "rolling-update: KEYVIZ_KEY_BUCKETS_PER_ROUTE must be empty or an integer between 1 and 256, got '$KEYVIZ_KEY_BUCKETS_PER_ROUTE'" >&2 | |
| exit 1 | |
| fi |
No description provided.