Skip to content

[WRONG BRANCH] Fix: defuse bot-authored mentions in translated text after punctuation/Markdown - #84

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-issue-translation-workflow
Draft

[WRONG BRANCH] Fix: defuse bot-authored mentions in translated text after punctuation/Markdown#84
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-issue-translation-workflow

Conversation

@luvs01

@luvs01 luvs01 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent AI-controlled translated content from producing live GitHub mentions in bot-authored updates by expanding the mention-defusing boundaries beyond just whitespace and ( so mentions following punctuation or Markdown delimiters are neutralized.
  • Confirm that the control-comment detected_language bookkeeping path in the control flow was reviewed and the change focuses on the translated-body sanitization where the regression existed.

Description

  • Tighten the mention-sanitizing regex in sanitizeTranslationBody so mentions are defused when preceded by punctuation or Markdown boundaries by replacing /(^|[\s(])@.../g with /(^|[^A-Za-z0-9._%+:-])@.../g in .github/scripts/issue-translation.cjs.
  • Keep emails, npm scopes, and other mid-token at-sign forms intact while inserting a zero-width space to break GitHub mention rendering.
  • Add/adjust regression tests in .github/scripts/issue-translation.test.cjs to cover mentions after commas, brackets, and blockquote delimiters as well as org/team mentions, while asserting emails and npm:@scope remain unchanged.

Testing

  • Ran node --test .github/scripts/issue-translation.test.cjs and the translation-related tests passed (68 tests in that suite succeeded).
  • Ran bun run typecheck and bun run privacy:scan and both checks completed successfully.
  • Attempted the full suite with bun run test / bun run prepush; the translation unit changes did not cause regressions, but the full-suite run hit unrelated timeouts/failures in tests/combo-management-api.test.ts so the prepush full-suite step could not be completed end-to-end in this environment.

Summary by CodeRabbit

  • Bug Fixes
    • Improved translated issue content to safely neutralize mention-like text appearing after punctuation, Markdown links, blockquotes, and scoped references.
    • Preserved valid email addresses and at-signs used within words, decorators, and other mid-token content.
  • Tests
    • Expanded coverage for mention-like patterns across common Markdown and punctuation contexts.
    • Added checks confirming that email addresses and legitimate mid-token at-signs remain unchanged.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions github-actions Bot changed the title Fix: defuse bot-authored mentions in translated text after punctuation/Markdown [WRONG BRANCH] Fix: defuse bot-authored mentions in translated text after punctuation/Markdown Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 8, 2026 06:36
@github-actions github-actions Bot added the bug Something isn't working label Aug 8, 2026
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The issue translation sanitizer now defuses mention-shaped tokens after additional punctuation and Markdown boundaries while preserving email addresses, scopes, decorators, and other mid-token at-signs. Tests cover the expanded boundary cases.

Changes

Mention sanitization

Layer / File(s) Summary
Sanitizer boundary handling and validation
.github/scripts/issue-translation.cjs, .github/scripts/issue-translation.test.cjs
The sanitizer matches @ handles after non-token boundaries and excludes email-like, scope-like, and other mid-token occurrences. Tests cover comma, bracketed mention, blockquote, scoped mention, email, and mid-token cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: ingwannu, lidge-jun, wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: defusing bot-authored mentions after punctuation or Markdown in translated text.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-vulnerability-in-issue-translation-workflow

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/scripts/issue-translation.cjs:
- Around line 810-813: The replacement in sanitizeTranslationBody must preserve
bare scoped package names while still handling actual mentions. Add
context-aware matching around the regex so `@scope/package` and `@org/team` remain
unchanged, while npm:`@scope/package` is handled correctly, and add tests covering
all three forms.

In @.github/scripts/issue-translation.test.cjs:
- Around line 1171-1178: Extend the test around sanitizeTranslationBody to
assert that user@example.com and npm:`@scope` remain unchanged, and add a
slash-bearing scoped-package input such as npm:`@scope/package` if that form is
supported by the contract. Verify each preserved token explicitly in the output
while retaining the existing defused-mention assertions.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 273445e1-da4d-4cb6-8505-bf06b3411f23

📥 Commits

Reviewing files that changed from the base of the PR and between e3b2d6e and d470f3b.

📒 Files selected for processing (2)
  • .github/scripts/issue-translation.cjs
  • .github/scripts/issue-translation.test.cjs

Comment on lines 810 to 813
.replace(
/(^|[\s(])@([A-Za-z0-9](?:[A-Za-z0-9-]{0,38})(?:\/[A-Za-z0-9._-]+)?)/g,
/(^|[^A-Za-z0-9._%+:-])@([A-Za-z0-9](?:[A-Za-z0-9-]{0,38})(?:\/[A-Za-z0-9._-]+)?)/g,
"$1@\u200b$2",
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

node <<'NODE'
const mention = /(^|[^A-Za-z0-9._%+:-])@([A-Za-z0-9](?:[A-Za-z0-9-]{0,38})(?:\/[A-Za-z0-9._-]+)?)/g;

for (const value of ["`@scope/package`", "npm:`@scope/package`", "`@org/team`"]) {
  console.log(`${value} => ${value.replace(mention, "$1@\u200b$2")}`);
}
NODE

Repository: luvs01/opencodex

Length of output: 253


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- target context ---'
sed -n '760,835p' .github/scripts/issue-translation.cjs
printf '%s\n' '--- related tests and references ---'
rg -n -C 3 'scope/package|npm:`@scope`|org/team|zero.?width|issue-translation|mention' .github test tests 2>/dev/null || true

Repository: luvs01/opencodex

Length of output: 39724


🌐 Web query:

GitHub username mention syntax colon immediately before @user notification

💡 Result:

No, a colon is not required before a GitHub @mention to trigger a notification [1][2]. The standard syntax for mentioning a user or team on GitHub is simply the @ symbol followed immediately by their username or team name (e.g., @username) [1][3]. Placing a colon immediately before the @ symbol is not part of the standard @mention syntax and would not be interpreted as a user mention [1][4]. While colons are used in GitHub Flavored Markdown for other features—such as creating emoji (e.g.,:smile:)—they are not used for user or team mentions [4]. When you type @, GitHub provides an autocomplete list of users and teams that filters as you type [1][2]. Selecting a user or team from this list ensures the correct syntax is used to trigger a notification [1]. Notifications for @mentions occur when a user is mentioned in contexts such as issues, pull requests, and discussions, provided the user has read access to the repository [1][5][6].

Citations:


Preserve bare scoped package names

At .github/scripts/issue-translation.cjs:810-813, the regex rewrites bare @scope/package tokens, although sanitizeTranslationBody states that scopes must remain unchanged. @scope/package and @org/team have the same lexical form. Add context-aware handling and tests for bare scopes, npm:@scope/package``, and @org/team.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/issue-translation.cjs around lines 810 - 813, The
replacement in sanitizeTranslationBody must preserve bare scoped package names
while still handling actual mentions. Add context-aware matching around the
regex so `@scope/package` and `@org/team` remain unchanged, while npm:`@scope/package`
is handled correctly, and add tests covering all three forms.

Source: Path instructions

Comment on lines +1171 to +1178
it("defuses mention-shaped tokens at Markdown and punctuation boundaries", () => {
const out = sanitizeTranslationBody(
"see @octocat, comma,@team, [@user], >@org/team, user@example.com, npm:@scope",
);
assert.match(out, /@\u200boctocat/);
assert.match(out, /,@\u200bteam/);
assert.match(out, /\[@\u200buser\]/);
assert.match(out, />@\u200borg\/team/);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the preserved forms.

The test input includes user@example.com and npm:@scope``, but the test only asserts the defused mentions. A regression that inserts a zero-width character into either preserved token would still pass.

Add preservation assertions, and add a slash-bearing scoped-package case if bare npm scopes are part of the contract.

Proposed test additions
     assert.match(out, /@\u200boctocat/);
     assert.match(out, /,@\u200bteam/);
     assert.match(out, /\[@\u200buser\]/);
     assert.match(out, />@\u200borg\/team/);
+    assert.match(out, /user@example\.com/);
+    assert.match(out, /npm:`@scope/`);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it("defuses mention-shaped tokens at Markdown and punctuation boundaries", () => {
const out = sanitizeTranslationBody(
"see @octocat, comma,@team, [@user], >@org/team, user@example.com, npm:@scope",
);
assert.match(out, /@\u200boctocat/);
assert.match(out, /,@\u200bteam/);
assert.match(out, /\[@\u200buser\]/);
assert.match(out, />@\u200borg\/team/);
it("defuses mention-shaped tokens at Markdown and punctuation boundaries", () => {
const out = sanitizeTranslationBody(
"see `@octocat`, comma,`@team`, [`@user`], >`@org/team`, user@example.com, npm:`@scope`",
);
assert.match(out, /@\u200boctocat/);
assert.match(out, /,@\u200bteam/);
assert.match(out, /\[@\u200buser\]/);
assert.match(out, />@\u200borg\/team/);
assert.match(out, /user@example\.com/);
assert.match(out, /npm:`@scope/`);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/issue-translation.test.cjs around lines 1171 - 1178, Extend
the test around sanitizeTranslationBody to assert that user@example.com and
npm:`@scope` remain unchanged, and add a slash-bearing scoped-package input such
as npm:`@scope/package` if that form is supported by the contract. Verify each
preserved token explicitly in the output while retaining the existing
defused-mention assertions.

luvs01 pushed a commit that referenced this pull request Aug 18, 2026
The six open js/polynomial-redos alerts I listed included #84, which had already
been fixed fourteen minutes before I wrote the list, and omitted #50, which is
open. Still six, one member wrong. The live set is #83, #60, #53, #52, #51, #50,
all from 2026-08-12/13 - so the scoped claim holds: this campaign introduced
exactly one and fixed exactly that one.

And the one it introduced has now closed. Alert #87 reads fixed as of
03:17:06Z from the rescan of main. The earlier text predicted that and declined
to claim it in advance, which turned out to be the right call.
@luvs01 luvs01 closed this Aug 19, 2026
@luvs01 luvs01 reopened this Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant