Repository navigation
fix: regexes with a linear pattern over trusted input carry no wall-clock match timeout - #471
Merged
Merged
Conversation
…lock match timeout (#427) .NET's match timeout is wall-clock, so on a stalled runner it fails a match that takes microseconds (#426). The tool-side snapshot reader, renderer and source-watch loader read spec/SNAPSHOT.md, spec/source-watch.json, `git rev-parse` output and a maintainer-selected receipt; their patterns either match a fixed width (the 40- and 64-character hashes) or scan linearly (the renderer's delimiter-separated runs, one of them unanchored). Thirteen Tools.Tests regexes over repository files, packed test outputs and test constants are the same case, as is DriveManifestTests' instance-name check. Each moves to Timeout.Infinite, or Regex.InfiniteMatchTimeout where the API takes a TimeSpan; PackedReadmeTests' timeout field goes with its only use. Four Tools.Tests patterns can backtrack quadratically on adversarial text (AnalyzerConfigReader's property line, the comment scan's documentation-path and Stryker rules, CommentReader's PowerShell block), so they keep their finite timeout with the reason beside it. Closes #427
…out; a superlinear or untrusted one keeps a finite timeout with its reason
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Regexes whose pattern matches in linear time over trusted input no longer carry a wall-clock match timeout; the four that can backtrack quadratically keep theirs, with the reason beside each. The rule goes into the coding style. Generated output is unchanged.
Closes #427.
Why
.NET's regex match timeout is wall-clock: on a descheduled thread it fails a match that needs microseconds. #426 showed this on a stalled macOS merge-group runner and ejected an unrelated PR, and #428 removed the timeout from eleven test-side regexes. This PR covers the rest.
What changes
SnapshotStateReader's full-SHA check,SourceWatchLoader's SHA-256 check, andSnapshotMarkdownRenderer's identity-table, pin-prose and date-line patterns move toTimeout.Infinite.spec/SNAPSHOT.md,spec/source-watch.json,git rev-parseoutput and a maintainer-selected receipt.DriveManifestTestsmove toTimeout.Infinite, or toRegex.InfiniteMatchTimeoutwhere the API takes aTimeSpan.PackedReadmeTests' timeout field goes with its only use.AnalyzerConfigReader's property line, where a lazy value and a trailing whitespace run overlap;docs/;$;CommentReader's PowerShell block, where each unclosed<#scans to the end.docs/engineering/coding-style.md§3): a regex whose pattern matches in linear time over repository-pinned or test-local input passesTimeout.Infinite, orRegex.InfiniteMatchTimeoutwhere the API takes aTimeSpan. One over untrusted input, or one whose pattern can backtrack superlinearly, keeps a finite timeout with its reason beside it. This records the decision UpstreamClientContract's route regex times out on loaded runners and can eject any PR #426 and test: regexes over pinned and in-test input carry no wall-clock match timeout (#426) #428 already took, so that a new regex doesn't reintroduce the flake.protocol-and-generation.md).Evidence
tools/,tests/andsrc/found no other finite regex timeout over trusted input.Local check and review
verify-clonespassing;generate --verifycurrent; the whole Tools.Tests project at 2086/0, Packaging included;DriveManifestTests3/3 on net10.0 and net11.0. CI is the full gate.Provenance: Generator lane, coordinated and finished in Claude Code; review and audit on the opencode dispatch harness (openai/gpt-6.1-sol-fast-1m).
Need help on this PR? Tag
@codesmith-botwith what you need.