Skip to content

feat(cloud-environment): scan a normalized copy of the page in pages-publish - #723

Merged
kyle-sexton merged 6 commits into
mainfrom
feature/nice-thompson-05u2ui-707
Oct 6, 2026
Merged

kyle-sexton merged 6 commits into
mainfrom
feature/nice-thompson-05u2ui-707

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Closes #707

Summary

The pages Worker (melodic-software/provisioning#705) scans a normalized copy of every upload, but pages-publish scanned only the raw bytes. Its early check therefore missed HTML-escaped, tag-split and JSON-escaped credential, path and hostname shapes. The client now scans decoded copies too, so it refuses an upload, or forces it private, before sending. The Worker remains the enforcing layer.

Fix

  • components/cloud-environment/pages-publish builds two decoded copies in linear POSIX-awk passes, with no new dependency:
    • Host copy: exactly the Worker's normalize(). Tags are stripped. &#NN;, &#xHH;, amp, lt, gt, quot, apos and nbsp are decoded only when the ; is present. \\ becomes \. A credential found here exits 4, the same page the Worker would refuse with a 422.
    • Wide copy: adds the extra named entities, numeric entities without their ;, and JS escapes (\/, \", \uXXXX, \u{…}, \xHH). A credential found only here forces the page private instead of refusing it.
    • An invalid decoded code point (NUL, above U+10FFFF, or overlong) becomes U+FFFD, so it never joins two fragments into a token shape.
  • Machine-path and hostname shapes only ever force private, on the raw copy and both decoded copies. gitleaks, when present, runs on the raw page.
  • Path shapes are reconciled with components/path-detection/machine-path-patterns.sh:
    • setup.sh installs the script as a single file, so the five HPP_* bodies are copied in word for word, and a test fails if the copy and the library differ.
    • On decoded copies they add home paths with no trailing slash, the forward-slash and 8.3 Windows forms, and Windows checkout roots.
  • The cloud-environment README documents the decoded scan and a Rollout of the decoded scan paragraph (lifecycle exception for a check that blocks from day one, with the Worker evidence below). The path-detection README names the embedded copy.

Verification

  • bash components/cloud-environment/pages-publish.test.sh: 233 assertions pass.
    • The escaped-form, HPP-only-shape, invalid-code-point and sync tests all fail against the old script.
    • Tests pin which escaped forms are refused and which go private.
    • An escaped placeholder and stray entities stay public.
    • A 2 MiB single line of each separator scans in under 20 s.
  • The Worker's own scan() (provisioning main 0809074) was run over the samples.
    • It flags the entity, hex-entity and tag-split token forms. The client refuses those.
    • It flags nothing for the _, \", _ and &#95-without-; forms. The client forces those private.
  • machine-path-patterns.test.sh and setup.test.sh pass. shellcheck, shfmt -i 2 -ci -d and markdownlint-cli2 are clean. The ci-workflows check-machine-specific-paths.sh driver reports nothing.
  • Follow-ups left out of scope:
    • the Worker's "fleet hostname" and CLOUDFLARE|CF_API_TOKEN shapes, which the client lacks;
    • a pre-existing pgup_ length mismatch (client 16+, Worker 20+).

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01G3BsUv4VeQ81gAPhk73xvs

kyle-sexton and others added 2 commits October 6, 2026 03:10
…publish

The pages Worker scans a normalized copy of each upload
(melodic-software/provisioning#705), so pages-publish now does too: tags
stripped, HTML entities decoded and JSON/JS escapes undone, in three linear
awk passes. Credential shapes found there still refuse with exit 4, and
machine paths or hostnames still force private.

The decoded copy is also matched against the path-detection bodies, embedded
verbatim because setup.sh installs the script as one file; the test pins the
copy to components/path-detection/machine-path-patterns.sh.

Closes #707

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01G3BsUv4VeQ81gAPhk73xvs
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T03:37:11.746781Z a885abb Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Code review in progress

  • Gather context (PR body, diff, changed files)
  • Understand request (CI code-review lane for PR feat(cloud-environment): scan a normalized copy of the page in pages-publish #723)
  • Review components/cloud-environment/pages-publish (awk decode passes, routing logic)
  • Review components/cloud-environment/pages-publish.test.sh
  • Review components/cloud-environment/README.md / components/path-detection/README.md
  • Adversarial validation of candidate findings
  • Post findings as inline comments + final summary

View job run

@claude

claude Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Security review in progress

  • Gather context (diff, changed files)
  • Check skip gate
  • Review changed files for security issues
  • Check instruction-surface deletions (pr-body-contract.md change)
  • Adversarial validation of candidate findings
  • Post final results

View job run

@claude

claude Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Code review in progress

  • Gather context (PR diff, CLAUDE.md/REVIEW.md, changed files)
  • Review components/cloud-environment/pages-publish changes
  • Review components/cloud-environment/pages-publish.test.sh changes
  • Review README updates
  • Check path-detection sync mechanism (machine-path-patterns.sh)
  • Adversarial validation of candidate findings
  • Post findings and final summary

View job run

@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: ce0c6fb9e3

ℹ️ 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".

kyle-sexton and others added 2 commits October 6, 2026 03:18
…ded scan

A decoded NUL or invalid code point now becomes U+FFFD instead of nothing, so
token halves around &#0;, &#99999999;, \u0000 or \x00 no longer join into a
credential shape and falsely refuse.

The decoded scan now builds two copies. The host copy repeats the Worker's
normalize() exactly, and a credential there still exits 4: the Worker already
answers that page with a 422, which also exits 4. The wide copy adds the
extra entities and JS escapes; a credential found only there sends the page
private instead of refusing it. gitleaks runs on the raw page only, as before.
The README records the rollout exception and the Worker evidence for it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01G3BsUv4VeQ81gAPhk73xvs

Copy link
Copy Markdown
Member Author

@codex review


Generated by Claude Code

@claude

claude Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Code review in progress

  • Gather context (PR diff, CLAUDE.md/REVIEW.md, changed files)
  • Review components/cloud-environment/pages-publish (awk decode passes, routing logic)
  • Review components/cloud-environment/pages-publish.test.sh
  • Review README updates
  • Check path-detection sync mechanism (machine-path-patterns.sh)
  • Adversarial validation of candidate findings
  • Post findings and final summary

View job run

@claude

claude Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Security review in progress

  • Gather context (diff, changed files)
  • Check skip gate
  • Review changed files for security issues
  • Check instruction-surface deletions (pr-body-contract.md change)
  • Adversarial validation of candidate findings
  • Post final results

View job run

@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: 154ffc105f

ℹ️ 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".

kyle-sexton and others added 2 commits October 6, 2026 03:28
…-publish

gitleaks scanned only the raw page, so a credential only a gitleaks rule
covers slipped through when markup or an entity split it. It now also runs
over the host and wide decoded copies. A raw finding still refuses with exit
4; a finding only in a decoded copy sends the page private, since gitleaks
rules are not the host's and the rollout exception covers only the host's
refusals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01G3BsUv4VeQ81gAPhk73xvs

Copy link
Copy Markdown
Member Author

@codex review


Generated by Claude Code

@claude

claude Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 5m 7s —— View job


Code review complete

  • Gather context (PR diff, CLAUDE.md/REVIEW.md, changed files)
  • Review components/cloud-environment/pages-publish (awk decode passes, routing logic)
  • Review components/cloud-environment/pages-publish.test.sh
  • Review README updates
  • Check path-detection sync mechanism (machine-path-patterns.sh)
  • Adversarial validation of candidate findings
  • Post findings and final summary

No new findings. I traced the full decode pipeline (decode_awk's tag/entity/escape passes, the utf8()/hexval() invalid-code-point handling, the host_copy vs wide_copy routing for secret_res, private_res, decoded_res, and gitleaks) against pages-publish.test.sh's 233 assertions, and against the prior Codex review rounds on this PR.

Both of Codex's P1 findings on this PR were real and are now resolved in the branch:

  • Invalid numeric/escape code points (e.g. ``) now map to U+FFFD instead of the empty string (154ffc1), so two token halves separated only by an invalid entity can no longer rejoin into a credential shape.
  • gitleaks now runs over host_copy/wide_copy in addition to the raw bytes (a885abb), with a host_copy hit routed the same way a secret_res host-copy hit is — except gitleaks findings in either decoded copy always go private rather than refuse, which the code comments (pages-publish:338-340) and the README's new "gitleaks ... refuses only on the raw bytes" line both state explicitly as intentional, since gitleaks' rule set doesn't correspond 1:1 to the Worker's scan.js patterns. pages-publish.test.sh:192-198 exercises exactly this (a tag-split and a decimal-entity gitleaks hit, both of which decode in host_copy too, and both assert private-not-refuse), so this is a deliberate, tested design choice rather than a gap.

I also checked:

  • The embedded HPP_* bodies (pages-publish:222-226) are byte-for-byte identical to components/path-detection/machine-path-patterns.sh, and the test's sync check (pages-publish.test.sh:300-303) would fail on drift.
  • The decode_awk pending/record-separator state machine for the escapes pass correctly handles the \\ → \ case and leaves pending state consistent across records for both the host (narrow) and wide decode variants.
  • README additions (components/cloud-environment/README.md, components/path-detection/README.md) accurately describe the current script behavior, and the new "Rollout of the decoded scan" paragraph satisfies component lifecycle § Enforcement rollout's requirement for equivalent live-consumer evidence and a stated reason no baseline period is needed.

Not verified by me: I could not execute bash components/cloud-environment/pages-publish.test.sh in this environment (the sandbox requires approval to run arbitrary scripts, which isn't available non-interactively here), so the "233 assertions pass" and the 2 MiB/20s timing claims in the PR body are author-claimed, not independently confirmed. Static trace of the relevant code paths did not surface a discrepancy with those claims.

Security-relevant aspects (credential/secret handling, trust boundaries) are intentionally out of scope for this lane since pr-review-security runs separately on this repo.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

claude-review has reviewed this pull request through a885abb; a later push is reviewed from there.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: a885abb434

ℹ️ 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".

@claude

claude Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 7m 49s —— View job


Security review in progress

  • Gather context (diff, changed files)
  • Check skip gate (open PR, security-relevant surface: credential-scanning logic)
  • Review changed files for security issues
  • Check instruction-surface deletions (no changes to AGENTS.md/REVIEW.md/pr-body-contract.md in this diff — N/A)
  • Adversarial hunt on the decode_awk bypass surface (running)
  • Post final results

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

claude-security-review has reviewed this pull request through a885abb; a later push is reviewed from there.

@kyle-sexton
kyle-sexton merged commit 2fe3018 into main Oct 6, 2026
22 checks passed
@kyle-sexton
kyle-sexton deleted the feature/nice-thompson-05u2ui-707 branch October 6, 2026 12:39
kyle-sexton added a commit that referenced this pull request Oct 23, 2026
… jobs (#852)

No related issue: pilot for installing the guardrails git hooks as
shared, committed lefthook jobs instead of per-clone local installs,
ahead of the same change in the other melodic-software repositories.

## Summary

Installs the guardrails plugin's three git-hook entries in this
repository so every clone gets them from `lefthook install`, and records
the commit subject pattern they enforce:

- `commit-msg-convention` (commit-msg): the subject against
`subject_pattern` in `.claude/source-control.md`.
- `pre-commit-content` (pre-commit): secrets and machine-specific paths
on added lines.
- `reference-verify` (pre-push): CLI flags, `/plugin:skill` references
and deleted paths on pushed lines.

## Fix

- `.githooks/guardrails/`: plugin-owned copies written by `install.mjs
copy --scope shared` (guardrails 0.55.4), staged `100755` where they
carry a shebang.
- `lefthook.yml`: the three jobs from the installer's snippets;
`.githooks/guardrails/**` added to the pre-commit `exclude`.
- `.github/workflows/pr-require-checks.yml`: `.githooks/guardrails/`
skipped by the ShellCheck action and the machine-path check, as
`components/path-detection/**` already is (the pattern copies
self-match).
- `.claude/source-control.md`: `subject_pattern` is the twelve
`allowedTypes` from `components/pr-convention-policy/policy.json`, an
optional scope (`"requireScope": false`), plus git's own `Merge ...` and
`Revert "..."` subjects so agent merges of main and reverts pass.
`fixup!`/`squash!`/`amend!` already pass in the hook.
- The installer's `.gitattributes` decision (`.githooks/** text eol=lf`)
is left out: `* text=auto eol=lf` already covers it.

## Verification

Enforcement rollout ([component
lifecycle](docs/component-lifecycle.md#enforcement-rollout)),
observation runs against this repository's history in report-only mode,
before blocking:

| Hook | Observation | Findings | Classification |
|---|---|---|---|
| `reference-verify` | pre-push replay of
`origin/main~200..origin/main`, 91 changed `.md`/`.sh`/`.ps1` files, 30
s | 0 | none; no file in the range exceeds the argument-size limit below
(largest `components/runner-policy/README.md`, 125,761 bytes) |
| `pre-commit-content` | each of the last 100 non-merge commits replayed
into the index, 20 s total | 1 commit (2fe3018, #723) | tool noise:
`components/cloud-environment/pages-publish` documents `/home/<x>` and
`/Users/<x>` forms in its own pattern bodies and self-matches, as the
plugin's pattern libraries do. Current content is clean; a future edit
of those lines would block. Tracked upstream as item 5 of
[claude-code-plugins#9426](melodic-software/claude-code-plugins#9426)
(repo-side exemption list) |
| `commit-msg-convention` | `subject_pattern` tested against the last
500 subjects on main and 2,000 across all branches | 0 non-matching |
none; `update stuff` and `feat:nospace` are rejected, `security: ...`,
merge and revert subjects pass |

Why blocking from the start: all three checks are deterministic, the
baseline above is clean apart from one classified self-match, and each
failure message names the file and line and says how to fix it.

Also:
- `lefthook validate`: All good. `install.mjs verify`: `ok` for all
three entries.
- The PR's own commits ran all three hooks; a normal commit's
`pre-commit-content` ran in 0.04–0.15 s (the 70 s on the first commit
was the 10.7k vendored lines).

Known defect, upstream: `reference-verify` skips a file over the 128 KiB
per-argument limit without a finding (Codex review here; item 4 of
[claude-code-plugins#9426](melodic-software/claude-code-plugins#9426)).
The copies are not edited in place: they are plugin-owned and a release
refresh would overwrite the change.

## Related

-
[claude-code-plugins#9426](melodic-software/claude-code-plugins#9426):
installer defects this pilot hit (exec bit, linted copies, machine-path
self-match, argument limit, exemption list).
-
[dotfiles#1292](melodic-software/dotfiles#1292):
removes the user-global `checks.*.declined` keys and makes `repos-sync`
run `lefthook install` after clone or fast-forward.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

pages-publish: scan a normalized copy of the page for escaped secrets and paths

1 participant