From d2882aaa8f2a7bbd7d206c480e06f90c7c871b0c Mon Sep 17 00:00:00 2001 From: Will Scott Date: Tue, 21 Jul 2026 13:12:12 -0500 Subject: [PATCH 1/3] Harden API, fix bugs, remove build-time GTM injection (v3.1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Security: - SSRF guards in api/chunk.js: http/https only, DNS-resolve + reject private/reserved IP ranges (incl. 169.254 metadata, CGNAT, IPv6 ULA), per-hop redirect re-validation, 5MB body cap, content-type allowlist - escapeHtml now escapes quotes — closes title="${fragment}" attribute XSS from scraped heading ids - Slack mrkdwn escaping in feedback.js kills pings + link spoofing; pageUrl scheme-checked and length-capped - Input validation with allowlists (400 not 500); error details no longer leak to clients Bugs: - Overlap slider was permanently stuck on Auto (unreachable else branch) - Dead node-fetch timeout replaced with native fetch + AbortSignal.timeout; node-fetch dependency removed - extract=defuddle now fails 422 instead of silently falling back to cheerio Housekeeping: - Removed scripts/build.js + vercel buildCommand; GTM-4G43 (shared SI container, matches grader/ontologizer) hardcoded; GTM_SETUP.md rewritten - Deleted ~1,900 lines of unused root design-system files - README: MIT license, searchinfluence/getchunks URLs, v3/v3.1 history, honest data-security FAQ Verified locally: SSRF/scheme/validation rejections, live extraction, http->https redirect following, slider fix, and XSS containment. Co-Authored-By: Claude Opus 4.8 (1M context) --- GTM_SETUP.md | 54 +- IMPLEMENTATION_GUIDE.md | 371 -------------- LOOK_AND_FEEL_GUIDE.md | 461 ----------------- README.md | 24 +- api/chunk.js | 173 ++++++- api/feedback.js | 26 +- getchunks-patterns.js | 569 --------------------- getchunks-styles.css | 765 ----------------------------- package-lock.json | 97 +--- package.json | 6 +- public/index.html | 24 +- scripts/build.js | 36 -- search-influence-components.html | 244 --------- search-influence-design-system.css | 472 ------------------ tasks/todo.md | 29 +- vercel.json | 1 - 16 files changed, 242 insertions(+), 3110 deletions(-) delete mode 100644 IMPLEMENTATION_GUIDE.md delete mode 100644 LOOK_AND_FEEL_GUIDE.md delete mode 100644 getchunks-patterns.js delete mode 100644 getchunks-styles.css delete mode 100755 scripts/build.js delete mode 100644 search-influence-components.html delete mode 100644 search-influence-design-system.css diff --git a/GTM_SETUP.md b/GTM_SETUP.md index d5e809a..9555179 100644 --- a/GTM_SETUP.md +++ b/GTM_SETUP.md @@ -1,48 +1,12 @@ -# Google Tag Manager Setup +# Google Tag Manager -This project uses environment variables to inject the Google Tag Manager ID at build time, so your GTM ID is never committed to the repository. +getchunks uses the **shared Search Influence GTM container `GTM-4G43`** — the same +container as AI Website Grader and Ontologizer. -## How It Works - -1. The HTML file contains placeholder `GTM-XXXXXXX` values -2. A build script (`scripts/build.js`) replaces these placeholders with the actual GTM ID from the `GTM_ID` environment variable -3. The build script runs automatically on Vercel deployments via the `buildCommand` in `vercel.json` - -## Setting Up Your GTM ID - -**Important**: This project uses `GTM_ID` (NOT `NEXT_PUBLIC_GTM_ID`). The build script runs server-side, so it doesn't need the Next.js `NEXT_PUBLIC_` prefix. - -### For Vercel Deployments - -1. Go to your Vercel project settings -2. Navigate to **Settings** → **Environment Variables** -3. Add a new environment variable: - - **Name**: `GTM_ID` (no prefix needed - this is NOT a Next.js project) - - **Value**: Your actual GTM ID (e.g., `GTM-4G43`) - - **Environment**: Production, Preview, and Development (as needed) -4. Redeploy your project - -The build script will automatically inject your GTM ID during the build process. - -### For Local Development - -Set the environment variable before running the build: - -```bash -export GTM_ID=GTM-4G43 -npm run build -``` - -Or run it inline: - -```bash -GTM_ID=GTM-4G43 npm run build -``` - -## Important Notes - -- **Never commit your real GTM ID** to the repository -- The placeholder `GTM-XXXXXXX` is safe to commit -- The build script will use `GTM-XXXXXXX` as a fallback if `GTM_ID` is not set -- Make sure to set the `GTM_ID` environment variable in your Vercel project settings +The ID is hardcoded in [public/index.html](public/index.html) (script tag in `` +plus the `