fix(db): owner-scoped file half and chunked instance sweep for DELETE /v1/batches/delete-completed (SEC-C/SEC-D, omni-code-sec on #12969) - #13374
Merged
diegosouzapw merged 5 commits intoSep 14, 2026
Conversation
…unks (SEC-D) Refs #12969
…NCE_SWEEP_CHUNK ids per statement The B3 restructure collected ALL of a key's completed batch ids into one IN (…) list; past SQLite's 32766 bound-parameter ceiling the sweep would throw and the tenant's only bulk-cleanup path would stay dead. Key mode now runs the same 200-id unit inside ONE outer transaction (nested calls are savepoints), so it stays all-or-nothing and never exceeds the ceiling. Also: whitespace-only apiKeyId rejected at the top; JSDoc qualifies the nulled-file guarantee as per-chunk in instance mode. Refs #12969
jonlwheat2-gif
added a commit
to jonlwheat2-gif/OmniRoute
that referenced
this pull request
Sep 13, 2026
…pw#13377) Auth (from PR diegosouzapw#13375): - Delete isStaleDashboardJwtError + staleDashboardJwtWarningEmitted from pipeline.ts; emit log in !payload branch - Minters use getDashboardJwtSecret() (trimmed) in login/route.ts, oidc/callback/route.ts - ws/handshake.ts uses getDashboardJwtSecret() instead of raw env - verifyDashboardSessionToken: pin {algorithms:['HS256']}, reject empty Uint8Array - Use DASHBOARD_SESSION_COOKIE/CLAIM constants in 7 consumers - Source guard: allowlist dashboardSessionToken.ts + oidc/callback for jwtVerify imports - Add try/finally around env mutation in dashboard-session-token-13298.test.ts - AUTHZ_GUIDE.md: 'route guard' -> 'dashboard route guard (isDashboardSessionAuthenticated())' Tests: 28/28 auth tests pass, typecheck clean Scope note: the Batches half of diegosouzapw#13377 (forward-progress guard for deleteCompletedBatches) is intentionally NOT in this PR. The issue's wording ("both for (;;) loops") targets PR diegosouzapw#13374's chunked implementation, which is stacked on PR diegosouzapw#12969 — not this release/v3.8.51 base. It is tracked separately.
Owner
Author
Full suite on the .113 box
Every failing file is either in the inherited set already recorded on #13262/#13297/#13375, or proven environmental with the box idle: the 6 catalog files new on Focused: |
diegosouzapw
merged commit Sep 14, 2026
ebd6e19
into
fix/batches-delete-completed-authz
3 checks passed
diegosouzapw
added a commit
that referenced
this pull request
Sep 14, 2026
diegosouzapw
added a commit
that referenced
this pull request
Sep 14, 2026
Merged after reconciling the whole stack onto the tip, operator-reviewed before merge. The core ownership fix for GHSA-wvxc-jp3v-5mg5 had already landed via #13211 with a different implementation of the same endpoint. This branch carries a stricter one, built up in layers: this PR, #13262 (explicit scope, audit log, atomic sweep), #13297 (revoked, deactivated, banned or expired keys rejected) and #13374 (owner-scoped file half, chunked instance sweep — SEC-C/SEC-D). The stack's implementation was kept over #13211's because it is stricter on every point: - **route:** with #13211, a request carrying BOTH a dashboard session cookie and an API key swept the whole instance. Here a presented key always scopes the sweep to that key; only a session without a key sweeps all tenants; neither returns 401. Instance-wide and row-deleting sweeps log at warn as an audit trail, and a failing sweep returns a sanitized 500. - **`deleteCompletedBatches`:** takes an explicit `{ apiKeyId } | { allTenants: true }`. An omitted or blank key throws instead of widening, and passing both throws. - **files:** a key sweep only soft-deletes files the caller owns (`deleteFileOwnedBy`), so a batch referencing another tenant's or an unowned file never nulls its content. - **transactions:** key mode is all-or-nothing across chunks; instance mode commits per 200-id chunk so a large sweep never holds one write lock on the table. #13211's own test was aligned to the explicit-scope API with its assertions unchanged. Its seed now creates the file with the batch's owner, as an upload through that key does in production — without that, SEC-C correctly leaves the unowned file intact. - 51/51 across the six batch suites (#13211's test, this stack's ownership and route-scope tests, `batch-deletion`, `batch-deletion-route-logic`, `files-delete-owned-by`) - ESLint, `typecheck:core`, complexity, cognitive-complexity, changelog integrity: clean⚠️ base-red inherited: #12732
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…w#12969) Merged after reconciling the whole stack onto the tip, operator-reviewed before merge. The core ownership fix for GHSA-wvxc-jp3v-5mg5 had already landed via diegosouzapw#13211 with a different implementation of the same endpoint. This branch carries a stricter one, built up in layers: this PR, diegosouzapw#13262 (explicit scope, audit log, atomic sweep), diegosouzapw#13297 (revoked, deactivated, banned or expired keys rejected) and diegosouzapw#13374 (owner-scoped file half, chunked instance sweep — SEC-C/SEC-D). The stack's implementation was kept over diegosouzapw#13211's because it is stricter on every point: - **route:** with diegosouzapw#13211, a request carrying BOTH a dashboard session cookie and an API key swept the whole instance. Here a presented key always scopes the sweep to that key; only a session without a key sweeps all tenants; neither returns 401. Instance-wide and row-deleting sweeps log at warn as an audit trail, and a failing sweep returns a sanitized 500. - **`deleteCompletedBatches`:** takes an explicit `{ apiKeyId } | { allTenants: true }`. An omitted or blank key throws instead of widening, and passing both throws. - **files:** a key sweep only soft-deletes files the caller owns (`deleteFileOwnedBy`), so a batch referencing another tenant's or an unowned file never nulls its content. - **transactions:** key mode is all-or-nothing across chunks; instance mode commits per 200-id chunk so a large sweep never holds one write lock on the table. diegosouzapw#13211's own test was aligned to the explicit-scope API with its assertions unchanged. Its seed now creates the file with the batch's owner, as an upload through that key does in production — without that, SEC-C correctly leaves the unowned file intact. - 51/51 across the six batch suites (diegosouzapw#13211's test, this stack's ownership and route-scope tests, `batch-deletion`, `batch-deletion-route-logic`, `files-delete-owned-by`) - ESLint, `typecheck:core`, complexity, cognitive-complexity, changelog integrity: clean⚠️ base-red inherited: diegosouzapw#12732
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes SEC-C and SEC-D of the omni-code-sec battery on #12969.
Validation
files-delete-owned-by 4/4 · ownership-wvxc 11/11 · route-scope 10/10 · batch-deletion 8/8 · typecheck:core · changelog-integrity vs the feature branch. Full suite on .113: last comment.
Refs #12969