Skip to content

Add pre-commit guard against ETHERPAD_DOMAIN leaks#655

Merged
narthur merged 12 commits into
masterfrom
feat/etherpad-domain-precommit-guard
May 13, 2026
Merged

Add pre-commit guard against ETHERPAD_DOMAIN leaks#655
narthur merged 12 commits into
masterfrom
feat/etherpad-domain-precommit-guard

Conversation

@narthur

@narthur narthur commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • New scripts/check-no-etherpad-domain.sh fails the commit if ETHERPAD_DOMAIN is unset (and absent from .env), or if its literal value appears anywhere in the staged index.
  • Wired into .husky/pre-commit after lint-staged.

Test plan

  • Manual: unset env + no .env → commit blocked with explanatory message
  • Manual: value set, no offending file → commit proceeds
  • Manual: value set, offending file staged → commit blocked, offending file:line printed
  • Manual: value loaded from .env and present in tree → commit blocked
  • CI green

🤖 Generated with Claude Code

Fails the commit if ETHERPAD_DOMAIN is unset (and not in .env), or if
its value appears in any file in the staged index. Backstop against
re-leaking the pad host into public history.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Build Performance

+0.08s (+1.3%) average build time

Base (3db5873) Head (11aeedb)
Average 6.05s 6.13s
Runs 5.95,6.11,6.10 6.24,6.05,6.10

3 timed builds after one warm-up build per commit.

@narthur narthur marked this pull request as ready for review May 13, 2026 20:05
Copilot AI review requested due to automatic review settings May 13, 2026 20:05
Table column padding shifted after recent content edits.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Adds a pre-commit guard that refuses to commit if the production Etherpad domain (read from the ETHERPAD_DOMAIN env var, falling back to a parsed .env) appears anywhere in the staged index. Wires the new script into the existing Husky pre-commit hook after lint-staged.

Changes:

  • New scripts/check-no-etherpad-domain.sh that resolves ETHERPAD_DOMAIN (env → .env), aborts if unset, and uses git grep --cached -F to block commits containing the literal value (excluding .env* and the script itself).
  • Updates .husky/pre-commit to invoke the new script after lint-staged.

Reviewed changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.

File Description
scripts/check-no-etherpad-domain.sh New bash guard: parses ETHERPAD_DOMAIN from env/.env, then git grep --cached -F against staged content to block commits leaking the value.
.husky/pre-commit Adds invocation of the new guard script after pnpm exec lint-staged.
Comments suppressed due to low confidence (1)

scripts/check-no-etherpad-domain.sh:22

  • If ETHERPAD_DOMAIN is set to a very short or common string (in .env or the environment), git grep -F will produce many false-positive matches and block all commits. There is no minimum-length sanity check on the value. Consider validating that the value is plausibly a domain (e.g. contains a dot and is at least a few characters) before running the search.
if [ -z "${ETHERPAD_DOMAIN:-}" ]; then
  echo "pre-commit: ETHERPAD_DOMAIN is unset and not found in .env." >&2
  echo "Set it (e.g. in .env) so this hook can verify no staged file contains the value." >&2
  exit 1
fi

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/check-no-etherpad-domain.sh Outdated
Comment thread .husky/pre-commit Outdated
Comment thread scripts/check-no-etherpad-domain.sh Outdated
Strip whitespace and # comments when extracting ETHERPAD_DOMAIN from
.env so the guard doesn't silently match a value that includes a
trailing comment.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the hand-rolled bash .env parser with `dotenv/config`, which
already handles comments, quoting, and escapes correctly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Lets knip discover it and gives the hook a friendlier invocation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Render was relying on a cached node_modules; the recent history
rewrite invalidated the cache and there's no auto-install step, so
\`pnpm run build\` errored with \`astro: not found\`. Make install
explicit so the build is reproducible from a clean checkout.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Render's render.yaml buildCommand is snapshotted at service creation
and not re-read on push, so changes there don't take effect without a
manual Blueprint sync. Moving the install fallback into a pnpm
prebuild hook keeps \`pnpm run build\` self-contained: locally it's a
no-op (astro already in node_modules/.bin), on a clean checkout it
installs first.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirror the expost approval — pixelteer is also a git-hosted dep that
runs prepare scripts during install, which Render rejects under the
tightened onlyBuiltDependencies allowlist.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Builds don't reach any devDependency (pixelteer is used only in the
manual puppeteer scripts; vitest/diffable-html only in snapshot
specs), so installing dev deps just added install time and forced us
to whitelist git-hosted dev deps in onlyBuiltDependencies. Switch the
prebuild to \`--prod\` and drop the pixelteer entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Accessibility Issues

Summary

No baseline issues found.

BaselineHead
-0

Issue Breakdown

CodeCount
View full breakdown

Previous file-existence check failed silently inside pnpm's script
shell. \$RENDER is set by Render and only by Render, so this scopes
the install to where it's needed and stays a no-op locally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
\`pnpm install --prod\` skips devDependencies inside git-hosted deps
too — and expost's own prepare script needs tsc (a devDep) to build
itself from source. So the install has to include dev deps, which
means pixelteer (also git-hosted with build scripts) needs to stay in
the allowlist.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dreeves dreeves temporarily deployed to feat/etherpad-domain-precommit-guard - beeblog PR #655 May 13, 2026 20:46 — with Render Destroyed
@narthur narthur merged commit 66f3a8d into master May 13, 2026
12 checks passed
@narthur narthur deleted the feat/etherpad-domain-precommit-guard branch May 13, 2026 20:55
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.

3 participants