From 4f414014a8d466fb8816f7eadf1175d98d2324c6 Mon Sep 17 00:00:00 2001 From: imbytecat Date: Sat, 25 Apr 2026 14:50:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor(codegen):=20embed-migrations=20?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=20journal=20tag/idx/when?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 防止手改 _journal.json 时 tag 字符串混入路径或注入 codegen import 语句; 同时锁紧 idx/when 为非负整数。 --- embed-migrations.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/embed-migrations.ts b/embed-migrations.ts index cda7516..2d2cc2c 100644 --- a/embed-migrations.ts +++ b/embed-migrations.ts @@ -7,9 +7,9 @@ const OUTPUT = './src/server/db/migrations.gen.ts' const SQL_RELATIVE_FROM_OUTPUT = '../../../drizzle' const journalEntrySchema = z.object({ - idx: z.number(), - tag: z.string(), - when: z.number(), + idx: z.number().int().nonnegative(), + tag: z.string().regex(/^\d{4}_[a-z0-9_]+$/), + when: z.number().int().nonnegative(), breakpoints: z.boolean(), }) const journalSchema = z.object({ entries: z.array(journalEntrySchema).default([]) })