Skip to content

Commit 29c2423

Browse files
committed
fix(review): [R20 S4] reject empty-string tokens in riskTierPathTokens (cubic-review P2)
An empty string in `riskTierPathTokens.<category>` compiles into a regex alternative like `(?:|foo)` — the empty branch matches the empty string between two adjacent boundary chars, so any path with two `_`/`.`/`-`/`/`/digit chars in a row (e.g. `stg__orders.sql`) silently over-promotes on any configured category. Reject at the config-schema layer via `z.string().min(1)`; the resolver itself is unchanged. Test: `riskTierPathTokens rejects empty-string tokens` under `describe("config")` in review.test.ts — asserts throw on empty token, non-empty tokens still parse. 230/230 review-* tests pass.
1 parent 21f9914 commit 29c2423

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎packages/opencode/src/altimate/review/config.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ export const ReviewConfig = z.object({
6868
* inside `broadcaster.sql` or `precast_table.sql`. The `preset:<name>`
6969
* marker expands to the current shipped list at reviewer startup.
7070
*/
71-
riskTierPathTokens: z.record(z.string(), z.array(z.string())).default({}),
71+
// Tokens must be non-empty. An empty string here compiles into a regex
72+
// alternative that matches everywhere between two boundary characters
73+
// (`(?:|foo)` matches the empty string), silently over-promoting paths
74+
// like `stg__orders.sql` where two boundary chars are adjacent.
75+
// Cubic-review P2 on PR #1028.
76+
riskTierPathTokens: z.record(z.string(), z.array(z.string().min(1))).default({}),
7277
})
7378
export type ReviewConfig = z.infer<typeof ReviewConfig>
7479

‎packages/opencode/test/altimate/review.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,19 @@ describe("config", () => {
884884
const rubric = resolveRubric(cfg)
885885
expect(rubric.exclusions.excludeGlobs).toContain("legacy/old.sql")
886886
})
887+
888+
test("riskTierPathTokens rejects empty-string tokens (cubic-review P2)", () => {
889+
// An empty token would compile to a `(?:|foo)` alternative that
890+
// matches the empty string between two boundary chars — e.g.
891+
// `stg__orders.sql` would silently over-promote. Zod schema
892+
// requires non-empty tokens.
893+
expect(() =>
894+
parseReviewConfig("riskTierPathTokens:\n finops:\n - ''\n - cost\n"),
895+
).toThrow()
896+
// Legit non-empty tokens still parse.
897+
const ok = parseReviewConfig("riskTierPathTokens:\n finops:\n - cost\n - preset:finops\n")
898+
expect(ok.riskTierPathTokens.finops).toEqual(["cost", "preset:finops"])
899+
})
887900
})
888901

889902
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)