Repository navigation
Conversation
Rewrite the regexes behind code-scanning alerts hypit-ai#38, hypit-ai#5, hypit-ai#36, hypit-ai#9 and hypit-ai#8 so they cannot backtrack super-linearly, keeping results identical: - visual-track shadows: the color group now starts at a non-space character, so it no longer competes with the preceding \s+. - comment-sticker dedent: trailing blank lines are trimmed by a backward scan instead of /\n\s*$/. - runtime-local: the Windows extension check inspects the last path segment instead of /\.[^\\/]+$/. - provider-hypihub: trailing slashes of the base URL are trimmed by a backward scan instead of /\/+$/. Also clean up the two test-only alerts: drop an identity replace in the ranking test (hypit-ai#15) and match the S3 test host with a trailing slash in the upload test (hypit-ai#16). Tests pin the previous results and run pathological inputs.
SanHsien
added a commit
to SanHsien/hypit
that referenced
this pull request
Nov 7, 2026
…i#460-hypit-ai#474; advance watermarks No PR was merged upstream, so nothing was cherry-picked: 11 PRs = 5 defer (hypit-ai#464 hypit-ai#466 hypit-ai#467 hypit-ai#469 hypit-ai#471, pinned in monitored) + 6 not applicable; 5 issues = 1 defer (hypit-ai#473) + 4 not applicable. hypit-ai#464 npm pin is moot because the fork gates publish jobs to upstream (b641cce). ROADMAP row updated with the deferred items. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
SanHsien
added a commit
to SanHsien/hypit
that referenced
this pull request
Nov 7, 2026
…e URLs (port of upstream PR hypit-ai#469) Ported before upstream merge, only the two spots that exist in this fork: comment-sticker dedent (/\n\s*$/ retried from every newline; 200k newlines took 21.8 s) and the HypiHub apiBaseUrl trailing-slash trim. Same results, linear scan. Replace with upstream's version once hypit-ai#469 is merged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This branch has not been deployed
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.
Closes #481
This PR works through the 11 open code-scanning alerts. I checked each one against the latest
mainand timed a worst-case input with Node 24, 50k-character payload unless noted. The open regex PRs (#439, #445, #446, #458) were checked first so this PR doesn't repeat their work.packages/visual-track/src/author.ts(shadows)shadowsrecipe property is authored input. The final\s+(.+)$let.+compete with\s+for whitespace, so a long whitespace run followed by a line break took ~23 s.packages/text-fine/src/surface.ts(dedent)/\n\s*$/as #5). Note on #445: its backward scan only drops the trailing run when the run begins with\n./\n\s*$/drops from the first newline inside the trailing whitespace run, so"abc \n "used to become"abc "and with #445 stays"abc \n ". The behaviour-preserving form istext.indexOf("\n", end)(used here for #5).packages/runtime-local/src/node.ts(executableExists)"."*n + "/"took ~6 s. The input is local runtime config, so the impact is low, but the fix is trivial.packages/result/src/writer.ts(mediaExtension).replace(/[^a-z0-9]+/gu, "-")runs first and collapses every run of non-alphanumerics,-included, into a single-. So/^-+|-+$/never sees more than one consecutive dash. Measured 0 ms.packages/generation/src/model.ts(pascal)"/"*n), but its only input is a generation port name.sealGenerationPortTableenforces^[a-z][A-Za-z0-9]*$on port names, so they contain no separators. Port tables are also declared by model-module authors, not by end users. Left unchanged.packages/provider-hypihub/test/upload.test.ts"https://s3.test/") matches the other routes in the same fixture.packages/ranking/test/ranking.test.tstype.name.replace(/Style$/u, "Style")was a no-op. It is nowtype.name.packages/provider-hypihub/src/upload.ts(apiBaseUrl)/\/+$/is not anchored at the start, so it is quadratic on many slashes followed by another character (~5 s). The input is the configured base URL. #458 does not touch this code.packages/provider-hypihub/src/provider.ts(apiBaseUrl)packages/comment-sticker/src/surface.ts(dedent)/\n\s*$/restarts at every newline, so many newlines followed by text took ~5 s. Not covered by #445, which only changes text-fine.packages/markup/src/syntax.ts(REFERENCE)"a" + ".a"*24 + "!"took ~4 s. Note on #439: it makes references stricter, not just faster. The current first segment's class already includes., soa.,a..banda.1are accepted today and are rejected under #439. If only the performance fix is wanted,^[A-Za-z_][A-Za-z0-9_.:-]*$accepts exactly the same language. Whether the stricter grammar is intended is up to the maintainers of that PR.What changed
visual-trackshadows: the color group is(\S.*)instead of(.+). The preceding\s+is greedy and the entry is trimmed, so the two forms match the same entries with the same groups.comment-stickerdedent:.replace(/^\n/u, "")becomes astartsWithcheck, and.replace(/\n\s*$/u, "")becomes a backward scan that finds the trailing whitespace run and cuts at its first\n.runtime-local:/\.[^\\/]+$/becomeshasExtension(), which looks at the last/or\path segment and checks for a.that is not its last character.provider-hypihub: one exported internal helper,trimTrailingSlashes()inupload.ts, replaces/\/+$/in bothapiBaseUrlfunctions.To check that the results are unchanged, I compared each old regex with its replacement on 200k random strings over an adversarial alphabet (newlines,
\r, U+2028, spaces, tabs, dots, slashes, backslashes, digits). There were 0 mismatches.Tests added
packages/visual-track/test/visual-track.test.ts:decodeVisualFrameTreatmentshadows. Covers multi-entry parsing, tab and line-break separators, the rejection cases (missing color, color spanning lines), and the 50k-run pathological entry. It finishes in about 8 ms.packages/comment-sticker/test/comment-sticker.test.ts: body-text Sticker throughdecodeCommentStickerTrackSurface. Covers dedent of indented text, trailing spaces before the last newline, and 50k newlines followed by text. The exact result is asserted, and it finishes in about 10 ms.packages/provider-hypihub/test/upload.test.ts:trimTrailingSlashescases, including 100k slashes followed by a character, plus a check that a paddedhttps://hub.test/v1//base URL still posts tohttps://hub.test/v1/files/uploads.runtime-localhas no new test. The changed check only runs onwin32.Commands run
pnpm install --frozen-lockfile: okpnpm check: ok (no errors)pnpm test: passes in CI (Linux and Windows); all checks on this PR are green.node --import tsx --test …): visual-track, comment-sticker, provider-hypihub upload, all passing.