From ea69e32d4422281dccb5eb6a2a7504994d059093 Mon Sep 17 00:00:00 2001 From: Utkarash Singh Date: Tue, 8 Sep 2026 17:20:38 +0100 Subject: [PATCH] fix: extract lint categories without spanning earlier arrays The categories regex used a lazy `.*?` under DOTALL, so in a lint with an earlier `array[...]` the capture ran across it to the trailing `as categories` and returned the whole span as garbage categories. This hit 0023/0024/0025, whose SECURITY category came out as dozens of junk strings, which then dropped them from category-filtered Advisor runs. Match a single `array[...]` with `[^\]]*` and validate the result against the known category set so a malformed lint fails the build instead of shipping. --- bin/compile_json.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/compile_json.py b/bin/compile_json.py index 2ad885c..822627e 100644 --- a/bin/compile_json.py +++ b/bin/compile_json.py @@ -32,9 +32,9 @@ import compile # noqa: E402 (bin/compile.py; import after sys.path setup) NAME_RE = re.compile(r"'([a-z0-9_]+)'\s+as\s+name", re.IGNORECASE) -CATEGORIES_RE = re.compile( - r"array\[(.*?)\]\s+as\s+categories", re.IGNORECASE | re.DOTALL -) +CATEGORIES_RE = re.compile(r"array\[([^\]]*)\]\s+as\s+categories", re.IGNORECASE) + +VALID_CATEGORIES = {"SECURITY", "PERFORMANCE"} def extract_name(stem: str, query: str) -> str: @@ -56,6 +56,9 @@ def extract_categories(stem: str, query: str) -> List[str]: ] if not categories: raise SystemExit(f"lint {stem!r}: empty categories array") + invalid = [c for c in categories if c not in VALID_CATEGORIES] + if invalid: + raise SystemExit(f"lint {stem!r}: invalid categories {invalid}") return categories