diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cbc80d3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,80 @@ +name: CI + +# Quality gates from gobinath.com docs/DESIGN.md §8: build, privacy check, no-JS smoke test. +# Deployment stays in deploy.yml / deploy-worker.yml; this workflow only checks. + +on: + pull_request: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + site: + name: Build, privacy, no-JS smoke + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 + with: + version: 10.24.0 + run_install: false + + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 24 + cache: pnpm + + - run: pnpm install --frozen-lockfile + + - name: Build (also catches broken links) + run: pnpm docs:build + + - name: Privacy check (GPS in images, third-party loads, private terms) + run: pnpm privacy + env: + PRIVACY_TERMS: ${{ secrets.PRIVACY_TERMS }} + + - name: No-JS smoke test (pages readable, dark by default, no third-party iframes) + run: pnpm smoke + + worker: + name: Worker dry run + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 24 + - name: Bundle without deploying + working-directory: worker + run: npx --yes wrangler@4 deploy --dry-run --outdir dist + + workflows: + name: Workflow lint (actionlint, zizmor) + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: actionlint + run: | + bash <(curl -sSfL https://raw.githubusercontent.com/rhysd/actionlint/v1.7.12/scripts/download-actionlint.bash) 1.7.12 + ./actionlint -color + - name: zizmor + run: pipx run zizmor==1.32.0 --min-severity medium .github/workflows diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ae8c18d..36c0689 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -20,18 +20,18 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v6 - + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + with: + persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@v4 + uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 with: languages: javascript queries: security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@v4 - + uses: github/codeql-action/autobuild@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v4 + uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 with: category: /language:javascript diff --git a/.github/workflows/deploy-worker.yml b/.github/workflows/deploy-worker.yml index 922890c..31e4eea 100644 --- a/.github/workflows/deploy-worker.yml +++ b/.github/workflows/deploy-worker.yml @@ -14,27 +14,28 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v6 - + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + with: + persist-credentials: false - name: Setup pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0 with: version: 10.24.0 run_install: false - name: Setup Node - uses: actions/setup-node@v6 + uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 with: node-version: 20 - cache: pnpm - cache-dependency-path: worker/pnpm-lock.yaml + # No dependency cache in a deploy workflow (zizmor: cache-poisoning) + package-manager-cache: false - name: Install dependencies run: pnpm install --frozen-lockfile working-directory: worker - name: Deploy Worker - uses: cloudflare/wrangler-action@v3 + uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3.15.0 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 17e5abd..bfe7f4e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,26 +25,26 @@ jobs: contents: read steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 with: + persist-credentials: false fetch-depth: 0 # Required for lastUpdated feature - name: Setup pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0 with: version: 10.24.0 run_install: false - name: Setup Node - uses: actions/setup-node@v6 + uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 with: node-version: 20 cache: pnpm cache-dependency-path: pnpm-lock.yaml - name: Setup Pages - uses: actions/configure-pages@v5 - + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 - name: Install dependencies run: pnpm install --frozen-lockfile @@ -52,7 +52,7 @@ jobs: run: pnpm run docs:build - name: Upload artifact - uses: actions/upload-pages-artifact@v4 + uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0 with: path: .vitepress/dist @@ -70,4 +70,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 \ No newline at end of file diff --git a/.github/workflows/first-interaction.yml b/.github/workflows/first-interaction.yml index de9318c..d0d18d1 100644 --- a/.github/workflows/first-interaction.yml +++ b/.github/workflows/first-interaction.yml @@ -4,7 +4,9 @@ on: issues: types: - opened - pull_request_target: + # Needed so the welcome comment can be posted on PRs from forks. Safe here: this workflow never + # checks out or runs the PR's code; it only posts a fixed comment. + pull_request_target: # zizmor: ignore[dangerous-triggers] types: - opened @@ -17,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Drop a welcome note - uses: actions/first-interaction@v1 + uses: actions/first-interaction@3c71ce730280171fd1cfb57c00c774f8998586f7 # v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} issue-message: | @@ -30,12 +32,12 @@ jobs: - Screenshots, links, or repro steps (if it's a bug) keep the study notes extra sharp. Appreciate you taking the time to help future learners. 🙌 - pull-request-message: | + pr-message: | 🚀 **First PR vibes!** Thank you for your inaugural contribution to notes.gobinath.com. Before a maintainer reviews it, double-check the essentials: - - `npm install` (once) and `npm run docs:build` help catch broken links or markdown issues locally. + - `pnpm install` (once) and `pnpm run verify` catch broken links, privacy issues and markdown problems locally. - Reference the relevant certification file(s) in your description so reviewers can follow along. - Add screenshots, diagrams, or context if you touched visual assets in `public/` or `resources/`. diff --git a/.gitignore b/.gitignore index b3f15af..bc44faa 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,6 @@ worker/.dev.vars AGENTS.md CLAUDE.md + +# private words list for the privacy check (CI uses the PRIVACY_TERMS secret) +.privacy-terms diff --git a/.vitepress/theme/components/SpotifyEpisode.vue b/.vitepress/theme/components/SpotifyEpisode.vue new file mode 100644 index 0000000..1252f9f --- /dev/null +++ b/.vitepress/theme/components/SpotifyEpisode.vue @@ -0,0 +1,101 @@ + + + + + diff --git a/.vitepress/theme/index.ts b/.vitepress/theme/index.ts index b0d5ee9..82f06e6 100644 --- a/.vitepress/theme/index.ts +++ b/.vitepress/theme/index.ts @@ -17,6 +17,7 @@ import AITag from './components/AITag.vue' import Flashcard from './components/Flashcard.vue' import FlashcardDeck from './components/FlashcardDeck.vue' import ExamMeta from './components/ExamMeta.vue' +import SpotifyEpisode from './components/SpotifyEpisode.vue' export default { extends: DefaultTheme, @@ -39,5 +40,6 @@ export default { app.component('AIAudioPlayer', AIAudioPlayer) app.component('AITag', AITag) app.component('ExamMeta', ExamMeta) + app.component('SpotifyEpisode', SpotifyEpisode) } } diff --git a/ADDING_CERTIFICATIONS.md b/ADDING_CERTIFICATIONS.md index a5cfecf..4421c10 100644 --- a/ADDING_CERTIFICATIONS.md +++ b/ADDING_CERTIFICATIONS.md @@ -60,7 +60,7 @@ The landing page for each certification. Sections in order: 2. **Info callout** — What kind of exam this is 3. **ImageModal** — Exam overview infographic -4. **Audio Refresher** — `` for NotebookLM podcast +4. **Audio Refresher** — `` for NotebookLM podcast, or `` for an episode on Spotify (never a raw Spotify ` + ::: tip Target Candidate **Experience expected:** 2+ years building production-grade applications on AWS, general AI/ML or data engineering background, and 1 year hands-on GenAI experience. diff --git a/certifications/azure/ab-730/index.md b/certifications/azure/ab-730/index.md index b037123..18fb35e 100644 --- a/certifications/azure/ab-730/index.md +++ b/certifications/azure/ab-730/index.md @@ -36,7 +36,7 @@ This exam validates your ability to write effective prompts, manage AI conversat A podcast-style walkthrough of key exam tactics. Made to listen on the drive to the exam center as a last-minute refresher. - + --- diff --git a/certifications/azure/ab-731/index.md b/certifications/azure/ab-731/index.md index e582268..9601e7e 100644 --- a/certifications/azure/ab-731/index.md +++ b/certifications/azure/ab-731/index.md @@ -31,7 +31,7 @@ A business-focused certification on driving AI adoption using Microsoft solution A podcast-style walkthrough of key exam tactics. Made to listen on the drive to the exam center as a last-minute refresher. - + ::: info This is NOT a technical exam Think like a transformation leader, not an engineer. Questions focus on business value, adoption strategy, and responsible AI governance. diff --git a/certifications/azure/dp-800/index.md b/certifications/azure/dp-800/index.md index 335068b..36af326 100644 --- a/certifications/azure/dp-800/index.md +++ b/certifications/azure/dp-800/index.md @@ -31,7 +31,7 @@ Microsoft currently lists DP-800 as a **beta** exam. Beta exams are **not scored A podcast-style walkthrough of key exam tactics. Useful as a final pass before practice questions or exam-day review. - + ::: tip Target Candidate This exam is for developers who already work comfortably with **T-SQL**, **database design**, and **deployment workflows**, and now need to add **AI-assisted development**, **embeddings/vector search**, and **RAG patterns** into SQL-backed applications. diff --git a/certifications/github/gh-100/index.md b/certifications/github/gh-100/index.md index e2052ed..669f08b 100644 --- a/certifications/github/gh-100/index.md +++ b/certifications/github/gh-100/index.md @@ -39,7 +39,7 @@ These notes follow the **live GH-100 certification page**. As of **March 17, 202 A podcast-style walkthrough of key exam tactics. Useful as a last-minute refresher before the exam. - + --- diff --git a/certifications/github/gh-300/index.md b/certifications/github/gh-300/index.md index dfff19d..0614ece 100755 --- a/certifications/github/gh-300/index.md +++ b/certifications/github/gh-300/index.md @@ -36,7 +36,7 @@ Think like a developer who uses GitHub Copilot daily. Questions test your abilit A podcast-style walkthrough of key exam tactics. Made to listen on the drive to the exam center as a last-minute refresher. - + --- diff --git a/certifications/github/gh-500/index.md b/certifications/github/gh-500/index.md index eb6f310..665ff01 100644 --- a/certifications/github/gh-500/index.md +++ b/certifications/github/gh-500/index.md @@ -35,7 +35,7 @@ Think like a security-aware developer or DevSecOps engineer. Questions test your A podcast-style walkthrough of key exam tactics. Made to listen on the drive to the exam center as a last-minute refresher. - + --- diff --git a/certifications/github/gh-900/index.md b/certifications/github/gh-900/index.md index 7acfa79..db37b10 100755 --- a/certifications/github/gh-900/index.md +++ b/certifications/github/gh-900/index.md @@ -35,7 +35,7 @@ No prior certification required. Suitable for developers, students, project mana A podcast-style walkthrough of key exam topics. Great for a last-minute refresher on the drive to the exam center. - + --- diff --git a/package.json b/package.json index 7fd68fb..1fb1df2 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,10 @@ "scripts": { "docs:dev": "vitepress dev", "docs:build": "vitepress build", - "docs:preview": "vitepress preview" + "docs:preview": "vitepress preview", + "privacy": "node scripts/privacy-check.mjs", + "smoke": "node scripts/smoke-check.mjs", + "verify": "vitepress build && node scripts/privacy-check.mjs && node scripts/smoke-check.mjs" }, "devDependencies": { "@fontsource-variable/archivo": "^5.3.0", diff --git a/public/cheatsheets/aip-c01/aip-c01-cheatsheet.html b/public/cheatsheets/aip-c01/aip-c01-cheatsheet.html index 5f8605f..be741c1 100644 --- a/public/cheatsheets/aip-c01/aip-c01-cheatsheet.html +++ b/public/cheatsheets/aip-c01/aip-c01-cheatsheet.html @@ -6,12 +6,11 @@ AIP-C01 · 5-Minute Cheat Sheet - + + diff --git a/public/cheatsheets/aip-c01/aip-c01-flashcards.html b/public/cheatsheets/aip-c01/aip-c01-flashcards.html index 578f048..9a16f69 100644 --- a/public/cheatsheets/aip-c01/aip-c01-flashcards.html +++ b/public/cheatsheets/aip-c01/aip-c01-flashcards.html @@ -7,10 +7,9 @@ - + +
diff --git a/public/cheatsheets/aip-c01/aip-c01-flowchart.html b/public/cheatsheets/aip-c01/aip-c01-flowchart.html index 9dcfb9b..deb9fc6 100644 --- a/public/cheatsheets/aip-c01/aip-c01-flowchart.html +++ b/public/cheatsheets/aip-c01/aip-c01-flowchart.html @@ -6,11 +6,10 @@ AIP-C01 · AWS Service Decision Flowchart - + +
diff --git a/public/cheatsheets/aip-c01/aip-c01-glossary.html b/public/cheatsheets/aip-c01/aip-c01-glossary.html index d8401a8..8973f11 100644 --- a/public/cheatsheets/aip-c01/aip-c01-glossary.html +++ b/public/cheatsheets/aip-c01/aip-c01-glossary.html @@ -7,17 +7,16 @@ - + + diff --git a/public/cheatsheets/aip-c01/aip-c01-quiz.html b/public/cheatsheets/aip-c01/aip-c01-quiz.html index 01d001e..9aa1d40 100644 --- a/public/cheatsheets/aip-c01/aip-c01-quiz.html +++ b/public/cheatsheets/aip-c01/aip-c01-quiz.html @@ -7,10 +7,9 @@ - + +
diff --git a/public/cheatsheets/aip-c01/aip-c01-scorecard.html b/public/cheatsheets/aip-c01/aip-c01-scorecard.html index 11ece25..916e819 100644 --- a/public/cheatsheets/aip-c01/aip-c01-scorecard.html +++ b/public/cheatsheets/aip-c01/aip-c01-scorecard.html @@ -7,10 +7,9 @@ - + +
diff --git a/public/cheatsheets/aip-c01/aip-c01-study-plan.html b/public/cheatsheets/aip-c01/aip-c01-study-plan.html index b9cdc72..903ee7e 100644 --- a/public/cheatsheets/aip-c01/aip-c01-study-plan.html +++ b/public/cheatsheets/aip-c01/aip-c01-study-plan.html @@ -7,15 +7,14 @@ - + +
diff --git a/public/cheatsheets/dp-800/dp800-cheatsheet.html b/public/cheatsheets/dp-800/dp800-cheatsheet.html index b138b36..e6fbaea 100644 --- a/public/cheatsheets/dp-800/dp800-cheatsheet.html +++ b/public/cheatsheets/dp-800/dp800-cheatsheet.html @@ -4,11 +4,10 @@ DP-800 · 5-Minute Cheat Sheet - + + diff --git a/public/cheatsheets/dp-800/dp800-flashcards.html b/public/cheatsheets/dp-800/dp800-flashcards.html index b3c0620..7fae35a 100644 --- a/public/cheatsheets/dp-800/dp800-flashcards.html +++ b/public/cheatsheets/dp-800/dp800-flashcards.html @@ -4,11 +4,10 @@ DP-800 · Flashcards - + +
diff --git a/public/cheatsheets/dp-800/dp800-flowchart.html b/public/cheatsheets/dp-800/dp800-flowchart.html index a4ade7d..acb295f 100644 --- a/public/cheatsheets/dp-800/dp800-flowchart.html +++ b/public/cheatsheets/dp-800/dp800-flowchart.html @@ -4,11 +4,10 @@ DP-800 · Service Decision Flowchart - + +
diff --git a/public/cheatsheets/dp-800/dp800-glossary.html b/public/cheatsheets/dp-800/dp800-glossary.html index 6c7a21a..885c910 100644 --- a/public/cheatsheets/dp-800/dp800-glossary.html +++ b/public/cheatsheets/dp-800/dp800-glossary.html @@ -4,11 +4,10 @@ DP-800 · Glossary - + +
diff --git a/public/cheatsheets/dp-800/dp800-quiz.html b/public/cheatsheets/dp-800/dp800-quiz.html index 7dfa47b..18253cb 100644 --- a/public/cheatsheets/dp-800/dp800-quiz.html +++ b/public/cheatsheets/dp-800/dp800-quiz.html @@ -4,11 +4,10 @@ DP-800 · Practice Quiz - + +
diff --git a/public/cheatsheets/dp-800/dp800-scorecard.html b/public/cheatsheets/dp-800/dp800-scorecard.html index 7dce441..08077ff 100644 --- a/public/cheatsheets/dp-800/dp800-scorecard.html +++ b/public/cheatsheets/dp-800/dp800-scorecard.html @@ -4,11 +4,10 @@ DP-800 · Mock Exam Scorecard - + +
diff --git a/public/cheatsheets/dp-800/dp800_20hr_study_plan.html b/public/cheatsheets/dp-800/dp800_20hr_study_plan.html index c1f53c3..af92b7e 100644 --- a/public/cheatsheets/dp-800/dp800_20hr_study_plan.html +++ b/public/cheatsheets/dp-800/dp800_20hr_study_plan.html @@ -4,10 +4,9 @@ + + diff --git a/public/fonts/brand/archivo-latin-wdth-normal.woff2 b/public/fonts/brand/archivo-latin-wdth-normal.woff2 new file mode 100644 index 0000000..e2448d0 Binary files /dev/null and b/public/fonts/brand/archivo-latin-wdth-normal.woff2 differ diff --git a/public/fonts/brand/fonts.css b/public/fonts/brand/fonts.css new file mode 100644 index 0000000..d36eec2 --- /dev/null +++ b/public/fonts/brand/fonts.css @@ -0,0 +1,31 @@ +/* Brand fonts for the standalone pages in /cheatsheets (the VitePress site bundles its own copy). + Self-hosted, from Fontsource (OFL). gobinath.com docs/DESIGN.md §3: no font CDNs. Latin subset. */ +@font-face { + font-family: 'Archivo Variable'; + font-style: normal; + font-display: swap; + font-weight: 100 900; + font-stretch: 62% 125%; + src: url(./archivo-latin-wdth-normal.woff2) format('woff2-variations'); +} +@font-face { + font-family: 'Newsreader Variable'; + font-style: normal; + font-display: swap; + font-weight: 200 800; + src: url(./newsreader-latin-opsz-normal.woff2) format('woff2-variations'); +} +@font-face { + font-family: 'Newsreader Variable'; + font-style: italic; + font-display: swap; + font-weight: 200 800; + src: url(./newsreader-latin-opsz-italic.woff2) format('woff2-variations'); +} +@font-face { + font-family: 'JetBrains Mono Variable'; + font-style: normal; + font-display: swap; + font-weight: 100 800; + src: url(./jetbrains-mono-latin-wght-normal.woff2) format('woff2-variations'); +} diff --git a/public/fonts/brand/jetbrains-mono-latin-wght-normal.woff2 b/public/fonts/brand/jetbrains-mono-latin-wght-normal.woff2 new file mode 100644 index 0000000..cd5102a Binary files /dev/null and b/public/fonts/brand/jetbrains-mono-latin-wght-normal.woff2 differ diff --git a/public/fonts/brand/newsreader-latin-opsz-italic.woff2 b/public/fonts/brand/newsreader-latin-opsz-italic.woff2 new file mode 100644 index 0000000..d8b3029 Binary files /dev/null and b/public/fonts/brand/newsreader-latin-opsz-italic.woff2 differ diff --git a/public/fonts/brand/newsreader-latin-opsz-normal.woff2 b/public/fonts/brand/newsreader-latin-opsz-normal.woff2 new file mode 100644 index 0000000..c6e5b0e Binary files /dev/null and b/public/fonts/brand/newsreader-latin-opsz-normal.woff2 differ diff --git a/scripts/privacy-check.mjs b/scripts/privacy-check.mjs new file mode 100644 index 0000000..9275e7f --- /dev/null +++ b/scripts/privacy-check.mjs @@ -0,0 +1,122 @@ +#!/usr/bin/env node +// Privacy guard, run in CI on every PR. Fails the build when: +// 1. An image in src/ or public/ carries GPS data (EXIF in JPEG, eXIf chunk in PNG) or is HEIC. +// 2. The built site loads anything from a host that isn't on the allowlist below. +// 3. Source or built output contains a private term. The terms themselves are private, so they +// are NOT in this repo: CI reads them from the PRIVACY_TERMS secret (one per line, or comma +// separated). Locally, put them in .privacy-terms (gitignored). +// +// Copied from gobinath.com (docs/DESIGN.md §5); keep the two in sync. +// Run after `pnpm docs:build`: pnpm privacy + +import { readFileSync, readdirSync, statSync, existsSync } from 'node:fs'; +import { join, extname, relative } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const root = join(fileURLToPath(import.meta.url), '../..'); +const problems = []; +const walk = (dir, out = []) => { + if (!existsSync(dir)) return out; + for (const n of readdirSync(dir)) { + if (n === 'node_modules' || n === '_originals' || n.startsWith('.')) continue; + const p = join(dir, n); + statSync(p).isDirectory() ? walk(p, out) : out.push(p); + } + return out; +}; +const rel = (p) => relative(root, p); + +// 1. Image metadata ---------------------------------------------------------------------------- +// Looks for the GPS IFD pointer (tag 0x8825) in IFD0 of a TIFF/EXIF block starting at offset t. +function tiffHasGps(buf, t) { + const le = buf.toString('latin1', t, t + 2) === 'II'; + const u16 = (o) => (le ? buf.readUInt16LE(o) : buf.readUInt16BE(o)); + const u32 = (o) => (le ? buf.readUInt32LE(o) : buf.readUInt32BE(o)); + const ifd = t + u32(t + 4); + const n = u16(ifd); + for (let e = 0; e < n; e++) if (u16(ifd + 2 + e * 12) === 0x8825) return true; + return false; +} + +// JPEG: the APP1 "Exif" segment +export function jpegHasGps(buf) { + let i = 2; + while (i + 4 < buf.length && buf[i] === 0xff) { + const marker = buf[i + 1]; + if (marker === 0xe1 && buf.toString('latin1', i + 4, i + 10) === 'Exif\0\0' && tiffHasGps(buf, i + 10)) return true; + if (marker === 0xda) break; // start of image data, no more metadata + i += 2 + buf.readUInt16BE(i + 2); + } + return false; +} + +// PNG: the eXIf chunk holds a bare TIFF block +export function pngHasGps(buf) { + for (let i = 8; i + 8 < buf.length; ) { + const len = buf.readUInt32BE(i); + const type = buf.toString('latin1', i + 4, i + 8); + if (type === 'eXIf' && tiffHasGps(buf, i + 8)) return true; + if (type === 'IDAT' || type === 'IEND') break; + i += 12 + len; + } + return false; +} + +const contentDirs = ['certifications', 'resources', 'public', '.vitepress/theme'].map((d) => join(root, d)); +for (const f of contentDirs.flatMap((d) => walk(d))) { + const ext = extname(f).toLowerCase(); + if (ext === '.heic' || ext === '.heif') problems.push(`${rel(f)}: HEIC photo, convert to JPEG and strip metadata`); + if (ext === '.jpg' || ext === '.jpeg') { if (jpegHasGps(readFileSync(f))) problems.push(`${rel(f)}: has GPS location data`); } + if (ext === '.png') { if (pngHasGps(readFileSync(f))) problems.push(`${rel(f)}: has GPS location data`); } +} + +// 2. Third-party loads in the built site -------------------------------------------------------- +// Links people click are fine; this only checks what the browser loads on its own. +const ALLOWED_HOSTS = [ + /(^|\.)gobinath\.com$/, + /^gemini-proxy\.gobinathm\.workers\.dev$/, // AI study assistant proxy (worker/) + /^cloud\.umami\.is$/, // privacy-friendly analytics + /^api-gateway\.umami\.dev$/, // Umami collector (preconnect) + // VitePress keeps a fallback for social-link icons it doesn't bundle. The only icon used + // (github) is built in, so this URL is never requested; it just appears in the theme bundle. + /^api\.iconify\.design$/, +]; +const dist = join(root, '.vitepress', 'dist'); +if (!existsSync(dist)) problems.push('dist missing: run `pnpm docs:build` first'); +for (const f of walk(dist).filter((p) => /\.(html|css|js)$/.test(p))) { + const s = readFileSync(f, 'utf8'); + const urls = [ + ...s.matchAll(/\s(?:src|action|data-live-url|poster)="(https?:\/\/[^"]+)"/g), + ...s.matchAll(/]*\bhref="(https?:\/\/[^"]+)"/g), + ...s.matchAll(/url\(\s*["']?(https?:\/\/[^)"']+)/g), + ...s.matchAll(/@import\s+["'](https?:\/\/[^"']+)/g), + ].map((m) => m[1]); + for (const u of urls) { + const host = new URL(u).hostname; + if (!ALLOWED_HOSTS.some((r) => r.test(host))) problems.push(`${rel(f)}: loads from ${host} (${u.slice(0, 80)})`); + } +} + +// 3. Private terms ------------------------------------------------------------------------------ +const termsFile = join(root, '.privacy-terms'); +const raw = process.env.PRIVACY_TERMS || (existsSync(termsFile) ? readFileSync(termsFile, 'utf8') : ''); +const terms = raw.split(/[\n,]/).map((t) => t.trim()).filter((t) => t && !t.startsWith('#')); +if (!terms.length) console.log('[privacy] no private terms configured (PRIVACY_TERMS or .privacy-terms), skipping term check'); +else { + const files = [...contentDirs.flatMap((d) => walk(d)), ...walk(dist), ...['index.md', 'privacy.md', 'ai-disclaimer.md'].map((f) => join(root, f))] + .filter((p) => /\.(astro|ts|mjs|js|json|md|html|css|txt|xml)$/.test(p)); + for (const f of files) { + const s = readFileSync(f, 'utf8').toLowerCase(); + for (const t of terms) { + const re = new RegExp(`\\b${t.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`); + // Never print the term itself: CI logs are public + if (re.test(s)) problems.push(`${rel(f)}: contains private term #${terms.indexOf(t) + 1}`); + } + } +} + +if (problems.length) { + console.error('[privacy] FAILED\n' + [...new Set(problems)].map((p) => ' - ' + p).join('\n')); + process.exit(1); +} +console.log(`[privacy] ok (${terms.length} private terms checked)`); diff --git a/scripts/smoke-check.mjs b/scripts/smoke-check.mjs new file mode 100644 index 0000000..281fc78 --- /dev/null +++ b/scripts/smoke-check.mjs @@ -0,0 +1,45 @@ +#!/usr/bin/env node +// No-JS smoke test (gobinath.com docs/DESIGN.md §8). VitePress pre-renders every page to HTML, so if +// the built files contain the content, visitors without JavaScript can read it. +// Run after `pnpm docs:build`: pnpm smoke +import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs'; +import { join, relative } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const dist = join(fileURLToPath(import.meta.url), '../../.vitepress/dist'); +const problems = []; +const walk = (d, out = []) => { + for (const n of readdirSync(d)) { + const p = join(d, n); + statSync(p).isDirectory() ? (n !== 'assets' && n !== 'cheatsheets' && walk(p, out)) : out.push(p); + } + return out; +}; +const text = (h) => h.replace(/|/g, '').replace(/<[^>]+>/g, ' '); + +if (!existsSync(dist)) { console.error('[smoke] dist missing: run `pnpm docs:build` first'); process.exit(1); } +const pages = walk(dist).filter((p) => p.endsWith('.html')); +if (pages.length < 20) problems.push(`only ${pages.length} pages built`); + +for (const p of pages) { + const html = readFileSync(p, 'utf8'); + const rel = relative(dist, p); + // Dark by default, also without JavaScript (DESIGN.md §3) + if (!/]*class="[^"]*\bdark\b/.test(html)) problems.push(`${rel}: is not dark by default`); + // Click-to-load only: no third-party players embedded on load + if (/]+src="https?:\/\/(?!([a-z0-9-]+\.)*gobinath\.com)/.test(html)) problems.push(`${rel}: embeds a third-party iframe`); + // 404 and the certifications/ redirect stub have no article content by design + if (rel === '404.html' || rel === 'certifications/index.html') continue; + if (!/]/.test(html)) problems.push(`${rel}: no

`); + if (rel.startsWith('certifications/') && !rel.endsWith('certifications/index.html') && text(html).split(/\s+/).length < 120) + problems.push(`${rel}: under 120 words of readable text`); +} + +for (const must of ['index.html', 'privacy.html', 'ai-disclaimer.html', 'sitemap.xml']) + if (!existsSync(join(dist, must))) problems.push(`missing ${must}`); + +if (problems.length) { + console.error('[smoke] FAILED\n' + problems.map((p) => ' - ' + p).join('\n')); + process.exit(1); +} +console.log(`[smoke] ok (${pages.length} pages readable without JavaScript, dark by default)`);