Repository navigation
fix(tools): eliminate ReDoS backtracking in tfdoc MARK_OPTS_RE - #414
Merged
Merged
Conversation
aghassemlouei
requested review from
Calvin-Cheng1,
LanceWray,
mgcarey-google and
pulsingSignal
November 12, 2026 16:52
aghassemlouei
marked this pull request as ready for review
November 12, 2026 16:55
Calvin-Cheng1
approved these changes
Nov 12, 2026
Open
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.
Description
Replaces the nested repetition in
MARK_OPTS_REinsidetools/tfdoc.pywith an explicit whitespace-delimitedkey:valuesequence so unterminated<!-- TFDOC OPTSmarkers cannot trigger exponential regular-expression backtracking.In #311,$2^n$ ways when the closing
MARK_OPTS_REwas widened from(?:[a-z_]+:[0-1]\s*?)+to(?:[a-z_]+:\S+\s*?)+to support string option values such asexclude:outputs.tf. Because\s*?matches zero characters and\S+overlaps with[a-z_]+:, adjacentkey:valuerepetitions can split a single non-whitespace token in-->delimiter is absent. Requiring\s+between option tokens matches the whitespace splitting inget_tfref_optsand makes every quantifier boundary disjoint.Closes Code Scanning alert #339
Type of Change
Deployment & Compliance Impact
tools/tfdoc.py.Checklist
Code Quality & Reusability
modules/orfast/stages-aw/can be leveraged for this change.docs/naming-convention.md.Documentation
README.mdof the modified module or blueprint.Security
Testing
Testing Performed
tests/test_tfdoc.pycovering single-option, multi-optionexclude, and 500-repeat unterminated<!-- TFDOC OPTS _:inputs (11/11passing in0.004s).123/123passing),ruff format --check,ruff check,tools/check_boilerplate.py, andtools/check_documentation.py --no-show-summary modules fast blueprints.