Repository navigation
fix: CORS allowlist, runbook schema drift, k6 guard, sweep assertions - #1442
Merged
Mimah97 merged 2 commits intoOct 26, 2026
Conversation
Four independent fixes landing in one commit: 1. CORS middleware env-driven allowlist (Vatix-Protocol#1289) - Rewrite apps/indexer/src/middleware/cors.ts from Hono stubs to real Fastify middleware. Export indexerCorsPlugin (uses @fastify/cors) and a standalone cors() hook for unit tests. - resolveAllowedOrigins() reads CORS_ALLOWED_ORIGINS (comma-separated); returns [] for unset/empty/whitespace — fails closed, never falls back to wildcard when an allowlist is configured. - cors() echoes the request Origin only when allowlisted; omits Access-Control-Allow-Origin entirely for non-allowlisted/absent origins; sets Vary: Origin; never emits Access-Control-Allow-Origin: *. - OPTIONS still returns 204; downstream handlers not invoked on preflight. - cors.test.ts rewritten to use Fastify inject() (27 tests). 2. Incident runbook schema drift detection - Extend tests/config/incident-runbook.test.ts with brace-counting extractPrismaBlocks() (handles nested {} in @@unique/@@index), parsePrismaSchema() (model→@@Map table names + all enum members), stripSqlLineComments(), extractTableNamesFromSql() (skips pg system tables and SQL keywords), extractEnumLiteralsFromSql() (ALL_CAPS comparison-context literals only, no INSERT VALUES noise). - A runbook SQL block referencing an unknown table or enum literal now fails the test with the offending identifier named. - Fix pre-existing container name drift: vatix-finalization-job → vatix-finalization-worker in docs/runbooks/incident-runbook.md. - All 7 assertions pass (4 existing + 3 new). 3. k6 soak script guards (Vatix-Protocol#807) - scripts/load/order-placement-soak.js: throw Error when MARKET_ID is empty, naming the variable and showing the -e MARKET_ID= usage. - Emit console.warn when AUTH_HEADER is unset so unauthenticated runs are visible in the summary. Existing ALLOWED_HOSTS guard untouched. 4. Cross-book sweep post-state assertions (Vatix-Protocol#808) - tests/matching/cross-book-sweep.test.ts: each sweep scenario now asserts trades.length, total filled quantity (sum of trade.quantity), remainingOrder === null, and getDepth() remaining quantities on every maker level of the swept book. - Existing toMatchSnapshot() calls and untouched-book assertions preserved.
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.
Four independent fixes landing in one commit:
CORS middleware env-driven allowlist (Indexer CORS middleware: allowlist origins from env instead of hardcoded wildcard #1289)
Incident runbook schema drift detection
k6 soak script guards (Add k6 script stub for order placement soak test #807)
Cross-book sweep post-state assertions (Add cross-book sweep fill scenario to matching corpus #808)
closes #1396
closes #1397
closes #1398
closes #1399