Commit Graph
1905 Commits
Author SHA1 Message Date
Linus Rath 79f73c5c84 fix: keep the errors endpoint out of the Bulwark Lite bundle 2026-11-01 04:35:04 +01:00
Linus Rath aa88e1b279 Merge branch 'main' into feat/observability 2026-11-01 04:21:12 +01:00
Linus Rath b92717921e fix: upload each source map with the chunk that names it when the build path is relative 2026-11-01 03:57:47 +01:00
Linus Rath 83a19f3329 docs: point code comments at the monitoring guide where the website has it 2026-11-01 03:49:54 +01:00
Linus Rath e02389b079 test: drop type directives the source map script test doesn't need 2026-11-01 03:49:54 +01:00
Linus Rath 75cb0f62fe fix: measure and trace the sign-in check's calls to Stalwart 2026-11-01 03:49:53 +01:00
Linus Rath 77d4114d4a fix: remove unquoted free text such as folder names from error report messages 2026-11-01 03:49:53 +01:00
Linus Rath be5a5e88ec ci: upload browser source maps to Bugsink and keep every map out of what ships
Every image, the standalone tarballs and the Lite zips are built with
source maps (`BULWARK_SOURCE_MAPS=1`). Turbopack builds give each chunk
a debug ID themselves; the webpack build in the Docker image gets them
from `sentry-cli sourcemaps inject`. `scripts/sourcemaps.mjs collect`
then moves every map out of the build before anything is packed, and
`scripts/sourcemaps.mjs check` fails the build when a `.map` file, an
inline map or a `sourceMappingURL` to a missing file would ship.

- Docker images: a `sourcemaps` stage holds only the maps; the amd64
  job exports it (a cache hit) and uploads it, since both platforms
  build identical chunks
- standalone tarballs, the Lite zips and the Lite image upload their
  own maps and check what they ship
- `scripts/upload-sourcemaps.sh` uploads to `bulwark-instances` and
  `bulwark-telemetry` (Bugsink keeps maps per project) and skips with a
  notice when the `BUGSINK_AUTH_TOKEN` secret is missing
2026-11-01 03:31:48 +01:00
Linus Rath d49839435b feat: send OpenTelemetry traces when an OTLP endpoint is configured
With `OTEL_EXPORTER_OTLP_ENDPOINT` or
`OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` set (and neither
`OTEL_SDK_DISABLED=true` nor `OTEL_TRACES_EXPORTER=none`), Bulwark
loads the OpenTelemetry SDK at startup and exports Next's own spans
plus a client span for every call to Stalwart, WOPI, translation, the
plugin proxy and OAuth over OTLP/HTTP. Calls to Stalwart carry a
`traceparent` header, so Stalwart's spans join the trace. All other
settings come from the standard `OTEL_*` variables.

Every span is scrubbed before export: URLs keep their origin only,
request paths become their route group, query strings, user agents and
client addresses are dropped, and addresses or credentials in other
attributes are removed. Without an endpoint the SDK is never loaded.
The endpoint is listed under the hosts that stay reachable with no
third-party traffic, and System > Monitoring shows whether tracing runs.
2026-11-01 03:25:28 +01:00
Linus Rath 7cb0c5f972 chore: use @prometheus-io/client, the maintained successor of the deprecated prom-client 2026-11-01 03:20:52 +01:00
Linus Rath e580ed24da feat: send anonymous error counts with the usage stats when the admin also agrees to it
A second switch under System > Usage stats, "Also send anonymous error
counts", or `BULWARK_TELEMETRY_ERRORS=on|off`. Off by default, off
whenever the heartbeat is off or no third-party traffic is on, and
switching the heartbeat off switches it off too. With it on the
heartbeat becomes schema 2: the v1 fields unchanged plus `errors`, up to
50 fingerprints of the last complete UTC day with the error name, the
top frames in Bulwark's bundles (path, line, column, debug ID), the
version, a bucketed count, on how many of the last 7 days it occurred,
and a message only when it is a fixed error code. Without the consent
the heartbeat stays exactly schema 1. The admin preview shows the v2
payload as soon as the switch is flipped.
2026-11-01 03:10:41 +01:00
Linus Rath 481c4b6030 feat: serve Prometheus metrics and split health into live and ready
- `/api/metrics` in Prometheus text format, off until `METRICS_TOKEN`
  or `METRICS_TOKEN_FILE` is set (404 before, 401 without the bearer
  token): requests per route group with status class and latency,
  sign-in outcomes, calls to Stalwart, WOPI, translation, the plugin
  proxy and OAuth, browser errors, errors today, process memory,
  event-loop lag, uptime and build info. Labels come from fixed lists.
  Each replica serves its own.
- `/api/health/live` answers while the process runs;
  `/api/health/ready` checks the config, the shared store, writable
  data dirs and Stalwart's session resource. `/api/health` and
  `/api/ready` are unchanged.
- the Docker image gets a HEALTHCHECK on the live endpoint
- adds prom-client, and the OpenTelemetry packages the tracing step
  loads on demand
2026-11-01 02:59:40 +01:00
Linus Rath b91a8f54aa Merge branch 'feat/kubernetes-manifests' 2026-11-01 02:55:57 +01:00
Linus Rath cba1109444 feat: report browser and server errors to an error tracker the admin sets
Admins had logs and nothing else: client errors only reached the
browser console. An admin can now set a Sentry-protocol address (DSN)
for Bugsink, GlitchTip or Sentry under System > Monitoring, or with
`ERROR_REPORTING_DSN`, `ERROR_REPORTING_DSN_FILE`,
`ERROR_REPORTING_SAMPLE_RATE` and `ERROR_REPORTING_ENVIRONMENT`.
Bulwark Lite reads the same from `errorReporting` in policy.json.
Everything stays off while no address is set.

- browsers report errors from the error boundaries, window.onerror,
  unhandled rejections and failed JMAP requests (method and error type
  only), with route and JMAP method breadcrumbs and the chunks' debug IDs
- the server reports what Next hands to onRequestError and what routes
  log with logger.error
- every report is scrubbed first: quoted text, addresses, URLs, file
  names, tokens and the rest after the first line are removed, and the
  server scrubs what browsers post to /api/errors again
- reports are deduplicated and rate-limited per session and process
- errors are counted per day for "errors today" on the admin page
- startup messages and audit entries go through the logger, so
  `LOG_FORMAT=json` covers them
2026-11-01 02:50:19 +01:00
Linus Rath d2a83a4ee9 fix: stop proxying locale rewrites back to the server when it listens on 127.0.0.1 #1487 2026-11-01 02:41:42 +01:00
Linus Rath 692f965f20 fix: start with ADMIN_PASSWORD when the admin config is mounted read-only #1066 2026-11-01 02:40:25 +01:00
Linus Rath d781e8762e Merge branch 'feat/multi-instance' 2026-11-01 01:43:15 +01:00
Linus Rath eb56ea441f fix: list the User-Agent contact link as a non-request host 2026-11-01 01:22:17 +01:00
Linus Rath acf125a52b test: fail when server state skips the shared store without a listed reason #1066 2026-11-01 01:12:49 +01:00
Linus Rath 3a9aef7c50 feat: move plugins, themes, branding and the signing key with the shared-store import and export #1066 2026-11-01 01:08:34 +01:00
Linus Rath 70a7e1227c fix: drop files of removed plugins on export and read only the approval files on import #1066 2026-11-01 01:07:30 +01:00
Linus Rath ac29a94fc3 fix: cap the plugin packages kept for approval review and sweep broken kept-version folders #1066 2026-11-01 01:04:51 +01:00
Linus Rath dcecd50b7f fix: keep up to 256 rendered branding images per kind, enough for many domains #1066 2026-11-01 01:03:33 +01:00
Linus Rath 38bc06f2d3 fix: answer 503 for plugin lists and marketplace installs while the shared store is down #1066
directory-keys-shared.test.ts: the store-down case now expects the store error instead of an 'invalid' signature, since a store outage no longer counts as a bad signature.
2026-11-01 01:03:13 +01:00
Linus Rath d78ce02f78 fix: refuse a plugin install that can't hold the registry lock and a bundle that doesn't match its entry #1066 2026-11-01 01:01:19 +01:00
Linus Rath 750f3114c1 fix: keep an old plugin's bundle hash when the shared store hiccups while it is fixed #1066 2026-11-01 00:58:33 +01:00
Linus Rath b39e3e27ac fix: cache a plugin signature only when it verifies for the cached bundle #1066 2026-11-01 00:57:21 +01:00
Linus Rath d9f4bdd9be fix: keep serving a plugin unsigned when its first signature can't be stored 2026-11-01 00:55:51 +01:00
Linus Rath 256855b294 fix: refuse to sign plugins on an instance whose signing key differs from the others #1066 2026-11-01 00:54:57 +01:00
Linus Rath 00e28e5f83 Merge branch 'feat/multi-instance' into feat/multi-instance-ext 2026-11-01 00:52:04 +01:00
Linus Rath 23b50f8268 test: read the wrapped mkdir in the Dockerfile as one command 2026-11-01 00:47:30 +01:00
Linus Rath c0c1a8f0fb test: give the config route test the logger calls config-manager now makes 2026-11-01 00:46:42 +01:00
Linus Rath ecdd2b54fe chore: name the app Bulwark Webmail in exported files, outgoing requests and the manifest 2026-11-01 00:41:21 +01:00
Linus Rath 77a06a8aa0 fix: stop logging that the shared store is unreachable while its first connection is still being made 2026-11-01 00:39:01 +01:00
Linus Rath 26f0b72b2e feat: write plugins, themes, approvals and branding back to local files on export #1066 2026-11-01 00:30:41 +01:00
Linus Rath 355e57ca6c Merge branch 'feat/multi-instance' into feat/multi-instance-ext 2026-11-01 00:28:15 +01:00
Linus Rath ad7a8d713c feat: bring plugins, themes, approvals and branding along when moving to a shared store #1066 2026-11-01 00:27:17 +01:00
Linus Rath 3c34eda260 fix: cap the cache of Stalwart admin checks so it can't grow without bound 2026-11-01 00:25:35 +01:00
Linus Rath 5efccb65e0 fix: show a re-uploaded logo or icon at once instead of after a restart 2026-11-01 00:24:07 +01:00
Linus Rath a03f76ec85 feat: send X-Powered-By: bulwarkmail.org on every response 2026-11-01 00:21:32 +01:00
Linus Rath fc7d5617c2 feat: serve uploaded branding from the shared store on every instance #1066 2026-11-01 00:20:24 +01:00
Linus Rath 3ed25e1d95 feat: import an existing install into the shared store on first start and export it back with SHARED_STORE_EXPORT #1066 2026-11-01 00:17:20 +01:00
Linus Rath 51e7999e3c feat: sign plugin bundles with one key on every instance #1066 2026-11-01 00:16:42 +01:00
Linus Rath 2078b0a13f Merge branch 'feat/multi-instance-auth' into feat/multi-instance 2026-11-01 00:13:17 +01:00
Linus Rath 5e4b6465d1 Merge branch 'feat/multi-instance' into feat/multi-instance-ext 2026-11-01 00:13:14 +01:00
Linus Rath e3936287fd feat: share plugin approvals and plugin settings between instances #1066 2026-11-01 00:13:09 +01:00
Linus Rath e75834314d fix: show plugin approval requests and decisions to every part of the server at once 2026-11-01 00:13:08 +01:00
Linus Rath 2944d2797f fix: keep every key when several of a plugin's settings are saved at once 2026-11-01 00:12:26 +01:00
Linus Rath 89f337c0ae Merge branch 'feat/multi-instance-admin' into feat/multi-instance 2026-11-01 00:12:24 +01:00
Linus Rath 8127640acf fix: write an office editor sign-out made during a store outage as soon as the store is back #1066 2026-11-01 00:10:09 +01:00