refactor(vex): split src/vex.rs by format into module directory#50
Merged
Conversation
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.
Coverage reportLine 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; |
3a3eecc to
780c377
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inrun.rs,lib.rs,enrich/mod.rs, orenrich/license.rsneeded changes.All 443 tests green (
cargo test --release).