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

- 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>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-22 22:05:42 -05:00
1 parent f5a4333a8e
commit 040ad028c0
10 files changed
+453 -20

No files matched your search

+11 -7
View File
@@ -8,10 +8,10 @@ const path = require('path');
const fs = require('fs');
const helmet = require('helmet');
require('dotenv').config();
const { validateWebhookUrl, applyParams, evalCondition, calculateNextRun } = require('./lib/utils');
const { validateWebhookUrl, applyParams, evalCondition, conditionErrors, calculateNextRun } = require('./lib/utils');
const { PAGES } = require('./lib/nav');
const { renderPage, renderError } = require('./lib/render');
const { upsertUser, makeAuthenticatePage, ssoIdentity, trustedProxies } = require('./lib/pageauth');
const { upsertUser, makeAuthenticatePage, ssoIdentity, trustedProxies, ALLOWED_GROUPS } = require('./lib/pageauth');
const { safeEqual, checkWorkerKey, workerAuthEnforced, classifyUpgrade, allowWorkerConnect } = require('./lib/wsauth');
const app = express();
@@ -869,14 +869,13 @@ async function authenticateSSO(req, res, next) {
const { username: remoteUser, name: remoteName, email: remoteEmail, groups } = identity;
// Check if user is in allowed groups (admin or employee)
const allowedGroups = ['admin', 'employee'];
const hasAccess = groups.some(g => allowedGroups.includes(g));
// Only the groups in ALLOWED_GROUPS (lib/pageauth.js): admins.
const hasAccess = groups.some(g => ALLOWED_GROUPS.includes(g));
if (!hasAccess) {
return res.status(403).json({
return res.status(403).json({
error: 'Access denied',
message: 'You must be in admin or employee group'
message: 'Pulse is limited to the admin group'
});
}
@@ -1426,8 +1425,11 @@ app.get('/api/workflows/:id', authenticateSSO, async (req, res) => {
app.post('/api/workflows', authenticateSSO, requireJSON, async (req, res) => {
try {
if (!req.user.isAdmin) return res.status(403).json({ error: 'Admin only' });
const { name, description, definition, webhook_url } = req.body;
if (!name || !definition) return res.status(400).json({ error: 'name and definition are required' });
const badConditions = conditionErrors(definition);
if (badConditions.length) return res.status(400).json({ error: 'Invalid condition', problems: badConditions });
const webhookCheck = validateWebhookUrl(webhook_url);
if (!webhookCheck.ok) return res.status(400).json({ error: webhookCheck.reason });
@@ -1750,6 +1752,8 @@ app.put('/api/workflows/:id', authenticateSSO, requireJSON, async (req, res) =>
} catch {
return res.status(400).json({ error: 'Invalid JSON in definition' });
}
const badConditions = conditionErrors(defObj);
if (badConditions.length) return res.status(400).json({ error: 'Invalid condition', problems: badConditions });
const [result] = await pool.query(
'UPDATE workflows SET name=?, description=?, definition=?, webhook_url=?, updated_at=NOW() WHERE id=?',