Repository navigation
Code scanning: tooling, test helpers and the stack-trace and trust-name alerts - #49
Merged
Merged
Conversation
…me alerts Fixes the build, repository-tooling and test alerts code scanning has had open on main since the repository went public. - Renderer notices (alerts 5, 6): a module ID's query is cut at its first `?` and an SPDX expression's first alternative found word by word, instead of `\?.*$` and `\s+OR\s+`, which went quadratic on long runs. - Regular expressions built from names (alerts 9, 12): the TOML key and table name are escaped whole; `.`, `+` and a backslash used to match as syntax. - The `projections-tools` launcher (alert 11) prints its "checkout is gone" message with printf and a single-quoted word, instead of escaping only backticks inside double quotes, where echo also read backslashes. - Markdown to plain text (alerts 14, 24): tags are dropped in one scan with the same result as `<[^>]+>`. - Renderer unit tests (alerts 15 to 23): one shared `plain` in renderers/kit/test/markup.mjs, a character scan, replaces nine copies of `replace(/<[^>]+>/g, '')` and agentic-workflows' own scan. - The renderer test workbench (alert 25) answers a failed relay with the error's message only, never `String(error)`. - comparator_tests (alert 27): the `--trust` run's result is `with_trust`; code scanning reads any name with `trusted` in it as secret data. - reference-docs `cell` (alert 13) says why it escapes only pipes: GitHub's tables treat just `\|` specially and backslashes are the cell's Markdown. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the security hardening of build scripts, repository tooling, and test helpers.
No open issues 🎉
What changed in this PR
Addresses code-scanning alerts in Projections’ build scripts, repository tooling, and test helpers, complementing the shipped-code fixes in #48.
Changes:
- Replaces vulnerable regex operations with linear scans or complete literal escaping, and safely quotes POSIX launcher diagnostics.
- Consolidates renderer markup helpers, uses a fixed fallback for relay errors, and renames a test variable flagged by a sensitive-name heuristic.
- Adds regression and adversarial-input tests, and documents the existing Markdown table-escaping behavior.
| File | Description |
|---|---|
tools/scripts/reference-docs/shared.mjs |
Adds a comment explaining Markdown table-cell escaping. |
tools/cli/test/release.test.ts |
Tests literal TOML table-name matching. |
tools/cli/test/markdown.test.ts |
Tests tag removal, edge cases, and large inputs. |
tools/cli/test/link.test.ts |
Tests launcher diagnostics with special characters in paths. |
tools/cli/src/lib/release.ts |
Fully escapes table names used in regexes. |
tools/cli/src/lib/markdown.ts |
Replaces regex tag removal with a linear scan. |
tools/cli/src/lib/link.ts |
Uses quoted printf arguments for launcher errors. |
packages/renderers/text-diff/test/view.test.mjs |
Uses the shared markup helper for status text. |
packages/renderers/testing/playwright/server.ts |
Uses a fixed message for non-Error relay failures. |
packages/renderers/sdk/test/notices.test.mjs |
Tests module queries, license alternatives, and large inputs. |
packages/renderers/sdk/build/notices.mjs |
Reads module queries and license alternatives without vulnerable regexes. |
packages/renderers/runtime-policy/test/runtime-policy.test.mjs |
Replaces local tag removal with the shared helper. |
packages/renderers/kit/test/markup.mjs |
Adds the shared single-pass markup text helper. |
packages/renderers/kit/test/group.test.mjs |
Uses the shared markup helper. |
packages/renderers/kit/test/diff.test.mjs |
Uses the shared markup helper. |
packages/renderers/database/test/types.test.mjs |
Uses the shared helper for rendered type text. |
packages/renderers/code-statistics/test/diff.test.mjs |
Uses the shared helper after removing screen-reader-only spans. |
packages/renderers/api/test/api.test.mjs |
Consolidates markup text extraction through the shared helper. |
packages/renderers/agentic-workflows/test/agentic-workflows.test.mjs |
Moves its existing helper to the shared implementation. |
packages/integrations/vscode/test/build.test.mjs |
Adds heading-anchor behavior and large-input tests. |
packages/integrations/vscode/scripts/docs.mjs |
Scans HTML tags linearly when generating heading anchors. |
packages/cli/tests/comparator_tests.rs |
Renames the trust-result variable without changing assertions. |
.github/projections/self-topology/releases.test.mjs |
Tests literal TOML key matching. |
.github/projections/self-topology/releases.mjs |
Fully escapes TOML keys used in regexes. |
Review effort: Balanced
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.
Fixes the build, repository-tooling and test code scanning alerts open on
mainsince the repository went public: #5, #6, #9, #11, #12, #14–#25 and #27. Alerts #13 and #26 are false positives, dismissed with reasons (below). The shipped-code ReDoS alerts are in #48.js/polynomial-redospackages/renderers/sdk/build/notices.mjs?(indexOf), and an SPDX expression's first alternative is found word by word, instead of\?.*$and\s+OR\s+.js/incomplete-sanitization.github/projections/self-topology/releases.mjstomlList,tools/cli/src/lib/release.tstable[\\^$.*+?()[\]{}|/-]). Before,a.bmatchedaxb,a+bmatched[aab], and a backslash was regex syntax.js/incomplete-sanitizationtools/cli/src/lib/link.tsprintf '%s: %s\n'and the message as a single-quoted word (the existingshellQuote), instead of escaping only backticks inside double quotes, whereechoalso read backslashes in the checkout path.js/incomplete-multi-character-sanitizationpackages/integrations/vscode/scripts/docs.mjsheading anchors,tools/cli/src/lib/markdown.tsplainwithoutTags) with the same result as<[^>]+>: no<…>is ever left, and a<that closes nothing stays text.js/incomplete-multi-character-sanitizationpackages/renderers/kit/test/markup.mjsplain(a character scan, the one agentic-workflows' tests had), replaces the ninereplace(/<[^>]+>/g, '')copies; agentic-workflows uses it too.js/stack-trace-exposurepackages/renderers/testing/playwright/server.tsString(error)fallback is a fixed message.rust/cleartext-loggingpackages/cli/tests/comparator_tests.rs--trustrun's result is namedwith_trust. CodeQL's sensitive-name heuristic classifies any name containingtrusted(notuntrusted) as secret data, soassert_eq!(…, "{trusted}")read as logging a secret.Dismissed as false positives
js/incomplete-sanitization,tools/scripts/reference-docs/shared.mjscell: the value is Markdown, not text. GitHub's tables give only\|a special meaning (in code spans too), so escaping each pipe is complete; escaping backslashes would double the cell's own Markdown, as in the`\S`patterns indocs/reference/schemas/definition.md. The function now says so.rust/cleartext-logging,packages/extractors/sdk/src/context.rs:195: the "sensitive" source is the extractor SDK's public, documentedtesting::trusted(…)(a testContextwhose run trusts repository code), and the sink isContext::root's panic naming the extractor. Neither carries secret data; renaming a public SDK function to avoid a name heuristic isn't worth the break.Tests
\0prefix,(MPL-2.0 OR Apache-2.0)electing MPL-2.0, and 100,000-character adversarial inputs bounded at 1 s.tableandtomlListfind only the literal name.`,$HOME,",\nand', exits 3 and prints the path as it is.withoutTagsand heading anchors: tags dropped,<<script>script>leaves no tag, a lone<kept, linear on 100,000<(the old regex took 3.4 s).Verified with
tools check --fast(cargo check included) and the unit suites of renderer kit, agentic-workflows, api, code-statistics, database, runtime-policy, text-diff, renderer-testing and the VS Code integration, plus tools/cli's markdown, link and release tests and the self-topology tests.