Skip to content

Repository security hygiene: CodeQL and OSV scans, Renovate, CODEOWNERS, sanitizer passthrough tests - #82

Merged
nickvigilante merged 8 commits into
mainfrom
vigilante/repo-security-hygiene
Sep 15, 2026
Merged

nickvigilante merged 8 commits into
mainfrom
vigilante/repo-security-hygiene

Conversation

@nickvigilante

@nickvigilante nickvigilante commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add .github/workflows/security.yaml: CodeQL (javascript-typescript) and OSV-Scanner against pnpm-lock.yaml, mirroring coder/coder's security workflow shape for this stack.
    GitHub Code Security is not yet enabled on this private repo, so the codeql job and the osv-scanner job's SARIF-upload step are gated behind a CODE_SCANNING_ENABLED repository variable (see the admin section below); OSV-Scanner's results are always uploaded as a workflow artifact regardless, so nothing is lost while that variable is unset.
    OSV-Scanner runs via the official google/osv-scanner-action, pinned by verified commit SHA, rather than an unverified curl download.
  • Add renovate.json: extends config:recommended, enables vulnerabilityAlerts/osvVulnerabilityAlerts, pins GitHub Actions to digests, groups fumadocs-*, pins ranges. pnpm-workspace.yaml catalog support comes from Renovate's built-in npm-manager defaults, so no extra config is needed for it. Validated with renovate-config-validator (current release, not a stale cache).
  • Add .github/CODEOWNERS: default ownership plus rules naming the same owners on the sanitizer boundary (mdx-config.ts, rehype-sanitize-coder-docs.ts, html-delimiters.ts, sync.ts) and .github/workflows/. The file says plainly that these rules are documentary until a security team handle exists (see the admin section below for the ruleset change that would make them binding).
  • Add a one-sentence runner-choice comment to five workflow headers explaining the Depot-vs-ubuntu-latest rule. Comment-only, no behavior change.
  • Add tests covering every MDX_PASSTHROUGH_TYPES entry in the sanitizer: each type has a test that an engine-generated node survives and a test that a corpus-authored raw-HTML lookalike carrying a dangerous attribute is sanitized normally.

For the repository admin

  1. Enable GitHub Code Security for coder/docs-engine, then set the repository variable CODE_SCANNING_ENABLED=true. Until both are done, security.yaml's codeql job is skipped and its osv-scanner job runs but does not upload to the Security tab (it still uploads a SARIF workflow artifact).
  2. To make the CI test suite a required check, update the branch protection ruleset for main to require this status check (the only job ci.yml defines):
    • build & check
  3. Set require_code_owner_review: true on the main ruleset so .github/CODEOWNERS actually blocks merges rather than only auto-requesting reviewers.
  4. Dependabot was intentionally skipped: Renovate (already added here) covers GitHub Actions and npm/pnpm dependency updates, including security advisories via vulnerabilityAlerts/osvVulnerabilityAlerts, so a separate Dependabot config would be redundant.

Testing

  • pnpm --filter @coder/docs-transforms test — 252 passed.
  • pnpm test (root, via turbo) — 17/17 tasks passed.
  • turbo run lint --force — 11/11 packages passed.
  • actionlint .github/workflows/security.yaml — no findings.
  • npx -p renovate@latest renovate-config-validator renovate.json — validated successfully against the current Renovate release.
  • biome format on the changed test file — no new violations (two pre-existing violations elsewhere in the file are unchanged and out of scope).

Addresses the repository and threat-model items in coder/security-assessments#280 (Linear: SEC-868).


🤖 Built with AI assistance.

Mirror coder/coder's security workflow shape for this TypeScript/pnpm
monorepo: CodeQL for javascript-typescript and OSV-Scanner against
pnpm-lock.yaml, both uploading SARIF to the Security tab, pinned to
full commit SHAs, on push/PR/weekly schedule/dispatch.

Assisted-by: AI
… support

Extend config:recommended, enable vulnerabilityAlerts and
osvVulnerabilityAlerts, pin GitHub Actions to digests, pick up
pnpm-workspace.yaml catalog entries via the npm manager, group
fumadocs-* packages, and pin ranges rather than leaving them floating.

Assisted-by: AI
Default ownership on everything, plus explicit owners on the
mdx-config/sanitizer/sync files that gate untrusted corpus content and
on the workflows directory, since those are the files where a mistake
has the highest blast radius. Individuals stand in for a team handle
that doesn't exist yet.

Assisted-by: AI
One sentence per header comment: Depot (depot-ubuntu-22.04-4) runs
only the jobs that compile content and need 16 GB of memory, and
everything else runs on ubuntu-latest since it needs no memory and
Depot is metered. Comments only, no behavior change.

Assisted-by: AI
MDX_PASSTHROUGH_TYPES lists five node kinds the sanitizer must let
through untouched (mdxjsEsm, mdxFlowExpression, mdxTextExpression,
mdxJsxFlowElement, mdxJsxTextElement); only two of the five had direct
coverage. Add one pair of tests per type: an engine-generated node of
that type survives verbatim, and a corpus-authored raw-HTML lookalike
carrying a dangerous attribute (onclick, style, javascript:) is
sanitized as ordinary raw HTML rather than treated as passthrough.

Assisted-by: AI
@vercel

vercel Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
coder-docs Ready Ready Preview Sep 15, 2026 5:30pm UTC
coder-docs-router Ready Ready Preview Sep 15, 2026 5:30pm UTC

Request Review

…y OSV action, fix pins

- security.yaml: GitHub Code Security is not enabled on this private
  repo, so SARIF uploads would 403 and both jobs would be permanently
  red. Gate the codeql job, and the osv-scanner job's upload-sarif
  step, behind vars.CODE_SCANNING_ENABLED == 'true'; osv-scanner
  always uploads its SARIF as a workflow artifact so results are never
  lost while the variable is unset.
- Replace the curl-and-chmod OSV-Scanner install with the official
  google/osv-scanner-action, pinned by verified commit SHA.
- Replace the three github/codeql-action pins with the actual commit
  SHA (the previous pin was the annotated tag object, not a commit —
  it ran, but broke pin-hygiene tooling and Renovate's digest pinning).
- Add actions: read to the codeql job (required for private repos) and
  persist-credentials: false to both checkout steps.
- CODEOWNERS: say plainly that the sanitizer-boundary and workflow
  rules are documentary until a security team handle exists, since
  they currently name the same owners as the `*` default.
- renovate.json: drop the npm.fileMatch block; current Renovate covers
  pnpm-workspace.yaml catalogs by default, so it added nothing and
  used a spelling Renovate would flag for migration.
- Fix a vacuous sanitizer test: the mdxJsxFlowElement raw-HTML
  lookalike used a tag hast-util-sanitize unwraps entirely, so it
  never exercised attribute filtering. Assert the unwrap directly and
  add a second case on an allowed element to cover the real path.
- Fix a new biome format violation introduced by an earlier commit.

Assisted-by: AI
nickvigilante and others added 2 commits September 15, 2026 12:14
…dition

Review follow-ups.

`osv-scanner` could not fail and could not report. Its outcome step exited 0
both when the scan was clean and when it found vulnerabilities, so the check
was green either way; with Code Security still gated off, the SARIF went only
to a workflow artifact. A scanner nobody can hear is worse than no scanner,
because the workflow's name implies coverage. Findings now land in the job
summary as a table and as warning annotations, and stay non-blocking on
purpose: a transitive advisory with no fix should not block unrelated pull
requests, and the archive serves prerendered files rather than running this
dependency tree. The failure case is narrowed to what it should always have
been -- a scan that did not happen. OSV-Scanner exits non-zero both when it
finds something and when it breaks, so the two are now told apart by whether
a result set exists, and an unsuccessful exit with an empty result set fails
rather than reading as clean.

While the Code Security gate is closed the job says so on every run, in the
log and the summary. Before, the codeql job reported as skipped and the
Security tab stayed empty, which is indistinguishable from a clean scan.

`steps.scan.outcome` moves out of the `run:` body into `env:`. It is a fixed
enum, so this is not a live injection, but a `${{ }}` expansion inside a
shell script is not the pattern to leave lying around for the next workflow
to copy. Renamed to `security.yml`, matching the other six workflows.

The sanitizer tests grew a matrix over `MDX_PASSTHROUGH_TYPES` but not a test
of the precondition the list depends on: that corpus content cannot produce
one of those node types in the first place. That claim is what makes waving
five node types past the schema safe, and it was carried by a comment. Pin
both halves. A unit test reparses HTML written to manufacture each type by
name, asserts `rehype-raw` yields only root/element/text, and asserts the
payloads are inert afterwards. An e2e test compiles real `.md` through the
production chain with an ESM statement, two expressions, and a
component-shaped tag, and asserts the braces survive as text and no
component received the attacker attribute -- reaching those assertions at all
proves nothing was evaluated.

Renovate gains `dependencyDashboardOSVVulnerabilitySummary`, so the advisories
the workflow no longer fails on are listed somewhere standing rather than
only in a per-run summary.

Also drops a stale tracker id from a comment in a test file this commit
already edits.

Assisted-by: AI
@vercel
vercel Bot temporarily deployed to Preview – coder-docs-router September 15, 2026 17:25 Inactive
@nickvigilante
nickvigilante merged commit 65dba64 into main Sep 15, 2026
6 checks passed
@nickvigilante
nickvigilante deleted the vigilante/repo-security-hygiene branch September 16, 2026 22:34

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – coder-docs — 95ebb642 Deployed Sep 15, 2026 by vercel[bot]
Preview – coder-docs-router — 95ebb642 Deployed Sep 15, 2026 by vercel[bot]
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.

1 participant