Safer workflow conditions; Pulse is admin-only #60

Merged
jared merged 1 commits from safe-conditions into main 2026-11-22 22:16:13 -05:00
Owner

Workflow conditions

Workflow conditions (step.condition and route if) are now parsed and interpreted by a small evaluator, lib/condition.js, instead of Node's vm module.

  • What it supports: exactly what our workflows use:
    • state.* and params.* lookups;
    • parseInt, parseFloat, Number, String, Boolean;
    • the string methods trim, toLowerCase, toUpperCase, includes, startsWith, endsWith;
    • || && ! === !== == != < <= > >= + - * / % with JavaScript semantics, plus literals and parentheses.
  • What it can't do: read anything but the workflow's own data. Prototypes, globals and arbitrary calls are refused.
  • Compatibility: each of the 26 conditions in the production workflows gives the same result as before, checked against 150 random states per condition.
  • Validation on save: creating or updating a workflow with a condition that doesn't parse gets a 400 that names the step and the error.

Admins only

  • Only the admin group may use Pulse: the pages, the API and the live WebSocket. Employees now get 403.
  • Creating a workflow requires admin, as editing already did.
  • Gandalf and the workers use API keys and aren't affected.

Tests

  • Unit: 50 new evaluator tests (the production conditions, the language, refused inputs, size and nesting limits).
  • Integration:
    • employees are refused on pages and the API;
    • invalid conditions are rejected on create and update.
  • UI: the live-update test now finds its execution's row by id, because the list is capped at 50 rows.

Locally: jest 133/133, integration 39/39, Playwright passing; semgrep, lint and the dash check are clean.

🤖 Generated with Claude Code

## Workflow conditions Workflow conditions (`step.condition` and route `if`) are now parsed and interpreted by a small evaluator, `lib/condition.js`, instead of Node's `vm` module. - **What it supports:** exactly what our workflows use: - `state.*` and `params.*` lookups; - `parseInt`, `parseFloat`, `Number`, `String`, `Boolean`; - the string methods `trim`, `toLowerCase`, `toUpperCase`, `includes`, `startsWith`, `endsWith`; - `|| && ! === !== == != < <= > >= + - * / %` with JavaScript semantics, plus literals and parentheses. - **What it can't do:** read anything but the workflow's own data. Prototypes, globals and arbitrary calls are refused. - **Compatibility:** each of the 26 conditions in the production workflows gives the same result as before, checked against 150 random states per condition. - **Validation on save:** creating or updating a workflow with a condition that doesn't parse gets a 400 that names the step and the error. ## Admins only - Only the `admin` group may use Pulse: the pages, the API and the live WebSocket. Employees now get 403. - Creating a workflow requires admin, as editing already did. - Gandalf and the workers use API keys and aren't affected. ## Tests - Unit: 50 new evaluator tests (the production conditions, the language, refused inputs, size and nesting limits). - Integration: - employees are refused on pages and the API; - invalid conditions are rejected on create and update. - UI: the live-update test now finds its execution's row by id, because the list is capped at 50 rows. Locally: jest 133/133, integration 39/39, Playwright passing; semgrep, lint and the dash check are clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jared added 1 commit 2026-11-22 22:05:59 -05:00
Safer workflow conditions; Pulse is admin-only
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 25s
CI / Test (jest) (push) Successful in 25s
CI / Security (npm audit) (push) Successful in 21s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m0s
CI / Integration (api) (push) Successful in 2m23s
CI / Lint (eslint) (pull_request) Successful in 24s
CI / Test (jest) (pull_request) Successful in 32s
CI / Security (npm audit) (pull_request) Successful in 39s
CI / UI (playwright) (push) Successful in 2m6s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Skipped
CI / Integration (api) (pull_request) Successful in 2m13s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 2m46s
CI / UI screenshots (before/after) (pull_request) Successful in 27s
CI / UI (playwright) (pull_request) Successful in 3m5s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
040ad028c0
- Workflow conditions (step.condition and route `if`) are now parsed and
  interpreted by lib/condition.js instead of being run with Node's vm
  module. The language covers what workflows use: state/params lookups,
  parseInt/parseFloat/Number/String/Boolean, a few string methods, the
  usual operators with JavaScript semantics. Conditions can only read the
  workflow's own data. Every condition in the production workflows gives
  the same result as before (differential test, 150 random states each).
- Creating and updating a workflow rejects conditions that don't parse
  (400 with the step and the error).
- Creating a workflow requires admin, like editing already did.
- Only the admin group may use Pulse (pages, API and live WebSocket);
  employees get 403. Gandalf and workers use API keys and are unaffected.
- The live-update UI test finds its execution's row by id instead of
  counting rows (the list is capped at 50).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared merged commit e6dbb2869b into main 2026-11-22 22:16:13 -05:00
jared deleted branch safe-conditions 2026-11-22 22:16:17 -05:00
Sign in to join this conversation.