circagraph
Sign inSign up

openchronology/timeline-app on GitHub

The OpenChronology repository on GitHub, mirrored by och-import-github: issues and pull requests as durations (ongoing while open), what happened to them as moments, plus releases, milestones, commits and branches. The Branches view shows the most recently active branches each in a track of its own.

Source: https://github.com/openchronology/timeline-app

3,131 moments · 2026-10-05 CE 20:21:49 UTC – 2026-11-16 CE 12:10:45 UTC · by @athan · @athan

#157 Plugins validate their own metadata; the server compiles scripts only in a sandbox

–

  • github
  • github/openchronology/timeline-app
  • github/openchronology/timeline-app#157
  • issue
  • state:closed

## Rule - **No running plugins on the server.** The server never runs plugin code. - **Compiling:** it may compile plugin scripts, to refuse ones that don't compile, in the safest way possible, preferably sandboxed. - **Validating metadata:** validating the metadata plugins use is each plugin's own job. Every plugin decides how it reads and handles its metadata, including malformed or unexpected values. - The server doesn't validate metadata on plugins' behalf. - Neither does any central validator in the browser's core. - **What the server does check:** it stores what it's given within its generic limits (valid JSON, sizes, IDs, times). ## What the server does with plugins today It never executes a plugin's script: the functions that run them (`scriptEffects` in `src/plugins.ts`, behind `pluginColor`, `pluginShape`, `pluginHeading` and the rest) are only used by the browser bundle. It does: 1. **Compile plugin scripts.** `validatePluginManifest` calls `compilePluginScript(source)` (`src/custom-time.ts`). That parses the script into a syntax tree for the plugin language's own interpreter; nothing is evaluated as JavaScript. It happens: - on publish (`server/plugins.mjs`); - when the catalogue is read; - through `validateInstalledPlugins`, for every installed plugin, in every server-side `validateDocument`: whole-document saves, creates, merges and rebuilt revisions; - on comparison query plugins (`server/query-plugins.mjs`). It runs in the request's own thread, on scripts of up to 16 KiB. 2. **Validate moment metadata for plugins.** `validateDocument` calls `validateStackMetadata(metadata, plugins)` for every moment (`src/core.ts`). The installed plugins decide which metadata keys are "stack" fields, and core code checks their entries' shape and that stacks aren't nested. This is validation on plugins' behalf, done centrally, on both server and browser. 3. **Rebuild the index on plugin changes.** Because of point 2, a save that changes the installed plugins can't be applied in place (`incremental` in `server/incremental.mjs`): every moment has to be revalidated through the whole-document rebuild. That's one of the whole-timeline operations #135 wants gone. 4. **Project view payloads by plugin.** `pluginMetadata(plugins, metadata)` (`overviewMetadata` in `server/store.mjs`) picks which metadata fields go into viewport results, from the manifests' declared keys. That runs at query time and stores nothing. It selects fields and runs no plugin code. ## Proposal **Compiling stays, sandboxed.** - Compile plugin scripts in a worker thread (`node:worker_threads`), with resource limits on heap and stack (`resourceLimits`) and a time limit (terminate the worker past it). - The worker gets the source and returns only whether it compiles, with the error. It's given nothing else: no database, no request, no secrets. - Compile once per distinct source: cache by hash, and reuse a small pool of workers. - For installed plugins in a saved document, skip compiling when the manifest is unchanged from the timeline's current one, or matches a published catalogue version already compiled. Saves then don't compile at all in the common case. - The browser compiles too, before running a script, as it does now. **Metadata validation leaves the core and goes to each plugin.** - Remove `validateStackMetadata` from `validateDocument`, on the server and in the browser's core. - Each plugin, including the built-in field kinds it declares (stack, links, color, icon and so on), reads its metadata leniently. Values of the wrong shape are ignored, or shown as unusable, as that plugin decides; they never throw. Where a plugin offers an editor for its fields, it validates what its editor writes. - **Stack entries:** the stack field's own handling decides how to treat a non-array, an entry without an ID, or a nested stack. - **Server code that reads metadata** must accept whatever shape it finds: the catalogue text (`oc_event_text`, `even……

Related

Open #157 Plugins validate their own metadata; the server compiles scripts only in a sandbox in the timeline

#157 Plugins validate their own metadata; the server…