Skip to content

chore: OSS polish — CodeQL, CoC, coverage, auth-gap fix#35

Merged
carhensi merged 5 commits into
mainfrom
chore/oss-polish
May 19, 2026
Merged

chore: OSS polish — CodeQL, CoC, coverage, auth-gap fix#35
carhensi merged 5 commits into
mainfrom
chore/oss-polish

Conversation

@carhensi
Copy link
Copy Markdown
Contributor

Bundle of OSS-maturity improvements to bring the extension closer to "reference-grade". Five focused commits, no production-code refactors beyond the auth-gap fix.

Commits

# Type Scope
1 ci CodeQL workflow — push/PR/weekly, security-and-quality query set, results in Security tab
2 docs CODE_OF_CONDUCT.md — Contributor Covenant 2.1, contact aligned with SECURITY.md
3 chore npm run coverage script + README mention (vitest --coverage was installed but unexposed)
4 fix(auth) New requireInstanceExists(db, id) for read-only server fns. Closes a defence-in-depth gap in getApiKeyStatusFn and checkPermissionsFn where assertInstanceContextMatches silent-returns on missing rows. Read-only: deliberately does NOT check the paused flag. Also covers parseConsentedScopes edge-cases.
5 test Coverage push from 77% → 85% lines via targeted edge-case tests for logger, webhooks/handler, webhooks/dedup, and bunnycdn (adoption flow + timeout + empty-body).

Coverage delta

Before After Δ
Lines 78.21% 85.17% +6.96
Statements 76.84% 83.99% +7.15
Branches 72.30% 78.82% +6.52
Functions 75.42% 80.67% +5.25
Tests 224 253 +29

Files now at / near 100%

logger.ts 100%, webhooks/handler.ts 100%, webhooks/dedup.ts 96%, crypto.ts 96%, domain/pull-zone.ts 91%, bunnycdn.ts 86%, scope.ts 81%.

Out of scope (separate PRs)

  • Zod-validate server-fn inputs — touches ~7 files, adds dep, changes error UX. Worth a dedicated feat() PR.
  • Type ghostmaker RPC client calls (4 client-side @ts-expect-error sites in lib/bunny-cdn-api.ts) — needs typed wrapper, own focused PR.
  • Push bunnycdn.ts coverage 86% → 90%+ — diminishing returns, more HTTP-mock plumbing.

Test plan

  • npm test — 253 / 253 green
  • npm run typecheck — clean
  • npm run code-check — clean (biome)
  • npm run coverage — produces report, summary at the top
  • npm run build — clean
  • Manual: confirm CodeQL workflow appears in Actions tab + first run completes
  • Manual: verify Security tab surfaces any CodeQL findings post-merge

🤖 Generated with Claude Code

carhensi and others added 5 commits May 19, 2026 12:30
Runs on push to main, every PR against main, and weekly to pick up
newly-disclosed CodeQL rules. Uses the 'security-and-quality' query
suite for js/ts, with results surfaced in the repository Security tab.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Standard OSS contribution policy. Contact address aligned with
SECURITY.md (hosting@hdnet.de).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`vitest --coverage` was already installed (@vitest/coverage-v8) but
not exposed as a script; current run reports 77% statements / 78%
lines across 224 tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`getApiKeyStatusFn` and `checkPermissionsFn` ran without any
downstream `requireScope` / `requireEnabled` check, so a request
against a non-existent (or just-removed) extension instance fell
straight through `assertInstanceContextMatches`'s silent-return.
Damage was bounded — status returned `{hasApiKey:false}` and the
permissions read is gated by the mittwald API — but the gap was
inconsistent with every other server function.

New `requireInstanceExists(db, instanceId)`:
- Reads-friendly: deliberately does NOT check the paused flag
  (reads stay available so the UI can render the paused banner).
- Returns the row so callers that needed to fetch it can skip
  a second query.

Also adds three `parseConsentedScopes` edge-case tests (invalid
JSON, non-array payload, non-string entries) — fails-closed
behaviour was untested.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds focused tests for previously-uncovered paths:

- logger.ts (78% → 100%): dev console output, production JSON
  lines, key-name redaction (top-level, nested, arrays, case-
  insensitive), non-object extras wrapped under `value`.

- webhooks/handler.ts (68% → 100%): bunny.deletePullZone happy
  path, bunny failure swallowed (instance still removed), no-API-
  key branch logs and skips bunny call.

- webhooks/dedup.ts (52% → 96%): startWebhookDedupSweeper active
  mode under fake timers — prune fires on tick, db errors are
  caught, repeated calls are idempotent.

- bunnycdn.ts (76% → 86%): createPullZone adoption flow (name-
  taken in our account → adopt; origin mismatch → throw;
  not-in-our-account → NAME_GLOBAL_TAKEN; non-taken errors
  rethrown). bunnyFetch AbortError → BUNNY_TIMEOUT.
  bunnyRequest empty-body 200 → undefined.

Total: 224 → 253 tests, 78.2% → 85.2% lines, 76.8% → 84.0% statements.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-advanced-security
Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@carhensi carhensi merged commit 76157d0 into main May 19, 2026
7 checks passed
@carhensi carhensi deleted the chore/oss-polish branch May 19, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants