Skip to content

fix(detect): generate labels and markers from pinned dfe-schemas - #169

Merged
catinspace-au merged 6 commits into
mainfrom
fix/catalogue-codegen
Nov 11, 2026
Merged

catinspace-au merged 6 commits into
mainfrom
fix/catalogue-codegen

Conversation

@catinspace-au

Copy link
Copy Markdown
Contributor

Replace the hand-run labels.rs snapshot, which had no drift check, and the marker table coded in signatures.rs. One generator reads the dfe-schemas wheel pinned by version and sha256 in scripts/dfe-schemas.toml.

  • scripts/gen_detect_tables.py writes src/detect/labels.rs and src/detect/markers.rs. Markers come from each source's catalogue.detect block, in detect.order, then file order. CEF markers go by source name.
  • The output uses the same static slices and const constructors, so the hot path is unchanged. Builds read no network and run no build script.
  • tests/scripts_suite.rs runs the generator with --check, so a stale table fails the Test job.
  • scripts/test_gen_detect_tables.py covers ordering, escaping, refusals and the digest check.
  • Generated SIGNATURES and CEF match the deleted hand-written tables entry for entry, including verify functions.
  • Labels are unchanged: 1,069 variants, no entry moved.

Replace the hand-run labels.rs snapshot, which had no drift check, and the marker table coded in signatures.rs. One generator reads the dfe-schemas wheel pinned by version and sha256 in scripts/dfe-schemas.toml.

- scripts/gen_detect_tables.py writes src/detect/labels.rs and src/detect/markers.rs. Markers come from each source's catalogue.detect block, in detect.order, then file order. CEF markers go by source name.
- The output uses the same static slices and const constructors, so the hot path is unchanged. Builds read no network and run no build script.
- tests/scripts_suite.rs runs the generator with --check, so a stale table fails the Test job.
- scripts/test_gen_detect_tables.py covers ordering, escaping, refusals and the digest check.
- Generated SIGNATURES and CEF match the deleted hand-written tables entry for entry, including verify functions.
- Labels are unchanged: 1,069 variants, no entry moved.
MAX_EVERY was fixed at 32 for the table's 32 all-of entries. One more all marker in dfe-schemas would have broken the build. The generator writes MAX_EVERY into markers.rs as the count of all-of entries. The per-line scratch stays a fixed-size stack array.

- The generator refuses an all marker over 8 literals and a priority over 255, because the detector holds them in a u8.
- The pinned wheel comes from DFE_SCHEMAS_WHEEL, a digest-named cache, or PyPI. Each source must match the pinned sha256.
- With none available the generator exits 3. The drift test skips that locally and fails in CI.
0.2.28 has the catalogue.detect blocks. Regenerating from its wheel changes only the origin line in the two file headers.
@catinspace-au
catinspace-au marked this pull request as ready for review November 11, 2026 06:49
The generator rejects non-https URLs before urlopen. This blocks file:// wheel URLs. The urlopen call has a nosemgrep mark for dynamic-urllib because the scheme check and sha256 pin address the rule.
@catinspace-au
catinspace-au merged commit d8d9a41 into main Nov 11, 2026
26 checks passed
@catinspace-au
catinspace-au deleted the fix/catalogue-codegen branch November 11, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant