Prevent quadratic DoS in chart number-format bracket parsing#1923
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1923 +/- ##
==========================================
+ Coverage 73.29% 73.33% +0.03%
==========================================
Files 2256 2521 +265
Lines 262814 283188 +20374
Branches 56792 60585 +3793
==========================================
+ Hits 192633 207670 +15037
- Misses 44317 47879 +3562
- Partials 25864 27639 +1775 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Motivation
IndexOf(']')from every unmatched'[', producing O(n^2) CPU for long malicious inputs.Description
'['forwardIndexOfscans with a single-pass tracker (nextClosingBracket) so the literal is walked once and closing brackets are advanced linearly; the change is inOfficeIMO.Drawing/OfficeChartDrawingRenderer.Text.csinNormalizeDataLabelFormatLiteral.FlowDrawing_IgnoresBracketDirectivesInDataLabelNumberFormatsLinearlythat verifies matched directives are stripped (e.g."[Red]$0") and that very long unmatched'['prefixes are preserved as literals without quadratic cost inOfficeIMO.Tests/Pdf/PdfDocumentChartDrawingTests.cs.net472/net8.0/ other existing targets were preserved.Testing
dotnetis not available; the test is included and should be run in CI or a local environment with the repository test matrix (for example: rundotnet test OfficeIMO.Tests/OfficeIMO.Tests.csprojfor the relevant target frameworks).Codex Task