changeguard 0.0.0-stage → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +450 -0
  2. package/LICENSE +202 -0
  3. package/LICENSE-PROPRIETARY +94 -0
  4. package/README.md +321 -2
  5. package/SECURITY.md +40 -0
  6. package/data/changes/openai.seed.json +87 -0
  7. package/data/changes/shopify.seed.json +42 -0
  8. package/data/changes/stripe.seed.json +60 -0
  9. package/data/changes/supabase.seed.json +56 -0
  10. package/data/changes/twilio.seed.json +63 -0
  11. package/data/openapi/openai/meta.json +9 -0
  12. package/data/openapi/openai/new.json +24 -0
  13. package/data/openapi/openai/old.json +68 -0
  14. package/data/providers/openai.json +60 -0
  15. package/data/providers/shopify.json +52 -0
  16. package/data/providers/stripe.json +57 -0
  17. package/data/providers/supabase.json +56 -0
  18. package/data/providers/twilio.json +57 -0
  19. package/dist/analyze/go-analyzer.js +343 -0
  20. package/dist/analyze/index.js +77 -0
  21. package/dist/analyze/js-analyzer.js +380 -0
  22. package/dist/analyze/parser.js +78 -0
  23. package/dist/analyze/py-analyzer.js +313 -0
  24. package/dist/analyze/rules.js +1 -0
  25. package/dist/analyze/ts-utils.js +62 -0
  26. package/dist/cli.js +335 -0
  27. package/dist/codemod/apply.js +159 -0
  28. package/dist/config.js +121 -0
  29. package/dist/deps/manifests.js +145 -0
  30. package/dist/github/api.js +136 -0
  31. package/dist/github/auth.js +54 -0
  32. package/dist/impact/engine.js +384 -0
  33. package/dist/ingest/canonical.js +52 -0
  34. package/dist/ingest/changelog-html.js +63 -0
  35. package/dist/ingest/feed-client.js +99 -0
  36. package/dist/ingest/feed-keys.js +198 -0
  37. package/dist/ingest/feed.js +178 -0
  38. package/dist/ingest/github-releases.js +59 -0
  39. package/dist/ingest/note-parser.js +274 -0
  40. package/dist/ingest/openapi-diff.js +217 -0
  41. package/dist/ingest/store.js +181 -0
  42. package/dist/llm/explanation.js +273 -0
  43. package/dist/mcp/format.js +116 -0
  44. package/dist/mcp/index.js +29 -0
  45. package/dist/mcp/protocol.js +36 -0
  46. package/dist/mcp/server.js +110 -0
  47. package/dist/mcp/standalone.js +12 -0
  48. package/dist/mcp/tools.js +189 -0
  49. package/dist/notify/index.js +174 -0
  50. package/dist/providers/registry.js +215 -0
  51. package/dist/report/html.js +194 -0
  52. package/dist/report/markdown.js +90 -0
  53. package/dist/report/pr-draft.js +37 -0
  54. package/dist/scan.js +168 -0
  55. package/dist/source/repo-source.js +100 -0
  56. package/dist/types.js +6 -0
  57. package/dist/util/http.js +40 -0
  58. package/dist/util/logger.js +61 -0
  59. package/dist/util/metrics.js +99 -0
  60. package/dist/util/request-context.js +22 -0
  61. package/dist/util/task-queue.js +69 -0
  62. package/dist/util/versions.js +52 -0
  63. package/fixtures/sample-repo/cmd/billing/main.go +47 -0
  64. package/fixtures/sample-repo/go.mod +12 -0
  65. package/fixtures/sample-repo/package.json +17 -0
  66. package/fixtures/sample-repo/requirements.txt +7 -0
  67. package/fixtures/sample-repo/services/ai.py +65 -0
  68. package/fixtures/sample-repo/src/billing.ts +68 -0
  69. package/package.json +110 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,450 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ Nothing yet.
11
+
12
+ ## [0.7.1] - 2026-11-23
13
+
14
+ ### Changed
15
+
16
+ - npm `keywords` populated (16 terms: mcp, breaking-changes, api-monitoring,
17
+ codemod, impact-analysis, provider names, claude-code, cursor, typescript,
18
+ static-analysis, developer-tools). The npm site search previously had zero
19
+ hits for this package because the field was empty. Requires a version bump
20
+ to reach the registry, hence 0.7.1.
21
+
22
+ ## [0.7.0] - 2026-11-19
23
+
24
+ ### Added
25
+
26
+ - MCP server (`changeguard mcp` / `changeguard-mcp` bin): the deterministic
27
+ scan engine is now reachable by agents over stdio JSON-RPC. Three read-only
28
+ tools — `list_breaking_changes`, `check_impact` (file:line impact with rule
29
+ ids), `get_feed_status` (explicit provenance for citation) — with
30
+ agent-friendly Markdown output, zero dependencies, and zero kernel changes
31
+ (`persist:false`, `online:false`). Safety is structural: absolute-path
32
+ validation with an optional `CHANGEGUARD_MCP_ALLOWED_ROOTS` allow-list, 30s
33
+ scan timeout, stdout carries protocol frames only (diagnostics on stderr),
34
+ BOM-tolerant framing. Implemented as the legacy handshake era
35
+ (2025-06-18): every current mainstream client probes `server/discover` then
36
+ falls back to `initialize`, so it is reachable everywhere; the 2026-07-28
37
+ stateless era is a follow-up. Publish gate now hard-fails when the tarball
38
+ omits `dist/mcp/*` (the local-works / packaged-missing class of bug).
39
+ `docs/mcp.md` documents the tool contracts, three client configs and the
40
+ read-only/offline guarantees. 15 MCP tests (protocol + tools + e2e).
41
+
42
+ Nothing yet.
43
+
44
+ ## [0.6.1] - 2026-11-17
45
+
46
+ ### Added
47
+
48
+ - Performance baseline in README (measured on synthetic repos, dist form):
49
+ 100 files/200 call sites in 0.75s, 500/1000 in 0.84s, 2000/4000 in 1.99s —
50
+ marginal cost ≈0.65ms/file. Reproducible via `scripts/gen-synth-repo.ts`
51
+ (mixed TS/Py/Go generator mimicking the fixture call shapes).
52
+ - `docs/maintenance.md`: ten-minute takeover checklist, the eight-step
53
+ release procedure, an index of every real pitfall hit during development,
54
+ an architecture map, backlog and handover notes. The project is declared
55
+ in **maintenance mode** at v0.6.0: bug and security fixes only, new
56
+ features require real user demand.
57
+
58
+ ### Fixed
59
+
60
+ - `changeguard --version` reports the real package version. It had been
61
+ hard-coded as `0.1.0` for five releases (0.2.0–0.6.0 all claimed 0.1.0),
62
+ caught by installing the 0.6.0 tarball into a clean prefix. The version now
63
+ resolves from package.json (from src/ and dist/ alike), with a regression
64
+ test that runs the CLI and compares against package.json.
65
+
66
+ ## [0.6.0] - 2026-11-16
67
+
68
+ ### Added
69
+
70
+ - Audit-log retention: `purgeAuditLogs(retentionDays)` plus scheduler wiring
71
+ (`CHANGEGUARD_AUDIT_RETENTION_DAYS`, default 90, 0 disables). Runs once at
72
+ boot and every 24h, independently of scan scheduling. The data-policy page
73
+ now states 90-day rotation instead of "kept until deletion".
74
+ - Self-service tenant deletion: `DELETE /api/tenant` (owner session or the
75
+ local no-password mode; exact-tenant-name confirmation required; API keys
76
+ refused with 403) backed by a single-transaction `deleteTenantData` that
77
+ removes scans/reports, API keys, installations, audit rows, memberships,
78
+ settings and the tenant row, returning per-table counts. The console
79
+ Settings page gained a SEC-04 danger-zone panel. Verified end-to-end in
80
+ local mode; 6 new tests, 187 total.
81
+
82
+ ### Changed
83
+
84
+ - R3 parameter findings skip feature-kind changes. A feature note ("new
85
+ parameter available") is an update-log entry, not a risk signal; R9
86
+ already excluded feature changes for the same reason. Measured effect: the
87
+ 18 LOW findings in an online `--only-matched` view drop to zero (26
88
+ findings → 8; HIGH 3 / MEDIUM 5 / LOW 0). The offline baseline reading
89
+ 45 → 44 for the same release is the correct consequence of R9 aggregation
90
+ (a same-provider medium+low pair merged into one medium: 35+9+1 →
91
+ 35+9+0), not a regression — no test pins the total.
92
+ - Title fallback also rejects generic section headers (`Breaking changes`,
93
+ `Change type`, `Changelog`, `Release notes`, `What's changed` …) and keeps
94
+ scanning the entry body for a substantive line. Also documented: the
95
+ ingest layer caches **parsed** records for 6h, so parser changes require
96
+ clearing `.changeguard/cache` before re-verification (the first re-run
97
+ looked unchanged for exactly this reason).
98
+
99
+ ### Added
100
+
101
+ - `changeguard scan --only-matched`: keep only findings anchored to a
102
+ concrete file (call-site hits). Repo-level advisories (R9) and
103
+ dependency-level pins (R7) drop out of this view; filtering happens before
104
+ every count so summary and artifacts stay consistent. Verified online:
105
+ 26 findings → 19, all file-anchored, HIGH 3 → 1 (the two R7 pins correctly
106
+ excluded).
107
+
108
+ ### Fixed
109
+
110
+ - Release-note titles: entries headed by a version tag (`### v7.44.0`),
111
+ a date-style name (`2026-08-25`, `2026-09-30.endive`) or punctuation
112
+ (`### -`) now fall back to the first substantive body line, so reports no
113
+ longer show findings titled "v7.44.0". Meaningful headings stay untouched,
114
+ output is clamped to 140 chars, and slug/id generation follows the fixed
115
+ title. Verified against a live online scan: advisory titles now carry the
116
+ actual change text ("Make id, sessionId and sessionToken required…").
117
+
118
+ ### Changed
119
+
120
+ - R9 repo advisories are now aggregated per provider instead of one finding
121
+ per un-matched change. Measured on a real online scan: 59 findings → 8
122
+ (86% fewer), with the three genuinely matched HIGH findings no longer
123
+ buried under 45 per-change "may affect this repository" entries. Each
124
+ advisory keeps the information: un-matched count, kind breakdown
125
+ (breaking / deprecation / behavior), the three latest titles, and a
126
+ "+N more" tail. Severity logic is unchanged — a group containing any
127
+ un-matched breaking change stays `medium`, deprecation/behavior-only
128
+ groups are `low`. The representative change (newest breaking, else newest)
129
+ still drives the report's change detail.
130
+
131
+ ### Added
132
+
133
+ - `scripts/backup-to.ps1` + `docs/backup.md`: one-command bundle backup to
134
+ removable media (`-AutoUsb` finds the USB drive, creates the bundle,
135
+ copies, verifies with `git bundle verify`, keeps the newest 3) plus a
136
+ documented restore drill (clone from bundle → npm ci → test). The script
137
+ is pure ASCII on purpose — Windows PowerShell 5.1 parses BOM-less UTF-8
138
+ as ANSI and breaks the parser otherwise.
139
+ - `SECURITY.md` with a vulnerability disclosure process (3-day ack, 7-day
140
+ triage, 30/90-day fix windows), in/out of scope, and the fail-closed
141
+ design notes reviewers need. The privacy policy already cited it — now
142
+ the file exists.
143
+
144
+ ### Changed
145
+
146
+ - CI now enforces the linters that were configured but never wired up: every
147
+ push and PR runs `npm run lint` (ESLint flat config) and
148
+ `npm run format:check`. `npm run check:fast` (typecheck + lint +
149
+ format:check) and `npm run check` (+ tests) reproduce the same gate locally
150
+ before pushing.
151
+ - `format` and `format:check` now pass an explicit path (`.`). Prettier 3
152
+ rejects a path-less invocation (`No parser and no file path given`), so the
153
+ check had been failing on its own arguments instead of validating the repo.
154
+ - `.prettierignore` also covers `.changeguard/`, `coverage/` and `backups/`:
155
+ runtime artifacts and generated reports are not repository sources, and
156
+ scanning them would make the check depend on whatever was last generated.
157
+
158
+ ### Fixed
159
+
160
+ - Prettier violations in `docker-compose.yml`, `docker-compose.multi.yml` and
161
+ `tests/node-sqlite-shim.mjs` (formatting only, no behavior change).
162
+
163
+ ## [0.5.0] - 2026-11-14
164
+
165
+ ### Added
166
+
167
+ - `docs/stripe-sandbox.md` — Stripe test-mode onboarding & verification
168
+ checklist (7 items, each mapped to the implementing code; notes that
169
+ `config.stripe.enabled` depends on the webhook secret alone).
170
+ - `docs/trial-playbook.md` — the 3–5 real-user trial script that turns the
171
+ CRL evidence gap into first-hand data: target personas, 30-minute script,
172
+ a 5-question feedback form (false-positive rate, novel findings,
173
+ forwarding intent, price anchor) and a mandatory feedback-log template.
174
+ - Legal pages: `/privacy`, `/terms`, `/data-policy` — public (whitelisted in
175
+ UNPROTECTED, served on a locked console), reachable from the login page and
176
+ the pricing footer. Content is grounded in the actual storage schema
177
+ (users/memberships/scans/reports/audit_log/api_keys + stateless HMAC
178
+ sessions): API keys stored hashed, report payloads carry code snippets,
179
+ LLM is disclosed as an optional third-party processor, self-service scan
180
+ deletion documented (`DELETE /api/scans/:id`), account/tenant deletion via
181
+ the contact mailbox in 30 days, plus an explicit "draft, not legal advice"
182
+ notice. A locked-console test proves whitelisting (legal pages 200 while
183
+ other paths 303-redirect). 6 new tests; 174 total.
184
+
185
+ ### Added
186
+
187
+ - `npm run feed:refresh` — seed refresh tool (`scripts/refresh-seeds.ts`).
188
+ Pulls release notes for every provider SDK repo (default since
189
+ 2025-01-01), filters to actionable kinds (breaking / deprecation /
190
+ behavior), deduplicates cross-language SDK duplicates (version banner
191
+ normalized), and separates records that carry **match anchors**
192
+ (non-empty `operations[].sdkPaths` or `renames`) from metadata-only
193
+ records. `--apply` appends only anchored, id-new records to
194
+ `data/changes/<provider>.seed.json`; anchors are never guessed — records
195
+ without one are reported for manual API-surface annotation. Dry run by
196
+ default. Observed on 2026-11-14: 87 actionable records -> ~80 unique,
197
+ only a handful anchored (note-parser extracts sdkPaths from explicit
198
+ field-level release text); the rest need human annotation. Anonymous
199
+ GitHub API allows 60 requests/hour — set `GITHUB_TOKEN` for a full run.
200
+
201
+ ### Added
202
+
203
+ - Structured logging. `CHANGEGUARD_LOG_FORMAT=json` switches the logger to
204
+ one JSON object per line (`t`, `level`, `msg`); the human format stays the
205
+ default. Every HTTP request runs inside an AsyncLocalStorage context, so
206
+ all 47 existing logger call sites automatically carry `requestId` (plus
207
+ `tenantId`/`actor` once auth resolves, and `method`/`path`) with zero
208
+ signature changes — async continuations and scans enqueued from a request
209
+ keep the context. The server mints a UUID per request (or honors an
210
+ inbound `X-Request-Id` from a proxy) and echoes it in the `X-Request-Id`
211
+ response header. JSON mode also emits one access line per request
212
+ (`access GET /path 200`), skipping `/healthz`, `/favicon.ico` and
213
+ `/metrics`. 8 new tests; 168 total.
214
+
215
+ ### Added
216
+
217
+ - Data-driven provider registry. Each vendor is now a JSON manifest in
218
+ `data/providers/<id>.json` (file stem must equal the id), loaded and
219
+ strictly validated at startup by `loadProviderManifests()` /
220
+ `validateProviderManifest()`. Adding a vendor is a data change with zero
221
+ code edits: package/host matching, three-language analyzer rules and
222
+ online change sources all derive from the manifest. Validation is
223
+ fail-fast and names the offending file and field (unknown
224
+ ecosystem/language, malformed `githubReleases`, stem/id mismatch, invalid
225
+ JSON, empty directory). `providerForPackage` / `providerForHost` /
226
+ `buildAnalyzerIndex` accept an injectable provider list for tests and
227
+ custom deployments. The five built-ins migrate to manifests with behavior
228
+ unchanged (pinned by `tests/providers.test.ts`, 16 new cases).
229
+
230
+ ## [0.4.0] - 2026-11-13
231
+
232
+ ### Fixed
233
+
234
+ - `GET /favicon.ico` now answers 204 instead of 404, keeping the browser
235
+ console clean (the real favicon lives with the out-of-repo marketing site).
236
+ - The login terminal header shows the server version from package.json
237
+ (it was hard-coded as v0.2 and already stale).
238
+
239
+ ### Changed
240
+
241
+ - Design docs reality check: the blueprint (`docs/design-plan.md`) drifted
242
+ behind the code after P2 — the server-rendered pages (dashboard / pricing /
243
+ auth) moved from the phosphor-green v1 tokens to the purple Sonar tokens,
244
+ and the pricing page had already been unified into the v2 language (SEC
245
+ section numbering, intercept-log style tier rows, STANDING BY stamp). The
246
+ blueprint now carries a §8 evolution record marking the drift, and P5's
247
+ "inline monospace font" is resolved as **won't do** (system monospace stack
248
+ is sufficient; a base64 woff2 would break the single-file report budget).
249
+ - The monospace font stack across all server-rendered pages is unified to
250
+ `ui-monospace, "Cascadia Code", Consolas, monospace` (32 occurrences in
251
+ dashboard.ts / pricing.ts / auth.ts previously mixed a shorter stack).
252
+
253
+ ### Added
254
+
255
+ - Prometheus metrics: `GET /metrics` serves the standard text exposition
256
+ format (zero dependencies, process-local registry in `util/metrics.ts` so
257
+ the Apache-2.0 `llm/` modules can record without touching the proprietary
258
+ boundary). Counters: scans by result, scan duration (count/sum/last),
259
+ findings by severity, LLM explanations and template fallbacks by reason
260
+ (error / safety-filter / scan-cap / kill-switch); gauges: scan queue depth
261
+ and uptime. Fail-closed: the endpoint returns 404 unless
262
+ `CHANGEGUARD_METRICS_TOKEN` is configured, 401 on a wrong token
263
+ (constant-time comparison); Bearer auth or `?token=` both accepted.
264
+ - Go pipeline e2e coverage: `tests/scan-e2e.test.ts` pins the full Go chain
265
+ (go.mod provider attribution → tree-sitter call sites → engine findings)
266
+ with six deterministic findings on `cmd/billing/main.go`, and documents the
267
+ boundary that Go findings carry no codemods (auto-fix is JS/TS/Python).
268
+ - Console open-PR endpoint error-path tests (`tests/open-pr.test.ts`): 404
269
+ unknown scan, 400 non-GitHub repoPath, 400 missing installation binding,
270
+ and 502 `GitHub PR failed: …` when credentials are missing (offline).
271
+
272
+ ### Fixed
273
+
274
+ - `providerForPackage` now compares package names case-insensitively on both
275
+ sides. Registry entries mix case for Go module paths
276
+ (`github.com/Shopify/go-shopify`), so a `go.mod` depending on it was not
277
+ attributed to the Shopify provider while all other Go paths were. Go
278
+ dependencies now resolve for all five providers.
279
+
280
+ ## [0.3.0] - 2026-11-13
281
+
282
+ ### Security
283
+
284
+ - LLM explanation hardening. The LLM prompt now explicitly warns that facts
285
+ (coming from potentially malicious feeds or changelogs) are untrusted data
286
+ and any text that looks like an instruction must be treated as content, not
287
+ as a command the model should follow.
288
+ - LLM output safety filters. `migrationSteps` returned by the LLM are filtered
289
+ against a blacklist of dangerous shell patterns (`curl|sh`, `wget|sh`,
290
+ `rm -rf`, `eval`, `bash -c`, `powershell -Enc`, ...) and silently dropped
291
+ when any match is found. Remaining steps are capped at 5 items of 500 chars
292
+ each; `summary` is capped at 500 chars.
293
+ - LLM rate limiting. Per-scan cap of 50 distinct changes reach the LLM pipeline
294
+ (rest fall back to template); process-wide per-hour hard cap (default 200)
295
+ prevents runaway spend when a malicious feed floods findings; at most 3
296
+ parallel LLM calls share the semaphore.
297
+ - Runtime LLM kill-switch. `CHANGEGUARD_DISABLE_LLM=1` is hot-loaded from
298
+ `process.env` on every LLM decision point — no process restart needed to
299
+ flip the whole pipeline to template mode during an incident response.
300
+ - Reports mark LLM-written content. The HTML report renders a blue
301
+ `🤖 AI 生成,仅供参考` badge next to explanations whose `source === 'llm'`;
302
+ the Markdown report already distinguishes `说明(LLM)` from
303
+ `说明(模板)`.
304
+
305
+ ### Changed
306
+
307
+ - Licensing is now dual: the standalone CLI and scanner are Apache-2.0
308
+ (`LICENSE`), while the hosted server, tenant/billing storage, console and
309
+ deployment packaging remain proprietary (`LICENSE-PROPRIETARY`, which also
310
+ defines the path-level boundary and the rules for mixed directories).
311
+ `package.json` declares `"license": "Apache-2.0"`.
312
+ - The CLI is split at the license boundary: `serve`, `tenant`, `key`, `plan`,
313
+ `audit` and `bind-installation` moved to the proprietary `src/cli-admin.ts`.
314
+ `src/cli.ts` now contains no import of `src/server/**` or `src/store/**` and
315
+ registers unavailable stubs with the same command names when the extension
316
+ is absent (Apache-2.0-only distribution). Command names, arguments, output
317
+ and exit codes are unchanged when the extension is present.
318
+ - The npm package is constrained by a `files` allowlist in `package.json`: it
319
+ ships only the Apache-2.0 portion, so `dist/server/**`, `dist/store/**`,
320
+ `dist/cli-admin.*` and the Docker files never enter the tarball.
321
+
322
+ ### Added
323
+
324
+ - Signed change feeds (feed v1): an ed25519-signed JSON envelope
325
+ (`{feedVersion, publisher, generatedAt, records, signature}`) verified with
326
+ Node's built-in `crypto` (no new dependencies). Signatures cover the
327
+ canonical JSON of everything except `signature`, so later publishers can add
328
+ fields without breaking older clients. `scan`, `pr-preview` and `pr-open`
329
+ accept `--feed <path|url>` and `--trusted-keys <file>`; verification is
330
+ fail-closed (missing signature, unknown `kid`, retired key, tampered payload
331
+ all reject the feed). See `docs/feed.md`.
332
+ - Two-layer feed trust: long-lived root keys built into the package
333
+ (`BUILTIN_ROOT_KEYS`, several allowed for root rotation) sign a keyring
334
+ (`{keyringVersion, generatedAt?, keys[], signature}`), and only after that
335
+ root signature verifies are the signing keys listed in the keyring
336
+ (`kid`, public key, optional `notBefore` / `retiresAt`) trusted for feeds.
337
+ Signing-key rotation therefore only re-signs a keyring — already-installed
338
+ CLIs accept it without a release; root rotation ships a CLI release that
339
+ trusts both roots during the overlap. Keyrings may be fetched over
340
+ `http(s)` because the root signature is checked locally.
341
+ `CHANGEGUARD_FEED_KEYS` / `CHANGEGUARD_FEED_ROOT_KEYS` select a keyring and
342
+ extra roots by environment. `BUILTIN_ROOT_KEYS` and `BUILTIN_FEED_KEYRING`
343
+ now carry bootstrap keys (root public key + signed keyring generated
344
+ 2026-11-13, private keys stay outside the repository); re-run the key
345
+ ceremony in an isolated environment and rotate before serving external
346
+ users (see `docs/feed.md` for the checklist).
347
+ - Strict feed mode: `CHANGEGUARD_FEED_STRICT=1` turns any verification failure
348
+ (including keyring rejections) into a non-zero exit with no fallback; the
349
+ default stays "error + warn + fall back to the bundled snapshot, exit 0".
350
+ CI pipelines must enable it, otherwise a failure silently degrades to stale
351
+ data.
352
+ - New rejection reasons: `keyring-malformed`, `keyring-unsigned`,
353
+ `keyring-unknown-root`, `keyring-bad-signature`, and `not-yet-valid` for
354
+ keys before their `notBefore` (retirement keeps using `retired-key`;
355
+ `keyring` covers unreadable root files and a missing keyring).
356
+ - `scripts/feed-keyring.ts` (npm `feed:keyring`) signs a keyring with a root
357
+ key and self-checks it against the root public key.
358
+ - `scripts/feed-keygen.ts` generates an ed25519 key pair into a git-ignored
359
+ `.keys/` directory (private key mode 0600; refuses paths inside the
360
+ repository that git does not ignore). `scripts/feed-sign.ts` signs the
361
+ bundled snapshot or an explicit `--records` file. npm scripts
362
+ `feed:keygen` / `feed:sign` wrap both.
363
+ - `tests/feed.test.ts` covers canonical serialization stability, sign→verify,
364
+ tampered payload, missing signature, unknown `kid`, unsupported version,
365
+ keyring root-signature acceptance/rejection (tampered bytes, unknown root,
366
+ unsigned, unsupported version), signing-key rotation with `notBefore` /
367
+ `retiresAt`, and keyring `kid`/key mismatch.
368
+ - `tests/cli-admin.test.ts` pinning the proprietary admin command surface
369
+ (tenant / key / audit subcommands).
370
+ - `tests/license-boundary.test.ts` guards the Apache-2.0 boundary: no
371
+ `server`/`store` imports in `src/cli.ts` (comments excluded) and no
372
+ proprietary path can match the `files` allowlist in `package.json`. It also
373
+ asserts the CLI resources (dist, `data/`, `fixtures/`, both license files)
374
+ are still shipped. The check is static, so it needs no network.
375
+
376
+ ### Fixed
377
+
378
+ - The CLI now exits 1 cleanly instead of crashing with 0xC0000409 on Windows
379
+ with Node >= 24 when a command fails while tree-sitter WASM / SQLite handles
380
+ are still closing: the synchronous `process.exit(1)` in the top-level catch
381
+ tripped a libuv assertion (`src/win/async.c`). Affected paths include
382
+ `CHANGEGUARD_FEED_STRICT=1` rejecting a feed. The failure exit is now
383
+ `process.exitCode` plus a natural drain, with a bounded unref'd timer as
384
+ fallback.
385
+ - Scans no longer warn `failed to persist scan … Cannot find module` in the
386
+ Apache-2.0-only build. A missing `store/sqlite` module is treated as
387
+ "persistence not available" and skipped silently; real write failures are
388
+ still reported.
389
+
390
+ ## [0.2.0] - 2026-11-07
391
+
392
+ ### Changed
393
+
394
+ - **Security: fail-closed defaults.** The console and JSON API now require
395
+ authentication by default; when neither `CHANGEGUARD_CONSOLE_PASSWORD` nor
396
+ GitHub OAuth is configured the console returns 503 with setup instructions
397
+ instead of serving the implicit local tenant. Local development opts out
398
+ explicitly with `CHANGEGUARD_ALLOW_ANONYMOUS_CONSOLE=1`.
399
+ - `POST /webhook` now rejects payloads that cannot be verified when
400
+ `GITHUB_WEBHOOK_SECRET` is unset (previously accepted). Dev opt-in:
401
+ `CHANGEGUARD_ALLOW_UNSIGNED_WEBHOOK=1`.
402
+ - Session cookies no longer fall back to a hard-coded secret. An unset
403
+ `CHANGEGUARD_SESSION_SECRET` generates a random per-process secret, so
404
+ sessions end on restart; set the variable in production.
405
+
406
+ ### Added
407
+
408
+ - Login rate limiting: 10 attempts per client IP per 15 minutes, then 429 with
409
+ `Retry-After`.
410
+ - `Secure` session cookies when the request arrives over TLS (or via a trusted
411
+ proxy's `X-Forwarded-Proto`), plus `CHANGEGUARD_SECURE_COOKIES` to force it.
412
+ - Baseline security response headers: CSP, `X-Content-Type-Options`,
413
+ `X-Frame-Options`, `Referrer-Policy`, `Permissions-Policy`, and HSTS over TLS.
414
+ - `CHANGEGUARD_TRUST_PROXY` for reverse-proxy deployments (per-client rate
415
+ limiting and `Secure` cookies).
416
+ - `tests/security.test.ts` covering fail-closed defaults, signature
417
+ verification, session secret, rate limiting and cookie attributes.
418
+
419
+ ## [0.1.0] - 2026-11-07
420
+
421
+ First tagged baseline. Everything below is the state of the repository at this tag.
422
+
423
+ ### Added
424
+
425
+ - Deterministic scanning engine: 9 rules (R1-R9) over 5 providers (Stripe, OpenAI,
426
+ Shopify, Twilio, Supabase) across JavaScript/TypeScript, Python and Go.
427
+ - Tree-sitter (WASM) based parsing with zero native build dependencies.
428
+ - Artifacts per scan: `report.json`, `report.md`, `report.html`, `pr-body.md`,
429
+ `codemod.patch`.
430
+ - CLI: `scan`, `demo`, `serve`, `pr-open <owner/repo>`, `github pr`.
431
+ - Multi-tenant control plane: tenants, hashed API keys, HMAC session cookies,
432
+ GitHub OAuth SSO, Stripe Checkout and webhook plan sync, quota gating (HTTP 402),
433
+ audit log, usage export (CSV/JSON), `/pricing` page.
434
+ - Plan limits: free (2 repos / 10 scans), pro (25 repos / 500 scans), team
435
+ (100 repos / 5000 scans).
436
+ - Notification channels: GitHub Issue (deduplicated by findings hash), draft
437
+ pull request, Slack webhook, SMTP email.
438
+ - GitHub App webhook receiver (`installation`, `installation_repositories`, `push`) with
439
+ HMAC-SHA256 signature verification.
440
+ - Scheduler for periodic re-scans, plus a bounded task queue.
441
+ - Console: scan history with per-scan Issue / PR links, repo management, API key
442
+ management, and the two HTML manuals with full-text search.
443
+ - Docker support: `Dockerfile` (node:22-bookworm-slim) and single- / multi-instance
444
+ `docker-compose` files.
445
+
446
+ ### Known gaps
447
+
448
+ - No signed change feed: seeds are hand-maintained and untrusted-by-default.
449
+ - SQLite is single-writer, so the multi-instance compose file is only safe with
450
+ the app-ro replica read-only.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.