@mitre/hdf-fixtures 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # @mitre/hdf-fixtures
2
+
3
+ Shared real-world HDF reference fixtures for cross-package consumers
4
+ (parsers, validators, hdf-extension-graph, hdf-generators, legacyhdf-to-hdf
5
+ converter).
6
+
7
+ **Why this package exists.** Real-world test data was historically scattered
8
+ across converter packages, with no shared discovery mechanism. Packages that
9
+ needed it most (parsers, validators) couldn't see the wild-data samples that
10
+ already existed elsewhere. The class-of-bug fixed by `hdf-libs-2nm0` /
11
+ `hdf-libs-828d` (parsers rejecting real InSpec output with bare timestamps)
12
+ went undetected for exactly that reason — the bug-exhibiting file lived in
13
+ `hdf-extension-graph/test/fixtures/` and never reached the parser's tests.
14
+ See bead `hdf-libs-e95o` for the architecture rationale.
15
+
16
+ ## Boundary rule
17
+
18
+ - **Converter fixtures stay where they are** unless multiple packages
19
+ actively consume them. A converter's `fixtures/input/` and
20
+ `fixtures/expected/` are the converter's *tested contract*.
21
+ - **Inclusion requires real multi-consumer usage** — at least two
22
+ workspace packages actively load the file. "Might be useful someday" or
23
+ "good for parity-test breadth" are not sufficient justification. When
24
+ in doubt, leave the file where it is and migrate later once the second
25
+ consumer materializes.
26
+ - **No duplicates.** If a fixture is going to be used by two packages,
27
+ it lives here exactly once and both consumers import it. The original
28
+ location's file gets deleted; consumer test code is updated.
29
+
30
+ ## Layout
31
+
32
+ ```
33
+ hdf-fixtures/
34
+ ├── results/ — HDF Results docs
35
+ ├── baseline/ — HDF Baseline docs
36
+ ├── amendments/ — HDF Amendments docs
37
+ └── inspec/ — InSpec runner output (non-HDF)
38
+ ```
39
+
40
+ The `inspec/` directory holds InSpec runner output (the input
41
+ format for `legacyhdf-to-hdf` — *not* HDF), kept here for cross-language
42
+ parser parity tests that verify both languages reject non-HDF inputs the
43
+ same way, AND for the legacyhdf-to-hdf converter's own tests (which load
44
+ them via the materialize-to-tmp-file helper in `converter_test.go`).
45
+
46
+ ## Fixture provenance
47
+
48
+ All fixtures here are **real tool output**, never fabricated (per
49
+ CLAUDE.md's fixture-integrity rule).
50
+
51
+ ### `results/` — HDF Results docs
52
+
53
+ | File | Source | Consumers |
54
+ |------|--------|-----------|
55
+ | `inspec-multilayered.json` | InSpec runner, multi-overlay scan | hdf-extension-graph TS + Go tests + hdf-parsers parser parity test. The bug-exhibiting fixture for `hdf-libs-2nm0` — bare timestamps that broke parsers before #83/#828d landed. Moved from `hdf-extension-graph/test/fixtures/multilayered-inspec.json`. |
56
+ | `minimal.json` | Hand-crafted minimal valid HDF Results doc | hdf-to-xml converter (TS + Go) + hdf-parsers integration test + hdf-validators integration test. The smallest schema-valid HDF Results document — single baseline, one passing requirement. Moved from `hdf-converters/converters/hdf-to-xml/fixtures/input/minimal.json`. |
57
+
58
+ ### `baseline/` — HDF Baseline docs
59
+
60
+ | File | Source | Consumers |
61
+ |------|--------|-----------|
62
+ | `win2022-stig.json` | Windows Server 2022 STIG | hdf-generators TS + Go integration tests + hdf-parsers parser parity test. Was previously duplicated across `hdf-generators/go/testdata/` and `hdf-generators/test/fixtures/`. |
63
+
64
+ ### `amendments/` — HDF Amendments docs
65
+
66
+ | File | Source | Consumers |
67
+ |------|--------|-----------|
68
+ | `uc-01-fixed-amendments.json` | HDF form of the CSAF spec example `2022-evd-uc-01-f-001.json` — produced by `csaf-vex-to-hdf` from that upstream VEX advisory. An open POA&M (vendor claims fixed, milestone still pending). | hdf-to-csaf-vex converter (TS + Go, incl. its golden) + hdf-to-oscal-poam converter (TS + Go golden). Moved from `hdf-converters/converters/hdf-to-csaf-vex/fixtures/input/`. |
69
+ | `multi-cve-amendments.json` | HDF form of the CSAF advisory `sec-vex-2022-0001.json` — produced by `csaf-vex-to-hdf` from that upstream VEX advisory. Three overrides across three distinct CVE-shaped requirementIds (the Log4Shell family: CVE-2021-44228/45046/45105), all falsePositive. A multi-override amendments doc for meaningful export-side output-count anchors (bead hdf-libs-j0ok). | hdf-to-oscal-poam, hdf-to-csaf-vex, hdf-to-cyclonedx-vex, hdf-to-openvex output-count anchors (TS + Go). |
70
+
71
+ ### `inspec/` — InSpec runner output (NOT HDF)
72
+
73
+ The input format for `legacyhdf-to-hdf` (which converts these to HDF). Kept
74
+ here because both that converter's tests AND the cross-language parser
75
+ parity test consume them. Each exercises a different timestamp format /
76
+ runner config.
77
+
78
+ | File | Notes | Consumers |
79
+ |------|-------|-----------|
80
+ | `ubi9-scan.json` | UBI9 container scan, `-05:00` offset | legacyhdf-to-hdf converter (TS + Go) + hdf-cli legacyhdf test + parser parity test |
81
+ | `container-scan.json` | Generic container scan, `-05:00` offset | same |
82
+ | `three-layer-overlay.json` | Three-layer overlay chain, `+00:00` offset | same |
83
+ | `wrapper.json` | InSpec wrapper-profile structure | legacyhdf-to-hdf converter (TS + Go) + hdf-parsers flatten integration test |
84
+ | `three-layer-rhel7.json` | Three-layer RHEL7 overlay (was `Three_Layer_RHEL7_Overlay_Example.json`) | hdf-parsers flatten integration test. Moved from `hdf-schema/test/fixtures/`. |
85
+
86
+ ## Validation gate
87
+
88
+ `fixtures_gate_test.go` walks every HDF document in `results/`,
89
+ `baseline/` and `amendments/` and validates against the appropriate schema (replaces the
90
+ per-converter snapshot coverage hdf-cli's
91
+ `converter_fixture_roundtrip_test.go` previously provided for these
92
+ specific files now that they live here). `inspec/*` is exempt — those
93
+ files are non-HDF by design.
94
+
95
+ ## Usage
96
+
97
+ **TypeScript:**
98
+
99
+ ```ts
100
+ import { results, baseline, amendments, inspec } from '@mitre/hdf-fixtures';
101
+
102
+ // On-disk path (for tools that need a file argument):
103
+ const path = results.inspecMultilayered.path;
104
+
105
+ // Or read the bytes directly:
106
+ const raw = results.inspecMultilayered.read();
107
+ ```
108
+
109
+ **Go:**
110
+
111
+ ```go
112
+ import fixtures "github.com/mitre/hdf-libs/hdf-fixtures"
113
+
114
+ data := fixtures.Results.InspecMultilayered // []byte, //go:embed'd at build
115
+ ```
116
+
117
+ ## When to add a new fixture
118
+
119
+ Add a fixture here when **two or more workspace packages already need it**
120
+ — not preemptively. If only one package needs it, keep it local to that
121
+ package; promote it here when a second consumer materializes.
122
+
123
+ Each new fixture must:
124
+ 1. Come from a real tool run (no fabrication).
125
+ 2. Be added to this README with provenance AND the list of consumers.
126
+ 3. Be wired into both `src/index.ts` (TS) and `fixtures.go` (Go) so both
127
+ sides have parallel access.
128
+ 4. Have its original location deleted (no duplicates) and every consumer
129
+ updated to import from here.
130
+ 5. Be added to the group map in `fixtures_gate_test.go`, which validates each
131
+ fixture against its schema. That map is hand-maintained: a fixture missing
132
+ from it is never validated, and nothing reports the omission.