Skip to content

fix(publish-gate): match a credential split across a line break #8806

Closed

Description

@kyle-sexton

Blocked by: #8811 (same lib/publish-gate.mjs functions: land #8811 first, or ship both in one PR).

Problem

lib/publish-gate.mjs checks each line on its own: firstHit splits the text on /\r?\n/ (lib/publish-gate.mjs:68-71). A credential split across two lines, with a line break inside the value, matches no pattern. The gate misses it, and so does fix-ci's leak-scan, which reads the same pattern list.

(Lines moved: normalize is now at :66-73 and firstHit at :75. The leak-scan loads lib/publish-gate.mjs from the default branch, .github/workflows/pr-run-activity-read.yml:1865, so a lib/ change covers it with no .github change.)

Proposal

Also scan a copy of the normalized text with each line break between two adjacent lines folded out, so a credential broken by one newline still matches. Apply only single-token secret patterns to the folded copy. The hex-pair alternatives of the R2 key pair pattern (lib/publish-gate.mjs:42, \b[0-9a-f]{32}\b.*\b[0-9a-f]{64}\b and its reverse) stay on per-line scanning: on a folded copy they would pair an md5 on one line with a sha256 on the next. That means splitting the R2 key pair regex so its keyed access_key_id/secret_access_key alternative can still run on the folded copy. Leave MACHINE_PATTERNS unfolded. Measure false positives against the tracked tree and the test fixtures before blocking on that copy.

Context

A known residual for the fix-ci leak-scan, accepted at review because it is a gap shared with the gate. To be weighed in the #8282 review.

Done when

  • lib/publish-gate.mjs also scans the normalized text with line breaks folded out. Check: the PR's CI runs lib/publish-gate.test.sh and it passes.
  • lib/publish-gate.test.mjs has a case with a line break inside a credential that is detected, and fails before the change. Check: as above.
  • A control case of a 32-hex value on one line and a 64-hex value on the next raises no hit. Check: as above.
  • A control case of plain prose with line breaks and a home path split across lines raises no false hit. Check: as above.
  • False positives are measured before blocking, as a committed test: every file in git ls-files outside the test-fixture paths that findSecret and findMachine pass today still passes with the folded copy. A pattern list whose folded copy adds a hit there is left on per-line scanning, with the reason in the PR body. Check: the PR's CI runs lib/publish-gate.test.sh and it passes.
  • scripts/sync-shared-copies.sh regenerates plugins/review/lib/publish-gate.mjs and plugins/visualization/lib/publish-gate.mjs (scripts/shared-copies.txt:455-456), with fragments from scripts/new-changelog-fragment.sh --carriers-of lib/publish-gate.mjs patch. Check: the PR's CI runs the shared-copy sync check and scripts/check-changelog-fragments.sh --check, and both pass.

Activity

  1. github-actions commented on Oct 21, 2026

    @github-actions
    Contributor

    Proposed work class: work-class: scoped
    Basis: automated intake triage; the lanes App applied this class.

    Size: Small
    Complexity: Medium
    Uncertainty: Known
    Flags: none
    Blocked by: #8811

    Decision recorded.

    The gap is still on origin/main in the publish gate: publishGate and hostedGate read findSecret (lib/publish-gate.mjs:236,243), and firstHit scans line by line (:75-82), so a credential broken by a line break passes the gate. The body's "and so does fix-ci's leak-scan" no longer holds: scanLeak (:192-199) runs deeperLeak, whose straddles (:151-160) joins adjacent lines for every blocking pattern but two.
    [quote truncated; the full decision is at the link]

    #8806 (comment)

    That decision settles the open questions. I understand the request as follows: lib/publish-gate.mjs should also scan text with the line break folded out, and leave out the OpenAI key and R2 key pair patterns. It needs the listed control cases, a committed false-positive measurement, and regenerated shared copies. It should land after #8811 or in the same PR. I found no duplicates.

    Automated triage, applied by the lanes App.

  2. added
    needs-human
    on Oct 21, 2026
  3. added
    status: confirmed
    and removed
    needs-human
    on Oct 22, 2026
  4. kyle-sexton commented on Oct 31, 2026

    @kyle-sexton
    MemberAuthor

    Decision recorded.

    The gap is still on origin/main in the publish gate: publishGate and hostedGate read findSecret (lib/publish-gate.mjs:236,243), and firstHit scans line by line (:75-82), so a credential broken by a line break passes the gate. The body's "and so does fix-ci's leak-scan" no longer holds: scanLeak (:192-199) runs deeperLeak, whose straddles (:151-160) joins adjacent lines for every blocking pattern but two. That gate decides what a view may publish (lib/publish-gate.mjs:2-6), so this is a secret-leak gap, not hardening deferred under §10. It lands after #8811 or in the same PR. Agents decided this on evidence under standing direction §1.

    Done when

    • lib/publish-gate.mjs also scans the normalized text with the line break between adjacent lines folded out, leaving out the OpenAI key and R2 key pair patterns as straddles does (lib/publish-gate.mjs:145-147,154). Check: the PR's CI runs lib/publish-gate.test.sh and it passes.
    • lib/publish-gate.test.mjs has a case with a line break inside a credential that is detected, and fails before the change. Check: as above.
    • A control case of a 32-hex value on one line and a 64-hex value on the next raises no hit. Check: as above.
    • A control case of an sk- word ending one line and a word starting the next raises no hit. Check: as above.
    • A control case of plain prose with line breaks and a home path split across lines raises no false hit. Check: as above.
    • False positives are measured before blocking, as a committed test: every file in git ls-files outside the test-fixture paths that findSecret and findMachine pass today still passes with the folded copy. A pattern list whose folded copy adds a hit there is left on per-line scanning, with the reason in the PR body. Check: as above.
    • scripts/sync-shared-copies.sh regenerates plugins/review/lib/publish-gate.mjs and plugins/visualization/lib/publish-gate.mjs, with fragments from scripts/new-changelog-fragment.sh --carriers-of lib/publish-gate.mjs patch. Check: the PR's CI runs the shared-copy sync check and scripts/check-changelog-fragments.sh --check, and both pass.
  5. removed
    status: confirmed
    on Oct 31, 2026
  6. added
    status: ready
    on Oct 31, 2026
  7. melodic-automation-lanes commented on Oct 31, 2026

    @melodic-automation-lanes
    Contributor

    Not admitted to the issue lane yet: blocker #8811 is not closed by a listed human or a merge.

  8. added
    agent-ready
    on Oct 31, 2026
  9. github-actions commented on Oct 31, 2026

    @github-actions
    Contributor
    No description provided.
  10. github-actions commented on Oct 31, 2026

    @github-actions
    Contributor
    No description provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readystatus: ready

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions