Skip to content

Language-aware Trojan Source analysis and zero-install scan page - #112

Merged
cursor[bot] merged 2 commits into
mainfrom
cursor/scan-page-trojan-source-cdf8
Sep 2, 2026
Merged

cursor[bot] merged 2 commits into
mainfrom
cursor/scan-page-trojan-source-cdf8

Conversation

@byte271

@byte271 byte271 commented Sep 2, 2026 •

Copy link
Copy Markdown
Owner

Continues the defensive scanner from #111 with the next slice: language-aware Trojan Source context plus a zero-install reveal page.

What this does

  • Hidden-scan findings can now sit in comment context, not only identifier / string / emoji / prose.
  • A small source lexer assigns comment / string / code roles. Language (auto, JavaScript/C-like, Python, SQL, HTML) picks comment syntax. // after : is not a comment (http://). # is a comment only for python.
  • Bidirectional overrides in an identifier, comment, or string are critical (the three Trojan Source encodings). autofix_trojan_source / autofixTrojanSource strip only bidi_control.
  • fuckmark lint infers language from the file suffix, so // U+202E in a .js file is comment + critical.
  • Frozen spec v3 adds comment/string vectors under specs/fuckmark-hidden-scan-v1.*, including bidi beside emoji in comments/strings.
  • Zero-install page: docs/scan.html + docs/scan.js (same engine as the editor extension). fuckmark web serves /scan.html. Scanning runs in the browser; an optional local Python /api/scan confirm appears when the CLI server is up. Examples are built with String.fromCodePoint so the HTML file itself stays clean.

Package version stays 0.4.1. Frozen confirmation artifacts are unchanged.

Review follow-up

Addressed the Codex P2s: bidi in a comment or string stays critical even next to emoji; Python /api/scan truncation now keeps truncated, full counts, and peak severity across every hit (not only the first 256 listed findings).

How to try it

fuckmark web

Open /scan.html, click Trojan Source identifier or Commenting-out, then Fix Trojan Source.

Trojan Source identifier findings with U+202E badges
Commenting-out finding at critical comment context
scan_page_trojan_source_walkthrough.mp4

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

Comment and string roles now drive severity: bidi overrides in comments or
strings are critical, matching identifier reordering. Lint infers language
from the file suffix. autofix_trojan_source strips only bidi controls.

Ship docs/scan.html (and scan.js copies) so fuckmark web can serve a
browser reveal at /scan.html without uploading text. Freeze record v2
binds the new conformance vectors.

Co-authored-by: Byte271 <byte271@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 4b98f4a9-d72b-4a4b-8d76-118b294d1ed7


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@byte271
byte271 marked this pull request as ready for review September 2, 2026 01:23

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f996908fab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 235 to 236
if _is_emojiish(prev_cp) or _is_emojiish(nxt_cp) or prev_cp in _VS or nxt_cp in _VS:
return CONTEXT_EMOJI

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep comment and string bidi findings critical beside emoji

When a bidi control inside a recognized comment or string is adjacent to an emoji or variation selector (for example, //😀\u202e), this early return overrides the lexer role, classifying the finding as emoji and downgrading it to high. That contradicts the new language-aware behavior that treats bidi controls in comments and strings as critical Trojan Source encodings, and affects both lint and scan reports.

Useful? React with 👍 / 👎.

Comment thread docs/scan.html
Comment on lines +410 to +414
return {
engine: "python",
total: inner.total || findings.length,
findings,
highest: inner.highest_severity || "",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve Python scan truncation in the browser result

When the local Python engine is selected and the input has more than 256 findings, /api/scan sets truncated and returns only the first 256 finding records, but this adapter discards that flag and renders the partial array as though it were complete. A bidi control placed after 256 other hidden characters is therefore not revealed, may be excluded from the displayed highest severity, and leaves “Fix Trojan Source” disabled because that button checks only this array; retain the truncation/count information or obtain all positions before presenting the result as complete.

Useful? React with 👍 / 👎.

Trojan Source bidi in a comment or string stays on that role even when
the next glyph is emoji, so severity stays critical. Truncated Python
/api/scan results now keep counts, the truncated flag, and peak
severity across every hit, not only the first 256 listed findings.
Freeze record v3 binds the new vectors.

Co-authored-by: Byte271 <byte271@users.noreply.github.com>
@cursor
cursor Bot merged commit f388ed4 into main Sep 2, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants