mirror of
https://github.com/storytold/cadcraft.git
synced 2026-10-24 10:56:51 -06:00
* security: bound drawing document-model work and allocation (CWE-400/407) Several document-model operations let crafted drawing data cause quadratic or exponential work, or multiply retained allocations: - Polyline grip generation rebuilt the whole segment vector inside the loop over every vertex, so enumerating one large polyline's grips was quadratic. Compute the segments once before the loop (row 35). - Associative-array name sync searched the whole replacement vector for every placement. Index replacements by placement coordinate once (last entry wins), turning the per-item lookup O(1) (row 44). - Dimension-extent bounds recursively expanded the referenced block without the shared bounds cache the Insert path uses, so a branching or self-referencing dimension block cost one pass per reference. Route it through the same `(name, depth)` cache (row 37). - Dynamic-block parsing parsed every graph-member occurrence into its own owned parameter, so a graph repeating a member multiplied one record into gigabytes. Deduplicate member handles before resolving them (row 7). - Stretch-action application linearly searched the vertex list and cloned the index vector for every selection occurrence. Index vertices by handle and skip handles already handled in the action's selection (row 30). New tests for polyline grips; all doc tests pass, clippy clean. Addresses findings rows 7, 30, 35, 37, 44. * fix: retain first dynamic stretch vertex selection --------- Co-authored-by: skylartaylor <26588250+skylartaylor@users.noreply.github.com>