diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6db85ce..af13bab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,6 +102,11 @@ jobs: - name: Third-party notices run: npm run gen-notices -- --check + # The same policy over every package in package-lock.json, transitive dependencies and + # each platform's binaries included; anything outside it needs a per-package review. + - name: Licences (whole dependency tree) + run: npm run check-licenses + # Fail if any changed image under src/assets/ still carries GPS or a camera serial. - name: Check EXIF (changed images) env: diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml new file mode 100644 index 0000000..6935ef0 --- /dev/null +++ b/.github/workflows/qodana.yml @@ -0,0 +1,87 @@ +name: Qodana + +# JetBrains Qodana (Qodana for JS, WebStorm's inspections) over the whole repository: on every +# PR, on main and by hand. Settings live in qodana.yaml. Results go to Qodana Cloud (the +# project token is the QODANA_TOKEN secret) and, for main, to GitHub code scanning as SARIF. +# +# Advisory, not required: the main ruleset requires only `build`, and Dependabot and fork PRs +# get no secrets, so they skip this job like the SonarCloud one in ci.yml. +on: + pull_request: + push: + branches: [main] + paths-ignore: ["poli0981.dev-docs/**", "*.md", "LICENSE"] + workflow_dispatch: + +# Explicit — a missing block makes GitHub default every scope to `none`. +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + # Cancel superseded PR runs; let main runs finish. + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + qodana: + if: >- + github.event_name != 'pull_request' || + (github.event.pull_request.head.repo.full_name == github.repository && + github.actor != 'dependabot[bot]') + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + checks: write # problem annotations on the commit + pull-requests: write # the summary comment on PRs + security-events: write # SARIF upload (main and manual runs) + steps: + # Pinned to commit SHAs like every other workflow here; Dependabot keeps them current. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + # The PR's own head commit, not the merge preview, so Qodana Cloud links to it. + ref: ${{ github.event.pull_request.head.sha || github.sha }} + fetch-depth: 0 + submodules: recursive + persist-credentials: false + + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version-file: .nvmrc + cache: npm + + # Same rules as ci.yml: no dependency lifecycle script runs in CI, and any lockfile + # package with an install script must be on package.json#allowScripts. + - name: Install + run: npm ci --ignore-scripts + + - name: Install scripts allow-listed + run: npm run check-install-scripts + + # Gitignored, generated types the TypeScript service needs to resolve imports of + # cloudflare:workers, astro:content and friends. + - name: Generate types + run: | + npm run types + npm run types:widgets + npm run astro -- sync + + - name: Qodana scan + uses: JetBrains/qodana-action@13e3acbbaeb2cbfc37893b98e74594985edf42eb # v2026.2.4 + env: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} + QODANA_ENDPOINT: https://qodana.cloud + with: + # Whole repository every time (it is small), so the quality gate in qodana.yaml + # always judges the full picture rather than the files a PR happens to touch. + pr-mode: false + upload-result: true + + # Like the OSV scan: main and manual runs only, so PR runs don't open code-scanning + # alerts for code that may never merge. + - name: Upload SARIF to code scanning + if: ${{ !cancelled() && github.event_name != 'pull_request' }} + uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 + with: + sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json + category: qodana diff --git a/README.md b/README.md index 26c95ed..c83d819 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![CI](https://github.com/poli0981/poli0981-dev/actions/workflows/ci.yml/badge.svg)](https://github.com/poli0981/poli0981-dev/actions/workflows/ci.yml) [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=poli0981_poli0981-dev&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=poli0981_poli0981-dev) +[![Qodana](https://github.com/poli0981/poli0981-dev/actions/workflows/qodana.yml/badge.svg)](https://github.com/poli0981/poli0981-dev/actions/workflows/qodana.yml) [![License: GPL-3.0](https://img.shields.io/badge/code-GPL--3.0-blue)](LICENSE) The personal site of Kokone (SkullMute) — dev portfolio, blog, short fiction and a hub for @@ -20,7 +21,7 @@ the SkullMute channel, in Vietnamese and English. Live at **[poli0981.dev](https | Content | Markdown/MDX in [`poli0981/content`](https://github.com/poli0981/content) (git submodule `src/content`) | | Search | Pagefind (built after `astro build`) | | Tooling | Node 26 · TypeScript 7 (`tsc`) next to TypeScript 6 (astro check, typescript-eslint) · `node:test` · ESLint · Prettier · knip | -| Quality | SonarCloud quality gate · CodeQL · OSV-Scanner · Snyk · Dependabot (3-day cooldown) · axe-core accessibility gate | +| Quality | SonarCloud quality gate · Qodana · CodeQL · OSV-Scanner · Snyk · Dependabot (3-day cooldown) · axe-core gate · licence check | ## How it fits together diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md index 7c066bc..bdca042 100644 --- a/THIRD-PARTY-NOTICES.md +++ b/THIRD-PARTY-NOTICES.md @@ -74,9 +74,11 @@ inventory is `package-lock.json`; platform binaries are covered in prose below. ## Licenses outside the standard allowlist -**MPL-2.0** — 3 package(s): `@axe-core/playwright`, `@resvg/resvg-js`, `satori` +**MPL-2.0** — 3 package(s): -> Reviewed: File-level copyleft. satori and @resvg/resvg-js are used unmodified as build-time tools and never shipped to the browser, so no source-disclosure obligation is triggered. +- `@axe-core/playwright` — reviewed: File-level copyleft. Runs only in the accessibility tests (tests/a11y); never shipped. +- `@resvg/resvg-js` — reviewed: File-level copyleft. Used unmodified at build time to draw the OG cards (scripts/gen-og.mjs); never shipped to the browser or the Worker. +- `satori` — reviewed: File-level copyleft. Used unmodified at build time to draw the OG cards (scripts/gen-og.mjs); never shipped to the browser or the Worker. @@ -108,8 +110,8 @@ Not packages — listed for transparency: - **Discord** — a webhook receiving bug-report notifications. - **YouTube, Steam and GitHub public APIs** — read by the widgets cron worker; visitors' browsers never call them (images are mirrored and served from the site). -- **SonarCloud, CodeQL, OSV-Scanner, Snyk** — code and dependency analysis in CI; nothing they do - reaches the running site. +- **SonarCloud, Qodana (JetBrains), CodeQL, OSV-Scanner, Snyk** — code and dependency analysis in + CI; nothing they do reaches the running site. ## Fonts diff --git a/package.json b/package.json index 57ddf53..e69cff9 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "test:coverage": "node --import ./tests/support/register.mjs --test --experimental-test-coverage --test-coverage-include=\"src/**/*.ts\" --test-coverage-include=\"workers/widgets/src/**/*.ts\" --test-coverage-exclude=\"**/*.d.ts\" --test-coverage-exclude=\"src/lib/easter.ts\" --test-coverage-exclude=\"src/content.config.ts\" --test-coverage-lines=80 --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info \"tests/**/*.test.ts\"", "test:a11y": "node --test --test-concurrency=1 \"tests/a11y/*.spec.ts\"", "gen-notices": "node scripts/gen-notices.mjs", + "check-licenses": "node scripts/check-licenses.mjs", "new:post": "node scripts/new-post.mjs", "gen-og": "node scripts/gen-og.mjs", "preview": "astro preview", diff --git a/qodana.yaml b/qodana.yaml new file mode 100644 index 0000000..a0a7e1a --- /dev/null +++ b/qodana.yaml @@ -0,0 +1,45 @@ +# JetBrains Qodana — run by .github/workflows/qodana.yml on every PR and on main +# (docs 08 §0). Reference: https://www.jetbrains.com/help/qodana/configuration-reference.html +# +# Qodana for JS is WebStorm's inspection engine. It reads .ts/.js/.mjs, CSS, JSON, YAML and +# Markdown — not .astro or .svelte, which stay with astro check, eslint-plugin-astro/-svelte +# and Prettier in ci.yml. +version: "1.0" +linter: qodana-js + +# Native mode: the workflow sets up Node from .nvmrc and runs `npm ci` itself, so the analysis +# resolves the same Node 26 and node_modules as the build (the Docker image ships its own Node). +withinDocker: false + +# Quality gate: the first run's 11 findings were fixed or, for one inspection, switched off +# below with the reason, so any problem now is a new one and turns the check red. +failThreshold: 0 + +profile: + name: qodana.recommended + inspections: + # Not source code: build output, coverage, generated types, the content submodule (prose, + # in its own repo), the design docs and the frontmatter templates. + - group: ALL + ignore: + - "dist/**" + - "coverage/**" + - ".astro/**" + - ".wrangler/**" + - "src/content/**" + - "poli0981.dev-docs/**" + - "docs/templates/**" + - "public/pagefind/**" + - "worker-configuration.d.ts" + - "workers/widgets/worker-configuration.d.ts" + # Prose checkers don't read Vietnamese: every other word of the bilingual UI strings, + # comments and docs would be a "typo". + - inspection: SpellCheckingInspection + enabled: false + - inspection: GrazieInspection + enabled: false + # "Import can be shortened" wants tsconfig's `@/` alias or extensionless paths. The build + # scripts and astro.config.mjs run under plain Node, where `@/` doesn't resolve and a + # TypeScript import needs its `.ts`; in src/ relative vs alias imports are a style choice. + - inspection: ES6PreferShortImport + enabled: false diff --git a/scripts/check-csp-hashes.mjs b/scripts/check-csp-hashes.mjs index 0ce8069..48cab6d 100644 --- a/scripts/check-csp-hashes.mjs +++ b/scripts/check-csp-hashes.mjs @@ -37,7 +37,7 @@ const CONTENT = /\bcontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i; // CodeQL js/bad-tag-filter found three separate holes here, one patch at a time, so the // cases below are now asserted on every run instead of being re-reasoned from scratch. const SCRIPT = /]*)?>([\s\S]*?)<\/script(\s[^>]*)?>/gi; -const JSON_LD = /type=("|')?application\/ld\+json/i; +const JSON_LD = /type=["']?application\/ld\+json/i; // Inline