Files
windmill/backend/tests/fixtures/job_provenance_versions.sql
227e934210 feat: harden job OIDC tokens with version claims, jti and a lifetime cap (#11457)
* feat: harden job OIDC tokens with version claims, jti and a lifetime cap

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: count restarted flow nodes as latest only if the current version uses them

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: follow stored loop and branch bodies when resolving current flow nodes

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: bind current flow nodes to their step id and skip non-numeric node keys

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* refactor: derive flow step currency from the flow above it and restarts

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: treat every restarted job but a version-checked flow as not latest

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat: count a restarted body as latest when the run it came from was current

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* chore: update ee-repo-ref to b469efc9ceddfaaa1040e4cb2c18993822f92c78

This commit updates the EE repository reference after PR #838 was merged in windmill-ee-private.

Previous ee-repo-ref: 25e0b9ae1c6c60419a479fa38d5dc5928832790a

New ee-repo-ref: b469efc9ceddfaaa1040e4cb2c18993822f92c78

Automated by sync-ee-ref workflow.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
2026-10-01 14:09:36 +02:00

93 lines
7.8 KiB
SQL

-- Add-on fixture for job_provenance.rs (combine with `base.sql` and `job_provenance.sql`):
-- past versions of f/t/tool and f/t/agent, a deleted version of f/t/tool, and flow steps
-- of f/t/agent under a regular run and under restarts.
INSERT INTO script (workspace_id, hash, path, content, language, kind, created_by, schema, summary, description, lock, created_at, archived)
VALUES ('test-workspace', 1111111110, 'f/t/tool', 'echo old tool', 'bash', 'script', 'test-user', '{}', '', '', '', NOW() - interval '1 day', true);
INSERT INTO script (workspace_id, hash, path, content, language, kind, created_by, schema, summary, description, lock, created_at, archived, deleted)
VALUES ('test-workspace', 1111111109, 'f/t/tool', '', 'bash', 'script', 'test-user', '{}', '', '', '', NOW() - interval '2 days', true, true);
INSERT INTO flow_version (id, workspace_id, path, value, schema, created_by, created_at)
VALUES (2222222221, 'test-workspace', 'f/t/agent', '{"modules":[]}', '{}', 'test-user', NOW() - interval '1 day');
UPDATE flow SET versions = ARRAY[2222222221::bigint, 2222222222::bigint]
WHERE workspace_id = 'test-workspace' AND path = 'f/t/agent';
INSERT INTO v2_job (id, workspace_id, kind, runnable_path, runnable_id, parent_job, created_by, permissioned_as, permissioned_as_email)
VALUES
-- the past tool version, run under the current flow version
('3bb0c0de-0000-4000-8000-000000000101', 'test-workspace', 'script', 'f/t/tool', 1111111110, '3bb0c0de-0000-4000-8000-000000000001', 'test-user', 'u/test-user', 'test@windmill.dev'),
-- the current tool version, run under the past flow version
('3bb0c0de-0000-4000-8000-000000000102', 'test-workspace', 'flow', 'f/t/agent', 2222222221, NULL, 'test-user', 'u/test-user', 'test@windmill.dev'),
('3bb0c0de-0000-4000-8000-000000000103', 'test-workspace', 'script', 'f/t/tool', 1111111111, '3bb0c0de-0000-4000-8000-000000000102', 'test-user', 'u/test-user', 'test@windmill.dev'),
-- the deleted tool version
('3bb0c0de-0000-4000-8000-000000000104', 'test-workspace', 'script', 'f/t/tool', 1111111109, NULL, 'test-user', 'u/test-user', 'test@windmill.dev'),
-- under the current flow version: an inline step, a loop body and a step of that body
('3bb0c0de-0000-4000-8000-000000000105', 'test-workspace', 'flowscript', 'f/t/agent/a', 4444444442, '3bb0c0de-0000-4000-8000-000000000001', 'test-user', 'u/test-user', 'test@windmill.dev'),
('3bb0c0de-0000-4000-8000-000000000106', 'test-workspace', 'flownode', 'f/t/agent/loop-0', 4444444444, '3bb0c0de-0000-4000-8000-000000000001', 'test-user', 'u/test-user', 'test@windmill.dev'),
('3bb0c0de-0000-4000-8000-000000000107', 'test-workspace', 'flowscript', 'f/t/agent/loop-0/b', 4444444446, '3bb0c0de-0000-4000-8000-000000000106', 'test-user', 'u/test-user', 'test@windmill.dev'),
-- an inline step under the past flow version
('3bb0c0de-0000-4000-8000-000000000108', 'test-workspace', 'flowscript', 'f/t/agent/a', 4444444441, '3bb0c0de-0000-4000-8000-000000000102', 'test-user', 'u/test-user', 'test@windmill.dev'),
-- a loop body restarted on its own, and a step of it
('3bb0c0de-0000-4000-8000-000000000109', 'test-workspace', 'flownode', 'f/t/agent/loop-0', 4444444443, NULL, 'test-user', 'u/test-user', 'test@windmill.dev'),
('3bb0c0de-0000-4000-8000-000000000110', 'test-workspace', 'flowscript', 'f/t/agent/loop-0/b', 4444444449, '3bb0c0de-0000-4000-8000-000000000109', 'test-user', 'u/test-user', 'test@windmill.dev'),
-- a body kept by a nested restart under the current flow version, and a step of it
('3bb0c0de-0000-4000-8000-000000000111', 'test-workspace', 'flownode', 'f/t/agent/branchone-1', 4444444445, '3bb0c0de-0000-4000-8000-000000000001', 'test-user', 'u/test-user', 'test@windmill.dev'),
('3bb0c0de-0000-4000-8000-000000000112', 'test-workspace', 'flowscript', 'f/t/agent/branchone-1/c', 4444444447, '3bb0c0de-0000-4000-8000-000000000111', 'test-user', 'u/test-user', 'test@windmill.dev');
-- An inline body (a flow deployed before flow nodes runs it as a preview) kept by a nested
-- restart under the current flow version, and a step of it.
INSERT INTO v2_job (id, workspace_id, kind, runnable_path, parent_job, created_by, permissioned_as, permissioned_as_email)
VALUES
('3bb0c0de-0000-4000-8000-000000000113', 'test-workspace', 'flowpreview', 'f/t/agent/branchone-0', '3bb0c0de-0000-4000-8000-000000000001', 'test-user', 'u/test-user', 'test@windmill.dev'),
('3bb0c0de-0000-4000-8000-000000000114', 'test-workspace', 'preview', 'f/t/agent/branchone-0/c', '3bb0c0de-0000-4000-8000-000000000113', 'test-user', 'u/test-user', 'test@windmill.dev');
-- The restarted bodies: two still running, one completed.
INSERT INTO v2_job_queue (id, workspace_id, scheduled_for, running)
VALUES
('3bb0c0de-0000-4000-8000-000000000111', 'test-workspace', NOW(), true),
('3bb0c0de-0000-4000-8000-000000000113', 'test-workspace', NOW(), true);
INSERT INTO v2_job_status (id, flow_status)
VALUES
('3bb0c0de-0000-4000-8000-000000000111',
'{"restarted_from": {"flow_job_id": "3bb0c0de-0000-4000-8000-0000000000ff", "step_id": "br"}}'),
('3bb0c0de-0000-4000-8000-000000000113',
'{"restarted_from": {"flow_job_id": "3bb0c0de-0000-4000-8000-0000000000fd", "step_id": "br"}}');
INSERT INTO v2_job_completed (id, workspace_id, duration_ms, status, flow_status)
VALUES ('3bb0c0de-0000-4000-8000-000000000109', 'test-workspace', 0, 'success',
'{"restarted_from": {"flow_job_id": "3bb0c0de-0000-4000-8000-0000000000fe", "step_id": "l"}}');
-- Loop bodies restarted on their own from completed runs: one of the current flow version,
-- one of the past version, and one that was itself a restart; with a step of the first.
INSERT INTO v2_job (id, workspace_id, kind, runnable_path, runnable_id, parent_job, created_by, permissioned_as, permissioned_as_email)
VALUES
('3bb0c0de-0000-4000-8000-000000000115', 'test-workspace', 'flownode', 'f/t/agent/loop-0', 4444444444, '3bb0c0de-0000-4000-8000-000000000001', 'test-user', 'u/test-user', 'test@windmill.dev'),
('3bb0c0de-0000-4000-8000-000000000116', 'test-workspace', 'flownode', 'f/t/agent/loop-0', 4444444444, NULL, 'test-user', 'u/test-user', 'test@windmill.dev'),
('3bb0c0de-0000-4000-8000-000000000117', 'test-workspace', 'flowscript', 'f/t/agent/loop-0/b', 4444444446, '3bb0c0de-0000-4000-8000-000000000116', 'test-user', 'u/test-user', 'test@windmill.dev'),
('3bb0c0de-0000-4000-8000-000000000118', 'test-workspace', 'flownode', 'f/t/agent/loop-0', 4444444443, '3bb0c0de-0000-4000-8000-000000000102', 'test-user', 'u/test-user', 'test@windmill.dev'),
('3bb0c0de-0000-4000-8000-000000000119', 'test-workspace', 'flownode', 'f/t/agent/loop-0', 4444444443, NULL, 'test-user', 'u/test-user', 'test@windmill.dev'),
('3bb0c0de-0000-4000-8000-000000000120', 'test-workspace', 'flownode', 'f/t/agent/loop-0', 4444444443, NULL, 'test-user', 'u/test-user', 'test@windmill.dev');
INSERT INTO v2_job_completed (id, workspace_id, duration_ms, status)
VALUES
('3bb0c0de-0000-4000-8000-000000000115', 'test-workspace', 0, 'success'),
('3bb0c0de-0000-4000-8000-000000000118', 'test-workspace', 0, 'success');
INSERT INTO v2_job_queue (id, workspace_id, scheduled_for, running)
VALUES
('3bb0c0de-0000-4000-8000-000000000116', 'test-workspace', NOW(), true),
('3bb0c0de-0000-4000-8000-000000000119', 'test-workspace', NOW(), true),
('3bb0c0de-0000-4000-8000-000000000120', 'test-workspace', NOW(), true);
INSERT INTO v2_job_status (id, flow_status)
VALUES
('3bb0c0de-0000-4000-8000-000000000116',
'{"restarted_from": {"flow_job_id": "3bb0c0de-0000-4000-8000-000000000115", "step_id": "b"}}'),
('3bb0c0de-0000-4000-8000-000000000119',
'{"restarted_from": {"flow_job_id": "3bb0c0de-0000-4000-8000-000000000118", "step_id": "b"}}'),
('3bb0c0de-0000-4000-8000-000000000120',
'{"restarted_from": {"flow_job_id": "3bb0c0de-0000-4000-8000-000000000109", "step_id": "b"}}');