Skip to content

refactor(vex): split src/vex.rs by format into module directory#50

Merged
Metbcy merged 2 commits into
mainfrom
refactor/31-split-vex-by-format
May 18, 2026
Merged

refactor(vex): split src/vex.rs by format into module directory#50
Metbcy merged 2 commits into
mainfrom
refactor/31-split-vex-by-format

Conversation

@Metbcy
Copy link
Copy Markdown
Owner

@Metbcy Metbcy commented May 18, 2026

Closes #31.

The monolithic src/vex.rs (1441 LOC, ~50KB) mixed five concerns: loader entry point, OpenVEX parser, CycloneDX VEX parser, apply pass, emit pass, and the synthetic-id formatters/parser. It was the largest module in the crate and well over the documented soft budget.

Split into a directory module, one file per concern:

  • src/vex/mod.rs — 480 LOC, 16K (types, load, detect_format, VexIndex, VexAnnotation, re-exports, loader tests)
  • src/vex/openvex.rs — 65 LOC (OpenVEX 0.2.0 parser)
  • src/vex/cyclonedx_vex.rs — 63 LOC (CycloneDX VEX 1.6 parser)
  • src/vex/apply.rs — 140 LOC (apply pass over enrichment)
  • src/vex/emit.rs — 354 LOC, 13K (emit + EmitOptions, emission tests)
  • src/vex/synthetic_id.rs — 417 LOC, 14K (formatters + parse_synthetic_id, id tests)

All under the 25KB budget.

Public API preserved via re-exports in mod.rs: crate::vex::{load, apply, emit, EmitOptions, VexAnnotation, VexIndex, VexStatement, VexStatus, SyntheticFindingKind, parse_synthetic_id, synthetic_id}. No call sites in run.rs, lib.rs, enrich/mod.rs, or enrich/license.rs needed changes.

All 443 tests green (cargo test --release).

Metbcy added 2 commits May 18, 2026 01:07
Closes #31.

The monolithic src/vex.rs (1441 LOC, 50KB) mixed five concerns:
loader entry point, OpenVEX parser, CycloneDX VEX parser, apply pass,
emit pass, and the synthetic-id formatters/parser. This made the file
the largest module in the crate and well over the soft budget.

Split into a directory module with one file per concern:

  src/vex/mod.rs          — types, load(), detect_format, VexIndex,
                            VexAnnotation, re-exports, loader tests
  src/vex/openvex.rs      — OpenVEX 0.2.0 parser
  src/vex/cyclonedx_vex.rs — CycloneDX VEX 1.6 parser
  src/vex/apply.rs        — apply() pass over enrichment
  src/vex/emit.rs         — emit() and EmitOptions, emission tests
  src/vex/synthetic_id.rs — formatters + parse_synthetic_id, id tests

Public API preserved via re-exports: crate::vex::{load, apply, emit,
EmitOptions, VexAnnotation, VexIndex, VexStatement, VexStatus,
SyntheticFindingKind, parse_synthetic_id, synthetic_id}. All 443 tests
pass.
CI caught two -D warnings issues missed by the local test build:
- src/vex/mod.rs: `Path` is no longer used after the parser split
  (only PathBuf is touched here).
- src/vex/emit.rs: `write_tmp` and its `Write`/`PathBuf` imports were
  never wired into emit tests (the roundtrip test inlines its own
  tmp-write logic). Removed.
- src/vex/mod.rs: `mod tests` now has `#[cfg(test)]` like its siblings,
  and the duplicate cfg attr in emit.rs is collapsed.

cargo test --release --all-features: 443 passed.
cargo clippy --all-targets --all-features -- -D warnings: clean.
RUSTFLAGS='-D warnings' cargo build --all-targets --all-features: clean.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

Coverage report

Line coverage: 84.1% (9378 / 11150 lines)

Full lcov report available as workflow artifact coverage-lcov: download from this run.

v0.9.8 introduces this report; --fail-under-lines will be added once coverage is visible across 2–3 releases.

@Metbcy Metbcy force-pushed the refactor/31-split-vex-by-format branch from 3a3eecc to 780c377 Compare May 18, 2026 01:39
@Metbcy Metbcy merged commit 1960e77 into main May 18, 2026
10 checks passed
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.

Split src/vex.rs by format (openvex / cyclonedx_vex / apply / synthetic_id)

1 participant