Skip to content

TEST: Make the open redirect ReDoS guard load-insensitive - #4801

Open
Richard Lundeen (richlundeen) wants to merge 2 commits into
microsoft:mainfrom
richlundeen:test-redos-timing-thread-cpu
Open

Richard Lundeen (richlundeen) wants to merge 2 commits into
microsoft:mainfrom
richlundeen:test-redos-timing-thread-cpu

Conversation

@richlundeen

Copy link
Copy Markdown
Contributor

Description

Keep the pseudo-protocol padding ReDoS guard reliable on loaded Windows workers while preserving its full coverage of the public scoring path.

  • Measure caller CPU time instead of wall-clock time for the 8000-character payload.
  • Mock persistence so the check isolates scorer work without changing the behavior assertion or 0.5-second bound.
  • Continue to catch backtracking in normalization as well as compiled-regex evaluation.

Time only the compiled default patterns with time.thread_time() so busy CI workers and cold persistence cannot fail the 0.5s guard; keep the 8000-space payload and not-detected assertion.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… memory

Measure score_text_async with time.thread_time() while CentralMemory returns a mocked MemoryInterface, so the ReDoS guard covers both compiled patterns and redirect-value normalization without counting persistence I/O or preemption.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 2, 2026 11:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the update reducing worker-load sensitivity in the open-redirect regression test.

No open issues 🎉

What changed in this PR

Makes the open-redirect ReDoS regression test less sensitive to worker load while preserving coverage of the public scoring path.

Changes:

  • Uses caller-thread CPU time instead of elapsed wall-clock time.
  • Mocks persistence while retaining the 8,000-character payload, negative-result assertion, and 0.5-second limit.
File Description
tests/​unit/​score/​regex/​test_open_redirect_output_scorer.py Isolates scorer CPU work while preserving regex and normalization coverage.

Review effort: Balanced

@romanlutz Roman Lutz (romanlutz) self-assigned this Dec 3, 2026

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants