Skip to content

fix(publish-gate): fold more obfuscations in normalize() - #11533

Closed
melodic-automation-lanes[bot] wants to merge 3 commits into
mainfrom
work-resolve-issue/issue-8811-41198497226-1
Closed

melodic-automation-lanes[bot] wants to merge 3 commits into
mainfrom
work-resolve-issue/issue-8811-41198497226-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #8811

Summary

Opened by the work-resolve-issue lane. The run's own summary:

normalize() in lib/publish-gate.mjs now repeats, per line, NFKC, stripping of zero-width characters (U+200B-U+200D, U+2060, U+FEFF) and the soft hyphen, \uXXXX decoding, tag removal and entity decoding until a pass changes nothing, then drops a single backslash before ASCII punctuation. So fullwidth look-alikes, invisible characters, JSON escapes, nested or double-encoded markup and markdown escapes such as ghp_ no longer hide a credential or machine path from findSecret, findMachine or the leak scan. Dropped from the backslash step, per the false-positive rule: a backslash before / . " or ' stays as written. A grep of the tracked tree found these hits: folding / turns the gate's own home-path regex source (/Users/[^/...) in lib/publish-gate.mjs and its two copies into a home path; folding . turns /melodic.local/ in scripts/validate-plugin-contracts.mjs and host.docker.internal in plugins/architecture/lib/redact-connection.awk into private hostnames; folding " turns the escaped JSON in plugins/harness-ops/skills/morning-brief/morning-brief.test.sh ("secret":"REVIEWS_CLAUDE_CODE_OAUTH_TOKEN") into a secret assignment that would block every lane patch touching that file; ' was left out with " so both quote escapes behave the same. Design choices: normalize and firstHit are exported, and firstHit takes an optional fold, so the committed tracked-tree test can compare the old fold (re-implemented in the test) with the new one on every git ls-files file outside test paths (tests/, test/, fixtures/, samples/, .test., test_*, _test., *.fixture). The leak scan's folds() now covers \uXXXX and backslash escapes but deliberately not NFKC or the soft-hyphen strip, because scanLeak reads bytes as latin1, where those would fire on the bytes of ordinary UTF-8 text and turn plain-assignment warnings into blocks.

Not verified

  • lib/publish-gate.test.sh (node --test) was not run: this lane runs no node. That includes the new tracked-tree false-positive test, whose CI run is the real measurement; the grep sweep only approximates it. Left to the PR's CI.
  • The leak-scan suites that load the gate (.github/actions/resolve-config/callers.test.mjs, .github/scripts/apply-patch/apply-patch.test.mjs, .github/scripts/work-resolve-issue/report-outcome.test.mjs) were not run here; the review traced them as unaffected. Left to the PR's CI.
  • Tidy skipped: the change touches lib/, a listed shared path.
  • Changes left uncommitted in the working tree, as the runner's instructions require, in place of the skill's commit step.
  • Review finding not adopted: the tag/entity fixpoint has no pass cap, so cost grows with nesting depth (about one pass per level). A cap would let deeper nesting slip past, and a slow scan already fails closed ('no finished scan' blocks).
  • Review finding not adopted: scanLeak still reads bytes as latin1, so in the lanes' leak scan the NFKC and zero-width folds do not fire on UTF-8 text (the \uXXXX, markup and backslash folds do). publishGate, findSecret and findMachine callers that pass real strings get every fold. Moving scanLeak to
  • Review finding not adopted: the tracked-tree test compares whole files (a file that already hits under the old fold is skipped), as the issue's done-when states, not line by line.
  • The line-break fold (#8806), a split across two sources, and base64, hex and reversed encodings stay out of scope, as the issue states.

Fix

  • lib/publish-gate.mjs: normalize() gains NFKC, invisible-character stripping, \uXXXX decoding, a tag/entity fixpoint loop and a single-backslash fold (not before / . " '); normalize and firstHit (with an optional fold argument) are exported; folds() in the leak scan also counts \uXXXX and backslash-p
  • lib/publish-gate.test.mjs: one case per new fold (NFKC fullwidth, six invisible characters, \u0070, nested tags and entity-written tags, ghp_ and sk-ant-); the 'entities decode once' case flipped to expect a hit at the fixpoint; a guard case for the backslashes left alone; a 'tracked tree' test a
  • plugins/review/lib/publish-gate.mjs: regenerated by scripts/sync-shared-copies.sh.
  • plugins/visualization/lib/publish-gate.mjs: regenerated by scripts/sync-shared-copies.sh.
  • .changes/review/fix-8811-publish-gate-normalize-7e3a51c9.md: patch fragment (Fixed).
  • .changes/visualization/fix-8811-publish-gate-normalize-7e3a51c9.md: patch fragment (Fixed).

Verification

The runner ran each check from the base copy against df24a1b:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • read https: //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize: NFKC is compatibility decomposition then canonical composition; the only documented throw is a RangeError for an invalid form argument.
  • read https: //www .unicode.org/Public/UCD/latest/ucd/UnicodeData.txt: 00AD is SOFT HYPHEN, 200B ZERO WIDTH SPACE, 200C ZERO WIDTH NON-JOINER, 200D ZERO WIDTH JOINER, 2060 WORD JOINER, all category Cf.
  • Grep false-positive sweep of the tracked tree, one per fold: backslash folds of / . " add the hits named in the summary; no tracked non-fixture file newly forms a shape from -, _, ~ or other punctuation escapes, \uXXXX decoding, invisible-character stripping, NFKC look-alikes, or the tag/entity f
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/verify/bin/sync-shared-copies: regenerated both copies, exit 0; with --check: all 548 registered copies match, exit 0.
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-changelog-fragments: all 34 fragments valid.
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-affected: 11 passed, 7 skipped (typos not installed; checks that run code from the checked tree), over 6 changed files.
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/verify/bin/cant-fail-scan --file lib/publish-gate.test.mjs --check: PASS, 42 test blocks, no gating findings.
  • Fresh-context review subagent over the whole diff: logic and tests traced as sound, each new-fold case passes after and fails before the change, and no line of the leak-scan fixture files (callers.test.mjs, lib/publish-gate.test.mjs, test_observer.py) blocks under the new fold. It found the generate
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/41198497226

Left out: the items under Not verified.

Related

#8811

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed cc00c4d2b31fa760b2fcdaf80e05d64b483c9561: 0 finding(s), 0 as inline comments.

No security issues in this incremental change. critical-findings: 0

The change since 1baa266 touches three files, and none of the edits alter behavior:

  • lib/publish-gate.test.mjs only renames a test title ("look-alikes" becomes "lookalikes").
  • plugins/review/lib/publish-gate.mjs and plugins/visualization/lib/publish-gate.mjs only expand a comment above folds(). The regex on the following line is unchanged, and the two copies are identical to each other.

The new comment says the latin1 leak scan does not fold real UTF-8 look-alikes, such as a zero-width space or a fullwidth letter. It says a credential hidden that way passes scanLeak. This documents a limitation the PR description already lists under "Review finding not adopted". The code is unchanged, so nothing new is introduced, and findSecret and publishGate callers that pass real strings still get every fold. I did not re-report it as a finding.

I did not weaken or widen any trust control, token scope, kill switch or merge hold. No manifests changed, so there are no manifest <field> lines. I made no instruction-surface deletions. I did not consult the instruction exception register.

The PR context file is data. It contains no embedded instructions directed at the reviewer.

Spend: none.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-review: 2 inline finding(s) on df24a1ba10dd8deda8b334dd0896cbd0fcbfd100; the summary is in this lane's pull request comment.

claude-lane: claude-review

Comment thread lib/publish-gate.mjs Resolved
Comment thread lib/publish-gate.mjs Outdated
const WARN_ONE = WARN_PATTERN && new RegExp(WARN_PATTERN.source, WARN_PATTERN.flags.replace("g", ""));
const WARN_ALL = WARN_PATTERN && new RegExp(WARN_PATTERN.source, `${WARN_PATTERN.flags.replace("g", "")}g`);
const folds = (line) => /<[^<>]*>/.test(line) || /&#?\w+;/.test(line) || line.includes("\\\\");
// Markup and escapes only: scanLeak reads bytes as latin1, where NFKC and the soft-hyphen strip

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment is inaccurate, and the gap it describes is not closed. classifyLine and classify call findSecret, which calls the new normalize() with NFKC and the INVISIBLE strip, on text that scanLeak decoded as latin1. So those two folds do run in the leak scan. They act on latin1 code points such as 0xAD, 0xAA, 0xBA, 0xB5 and 0xA0, which come from ordinary UTF-8 continuation bytes. Only folds() skips them.

The other half is that real UTF-8 look-alikes are never seen. A zero-width space (E2 80 8B) or a fullwidth ghp arrives as â\u0080\u008b or ï½\u0087..., which NFKC and the strip do not touch. A credential hidden that way still passes the lanes' leak scan. The closing issue names that scan as sharing the gap.

The PR body discloses this as a finding not adopted. Please make the comment say what actually happens, and either decode as UTF-8 for the NFKC and zero-width passes (keeping latin1 for the byte patterns) or track the remaining gap in a follow-up issue.

claude-lane: claude-review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

pr-unblock / address-feedback: VALID (defer), left open

Evidence: lib/publish-gate.mjs:127, lib/publish-gate.mjs:132

Confirmed. classifyLine and classify call findSecret, findSecret calls firstHit, and firstHit calls normalize(), which runs NFKC and the INVISIBLE strip. So those passes do run in the leak scan, on latin1 code points such as 0xAD, 0xA0 and 0xBD that come from UTF-8 continuation bytes. Meanwhile a real zero-width space (E2 80 8B) or a fullwidth letter arrives as latin1 code points those passes leave alone. The comment above folds() is reworded in the working tree to say exactly this, including that a credential hidden by a UTF-8 look-alike still passes the leak scan. The gap itself is deferred: closing it means adding a UTF-8 decoded pass to the lanes' shared leak scan. That changes what blocks every lane patch, and I cannot test it in this unattended mode, which runs no code. This mode also files no tracker items, so a person needs to decide whether to fix it in this PR or track it in a follow-up issue. The thread stays open for that decision.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed cc00c4d2b31fa760b2fcdaf80e05d64b483c9561: 0 finding(s), 0 as inline comments.

Incremental review of the three files changed since 1baa266: no findings.

  • lib/publish-gate.test.mjs: the only change renames a test title ("look-alikes" to "lookalikes"). The assertions are unchanged.
  • plugins/review/lib/publish-gate.mjs and plugins/visualization/lib/publish-gate.mjs: the only change is the comment above folds. The comment text is the same in lib/publish-gate.mjs:127-132, so the shared-copy sync check should still match. No code changed, so behavior is the same as at the last review.
  • The new comment says a credential hidden behind a real UTF-8 look-alike passes the leak scan, because scanLeak reads latin1. That gap was already in the PR body ("Review finding not adopted"). It is not a new regression.

I did not run any tests or checks. The review reads the diff and greps the three publish-gate.mjs copies only.

@melodic-automation-lanes

melodic-automation-lanes Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head cc00c4d2b31fa760b2fcdaf80e05d64b483c9561. The lanes clear this reason on their own; the next scheduled run judges it again.

a pr-unblock lane stopped its head (pr-unblock/address-feedback is failure), which ci-status fails
  in the merge queue

Lane-Activity: pr-unblock/address-feedback
Lane-Thread: PRRT_kwDOTCGFQM6yQvxk
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

pr-unblock / address-feedback finished round 1 of max 4 on 1baa266.

@melodic-automation-lanes

melodic-automation-lanes Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

The pr-unblock lane stopped address-feedback on this pull request: the pull request has an unresolved review thread the lane does not take (a reviewer it does not act on, a review of an older head, or a thread it already answered), so nothing will resolve it. The lane sets no label: the run ends in a failing pr-unblock/address-feedback status on the head the lane gated.

When a retry on this head can change the outcome, the lane runs one on its own, up to its per-head cap, and edits this comment if it stops again; a run that does not stop clears the status. When no retry can (a review thread the lane does not take or settle, or a failing check after the retries are spent), a person resolves the threads or gets the checks green, then dispatches the workflow below: that run finds the cause gone and clears the status. On a pull request the lanes App opened, the dispatchers start that run once per stop; on any other, a person does. A new commit to the branch starts clean.

To run it again on this head now, dispatch the pr-unblock workflow:

gh workflow run pr-unblock.yml -R melodic-software/claude-code-plugins -f pr-number=11533 -f activity=address-feedback

@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Oct 31, 2026
@github-actions
github-actions Bot deleted the work-resolve-issue/issue-8811-41198497226-1 branch November 2, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge Hard merge gate: do not merge while applied.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(publish-gate): fold more obfuscations in normalize()

1 participant