@mitre/hdf-diff 3.0.1 → 3.1.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.
Files changed (91) hide show
  1. package/LICENSE.md +55 -0
  2. package/README.md +49 -17
  3. package/dist/index.d.ts +622 -16
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +2037 -18
  6. package/dist/index.js.map +1 -1
  7. package/package.json +19 -19
  8. package/dist/diff.d.ts +0 -49
  9. package/dist/diff.d.ts.map +0 -1
  10. package/dist/diff.js +0 -791
  11. package/dist/diff.js.map +0 -1
  12. package/dist/exit-codes.d.ts +0 -42
  13. package/dist/exit-codes.d.ts.map +0 -1
  14. package/dist/exit-codes.js +0 -74
  15. package/dist/exit-codes.js.map +0 -1
  16. package/dist/matching/cci-match.d.ts +0 -14
  17. package/dist/matching/cci-match.d.ts.map +0 -1
  18. package/dist/matching/cci-match.js +0 -102
  19. package/dist/matching/cci-match.js.map +0 -1
  20. package/dist/matching/exact-id.d.ts +0 -9
  21. package/dist/matching/exact-id.d.ts.map +0 -1
  22. package/dist/matching/exact-id.js +0 -88
  23. package/dist/matching/exact-id.js.map +0 -1
  24. package/dist/matching/fuzzy-match.d.ts +0 -26
  25. package/dist/matching/fuzzy-match.d.ts.map +0 -1
  26. package/dist/matching/fuzzy-match.js +0 -145
  27. package/dist/matching/fuzzy-match.js.map +0 -1
  28. package/dist/matching/index.d.ts +0 -36
  29. package/dist/matching/index.d.ts.map +0 -1
  30. package/dist/matching/index.js +0 -71
  31. package/dist/matching/index.js.map +0 -1
  32. package/dist/matching/mapped-id.d.ts +0 -13
  33. package/dist/matching/mapped-id.d.ts.map +0 -1
  34. package/dist/matching/mapped-id.js +0 -101
  35. package/dist/matching/mapped-id.js.map +0 -1
  36. package/dist/matching/types.d.ts +0 -34
  37. package/dist/matching/types.d.ts.map +0 -1
  38. package/dist/matching/types.js +0 -2
  39. package/dist/matching/types.js.map +0 -1
  40. package/dist/normalize.d.ts +0 -20
  41. package/dist/normalize.d.ts.map +0 -1
  42. package/dist/normalize.js +0 -120
  43. package/dist/normalize.js.map +0 -1
  44. package/dist/renderers/csv.d.ts +0 -15
  45. package/dist/renderers/csv.d.ts.map +0 -1
  46. package/dist/renderers/csv.js +0 -77
  47. package/dist/renderers/csv.js.map +0 -1
  48. package/dist/renderers/filter.d.ts +0 -11
  49. package/dist/renderers/filter.d.ts.map +0 -1
  50. package/dist/renderers/filter.js +0 -29
  51. package/dist/renderers/filter.js.map +0 -1
  52. package/dist/renderers/index.d.ts +0 -17
  53. package/dist/renderers/index.d.ts.map +0 -1
  54. package/dist/renderers/index.js +0 -29
  55. package/dist/renderers/index.js.map +0 -1
  56. package/dist/renderers/json.d.ts +0 -13
  57. package/dist/renderers/json.d.ts.map +0 -1
  58. package/dist/renderers/json.js +0 -41
  59. package/dist/renderers/json.js.map +0 -1
  60. package/dist/renderers/markdown.d.ts +0 -13
  61. package/dist/renderers/markdown.d.ts.map +0 -1
  62. package/dist/renderers/markdown.js +0 -133
  63. package/dist/renderers/markdown.js.map +0 -1
  64. package/dist/renderers/terminal.d.ts +0 -14
  65. package/dist/renderers/terminal.d.ts.map +0 -1
  66. package/dist/renderers/terminal.js +0 -173
  67. package/dist/renderers/terminal.js.map +0 -1
  68. package/dist/renderers/types.d.ts +0 -12
  69. package/dist/renderers/types.d.ts.map +0 -1
  70. package/dist/renderers/types.js +0 -2
  71. package/dist/renderers/types.js.map +0 -1
  72. package/dist/sbom.d.ts +0 -42
  73. package/dist/sbom.d.ts.map +0 -1
  74. package/dist/sbom.js +0 -203
  75. package/dist/sbom.js.map +0 -1
  76. package/dist/status.d.ts +0 -27
  77. package/dist/status.d.ts.map +0 -1
  78. package/dist/status.js +0 -137
  79. package/dist/status.js.map +0 -1
  80. package/dist/summary.d.ts +0 -6
  81. package/dist/summary.d.ts.map +0 -1
  82. package/dist/summary.js +0 -47
  83. package/dist/summary.js.map +0 -1
  84. package/dist/types.d.ts +0 -208
  85. package/dist/types.d.ts.map +0 -1
  86. package/dist/types.js +0 -2
  87. package/dist/types.js.map +0 -1
  88. package/dist/validate.d.ts +0 -20
  89. package/dist/validate.d.ts.map +0 -1
  90. package/dist/validate.js +0 -19
  91. package/dist/validate.js.map +0 -1
package/LICENSE.md ADDED
@@ -0,0 +1,55 @@
1
+ # License
2
+
3
+ Copyright © 2025 The MITRE Corporation.
4
+
5
+ Approved for Public Release; Distribution Unlimited. Case Number 18-3678.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
8
+ not use this file except in compliance with the License. You may obtain a
9
+ copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ License for the specific language governing permissions and limitations
17
+ under the License.
18
+
19
+ ## Redistribution Terms
20
+
21
+ Redistribution and use in source and binary forms, with or without
22
+ modification, are permitted provided that the following conditions are
23
+ met:
24
+
25
+ - Redistributions of source code must retain the above copyright/digital
26
+ rights legend, this list of conditions and the following Notice.
27
+ - Redistributions in binary form must reproduce the above
28
+ copyright/digital rights legend, this list of conditions and the
29
+ following Notice in the documentation and/or other materials provided
30
+ with the distribution.
31
+ - Neither the name of The MITRE Corporation nor the names of its contributors
32
+ may be used to endorse or promote products derived from this software
33
+ without specific prior written permission.
34
+
35
+ ## Notice
36
+
37
+ The MITRE Corporation grants permission to reproduce, distribute, modify, and
38
+ otherwise use this software to the extent permitted by the licensed terms
39
+ provided in the LICENSE file included with this project.
40
+
41
+ This software was produced by The MITRE Corporation for the U.S. Government
42
+ under contract. As such the U.S. Government has certain use and data
43
+ rights in this software. No use other than those granted to the U.S.
44
+ Government, or to those acting on behalf of the U.S. Government, under
45
+ these contract arrangements is authorized without the express written
46
+ permission of The MITRE Corporation.
47
+
48
+ Some files in this codebase were generated by generative AI, under the
49
+ direction and review of The MITRE Corporation employees, for the purpose of
50
+ development efficiency. All AI-generated code functionality was validated
51
+ by standard quality and assurance testing.
52
+
53
+ For further information, please contact The MITRE Corporation,
54
+ Contracts Management Office, 7515 Colshire Drive, McLean, VA 22102-7539,
55
+ (703) 983-6000.
package/README.md CHANGED
@@ -1,26 +1,30 @@
1
1
  # @mitre/hdf-diff
2
2
 
3
- Structured comparison of HDF evaluation results — tracks what changed, why, and by how much.
3
+ Structured comparison of HDF documents — tracks what changed, why, and by how much.
4
4
 
5
5
  ## What it does
6
6
 
7
- Compares two HDF results documents and produces a structured diff showing:
8
- - Requirements added, removed, or changed between evaluations
9
- - Status transitions (passed→failed, failed→passed, etc.) with change reasons
10
- - Field-level changes (impact, title, severity)
11
- - Per-baseline and per-component compliance summaries
12
- - SBOM (CycloneDX/SPDX) package-level diffs
7
+ Compares HDF documents (results, baselines, or system documents) and produces a structured diff:
13
8
 
14
- Output formats: JSON, Markdown, CSV, terminal (ANSI-colored).
9
+ - **Results comparison** (`diffHdf`) — requirements added, removed, or changed between evaluations; status transitions with change reasons; field-level changes (impact, severity, disposition, effectiveImpact); per-baseline compliance summaries
10
+ - **Baseline evolution** (`diffBaselines`) — track how a baseline's requirements change across versions (IDs added/removed, impact/severity/title changes)
11
+ - **System drift** (`diffSystems`) — compare two HDF system documents for component, data flow, and configuration changes
12
+ - **SBOM comparison** (`diffSboms`) — CycloneDX/SPDX package-level diffs (added, removed, updated)
13
+ - **Amendment operations** (Go only, `amend` subpackage) — merge overrides into results, verify amendment chains, compute effectiveStatus/effectiveImpact/disposition
14
+
15
+ Additional capabilities:
16
+ - Multiple comparison modes: temporal, baseline, fleet, multi-source
17
+ - Format normalization: legacy InSpec exec-json (v1) to current HDF
18
+ - Output formats: JSON, Markdown, CSV, terminal (ANSI-colored)
19
+ - CI exit codes: GNU diff-compatible (0/1/2) and detailed (10-14)
15
20
 
16
21
  ## Relationship to other packages
17
22
 
18
23
  | Package | Relationship |
19
24
  |---------|-------------|
20
- | **hdf-schema** | Provides the `HDFResults` types that hdf-diff consumes |
25
+ | **hdf-schema** | Provides `HDFResults`, `HDFBaseline`, and system types that hdf-diff consumes |
21
26
  | **hdf-validators** | Used to validate comparison output against the HDF comparison schema |
22
- | **hdf-cli** | `hdf diff` command wraps this library for CLI use |
23
- | **hdf-parsers** | Not used — hdf-diff operates on typed structs, not raw JSON |
27
+ | **hdf-cli** | `hdf diff` and `hdf amend` commands wrap this library for CLI use |
24
28
 
25
29
  ## Installation
26
30
 
@@ -31,16 +35,20 @@ npm install @mitre/hdf-diff
31
35
  ## Usage
32
36
 
33
37
  ```typescript
34
- import { diffHdf, render } from '@mitre/hdf-diff';
38
+ import { diffHdf, diffBaselines, diffSystems, render } from '@mitre/hdf-diff';
35
39
 
36
- // Compare two evaluation results
40
+ // Compare two evaluation results (temporal mode)
37
41
  const comparison = diffHdf(oldResults, newResults);
38
42
 
39
- // Render as markdown
40
- const md = render(comparison, { format: 'markdown', detail: 'full' });
43
+ // Compare baseline evolution (track requirement changes across versions)
44
+ const baselineDiff = diffBaselines(oldBaseline, newBaseline);
45
+
46
+ // Compare system documents (component/data-flow drift)
47
+ const systemDiff = diffSystems(oldSystem, newSystem);
41
48
 
42
- // Render as JSON
43
- const json = render(comparison, { format: 'json' });
49
+ // Render as markdown, JSON, CSV, or terminal
50
+ const md = render(comparison, 'markdown', { detail: 'full' });
51
+ const json = render(comparison, 'json');
44
52
 
45
53
  // Check exit codes for CI
46
54
  import { computeExitCode, EXIT_IDENTICAL } from '@mitre/hdf-diff';
@@ -76,12 +84,36 @@ const sbomDiff = diffSboms(oldSbom, newSbom);
76
84
  ## CLI usage
77
85
 
78
86
  ```bash
87
+ # Results comparison
79
88
  hdf diff old-results.json new-results.json
80
89
  hdf diff old-results.json new-results.json --format markdown
81
90
  hdf diff old-results.json new-results.json --json
91
+
92
+ # System drift detection
93
+ hdf diff old-system.json new-system.json
94
+
95
+ # SBOM comparison
82
96
  hdf diff --sbom old-sbom.json new-sbom.json
97
+
98
+ # Baseline mode (golden baseline vs current scan)
99
+ hdf diff --mode baseline golden.json current.json
100
+ ```
101
+
102
+ ## Go usage
103
+
104
+ The diff engine is also available as a Go module:
105
+
106
+ ```go
107
+ import diff "github.com/mitre/hdf-libs/hdf-diff/go"
83
108
  ```
84
109
 
110
+ See the [hdf-diff/go](https://github.com/mitre/hdf-libs/tree/main/hdf-diff/go) directory for the Go API.
111
+
112
+ ## Schema documentation
113
+
114
+ The HDF Comparison schema that hdf-diff produces is documented at
115
+ <https://mitre.github.io/hdf-libs/schemas/>.
116
+
85
117
  ## License
86
118
 
87
119
  Apache-2.0 © MITRE Corporation