Skip to content

test: repeat the backtracking test input 1024 times, not 8 - #3106

Open
mrueg wants to merge 1 commit into
kubernetes:mainfrom
mrueg:fix/allowdenylist-repeat-count
Open

test: repeat the backtracking test input 1024 times, not 8#3106
mrueg wants to merge 1 commit into
kubernetes:mainfrom
mrueg:fix/allowdenylist-repeat-count

Conversation

@mrueg

@mrueg mrueg commented Aug 23, 2026

Copy link
Copy Markdown
Member

What this PR does / why we need it:

TestCatastrophicBacktrackTimeout builds its input like this:

var exp = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
exp = strings.Repeat(exp, 2^10)

In Go ^ is bitwise XOR, not exponentiation, so 2^10 evaluates to 8. 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 vet and gofmt are 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

  • Tests
    • Corrected a stress-test input to reliably exercise repeated-pattern handling.
    • Improved test validity by generating the intended 1,024 repetitions.

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.
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow
kubernetes-prow Bot requested review from dgrisonnet and nmn3m August 23, 2026 21:06
@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 23, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

Instructions 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.

@kubernetes-prow kubernetes-prow Bot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 23, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in SIG Instrumentation Aug 23, 2026
@kubernetes-prow kubernetes-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 23, 2026
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 28838dfd-815f-4f0d-8812-90bb72528956

📥 Commits

Reviewing files that changed from the base of the PR and between 9295108 and 4c0aec3.

📒 Files selected for processing (1)
  • pkg/allowdenylist/allowdenylist_test.go

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The catastrophic backtracking test now repeats its sample string 1,024 times by using decimal 1024 instead of the invalid 2^10 expression.

Changes

Allow/deny list test correction

Layer / File(s) Summary
Fix test input repetition count
pkg/allowdenylist/allowdenylist_test.go
The test uses 1024 to create the intended 1,024-fold repeated input.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 4c0ae

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: dgrisonnet, nmn3m

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main test correction from 8 repetitions to 1,024 repetitions.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

1 participant