test: repeat the backtracking test input 1024 times, not 8 - #3106
Conversation
TestCatastrophicBacktrackTimeout builds its input with strings.Repeat(exp, 2^10). In Go ^ is bitwise XOR rather than exponentiation, so 2^10 evaluates to 8 and the input is 432 bytes instead of the ~55 KB the expression was meant to produce. The test still passes either way, since the regex backtracks catastrophically on both inputs and the assertion is on the match timeout, so this only corrects the intent. Verified that the test still aborts on the timeout with the longer input, at 60.15s against its 60s plus 500ms bound.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mrueg The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
This issue is currently awaiting triage. If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the The DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe catastrophic backtracking test now repeats its sample string 1,024 times by using decimal ChangesAllow/deny list test correction
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This changes only the test input size and does not affect production behavior or KSM cardinality; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
What this PR does / why we need it:
TestCatastrophicBacktrackTimeoutbuilds its input like this:In Go
^is bitwise XOR, not exponentiation, so2^10evaluates to8. The input is 432 bytes rather than the ~55 KB the expression was clearly meant to produce.The test passes either way — that regex backtracks catastrophically on both inputs, and the assertion is on the match timeout firing, not on the input size — so this only corrects the intent.
Verified with the longer input: the test still aborts on the timeout, at 60.15s against its 60s + 500ms bound.
go vetandgofmtare clean.How does this change affect the cardinality of KSM: does not change cardinality
Which issue(s) this PR fixes:
N/A
🤖 Generated with Claude Code
Summary by CodeRabbit