Skip to content

fix(review): prevent generated test markdown breakout - #4383

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-markdown-fence-injection-in-ai-test-comments
Jul 9, 2026
Merged

fix(review): prevent generated test markdown breakout#4383
JSONbored merged 1 commit into
mainfrom
codex/fix-markdown-fence-injection-in-ai-test-comments

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Close a stored-comment Markdown injection vector where AI-generated Playwright tests containing triple-backtick runs could close the bot's fixed ```typescript fence and inject attacker-controlled Markdown into PR comments.
  • Keep public comment rendering safe while preserving the ability to post the generated test source for maintainer review.

Description

  • Add markdownFenceFor(source: string) and use a fence length that is one backtick longer than any run found in the generated source so the renderer no longer emits a fixed triple-backtick opener/closer (src/review/e2e-test-gen-render.ts).
  • Replace the hard-coded code-fence strings with the computed fence when rendering the AI-generated test body so nested backtick runs cannot break out of the code block (src/review/e2e-test-gen-render.ts).
  • Add a regression unit test that includes attacker-controlled backtick fences inside generated Playwright-like source and asserts the renderer uses a longer fence and keeps the content inside the code block (test/unit/e2e-test-gen-render.test.ts).

Testing

  • Ran npx vitest run test/unit/e2e-test-gen-render.test.ts and all tests in that file passed.
  • Ran npm run typecheck and git diff --check, both succeeded with no errors.
  • Attempted npm run test:coverage; the tests passed but coverage remapping failed in this container under Node v24.15.0 while the repo expects Node 22, so a full unsharded coverage run / npm run test:ci should be executed in the project CI or a Node 22 environment before pushing.

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.95%. Comparing base (c823f9c) to head (0d61629).
⚠️ Report is 10 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4383   +/-   ##
=======================================
  Coverage   93.95%   93.95%           
=======================================
  Files         400      400           
  Lines       36817    36821    +4     
  Branches    13451    13451           
=======================================
+ Hits        34592    34596    +4     
  Misses       1569     1569           
  Partials      656      656           
Files with missing lines Coverage Δ
src/review/e2e-test-gen-render.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored JSONbored self-assigned this Jul 9, 2026
@JSONbored JSONbored added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 9, 2026
@JSONbored
JSONbored merged commit 331488c into main Jul 9, 2026
10 checks passed
@JSONbored
JSONbored deleted the codex/fix-markdown-fence-injection-in-ai-test-comments branch July 9, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Development

Successfully merging this pull request may close these issues.

1 participant