@mitre/hdf-extension-graph 3.6.0-rc.2 → 3.6.0-rc.4
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 +46 -2
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -24,6 +24,10 @@ pnpm add @mitre/hdf-extension-graph
|
|
|
24
24
|
|
|
25
25
|
Requires `@mitre/hdf-schema` as a peer dependency.
|
|
26
26
|
|
|
27
|
+
```bash
|
|
28
|
+
go get github.com/mitre/hdf-libs/hdf-extension-graph/go/v3
|
|
29
|
+
```
|
|
30
|
+
|
|
27
31
|
## Usage
|
|
28
32
|
|
|
29
33
|
### Build the graph
|
|
@@ -144,16 +148,56 @@ Builds a bidirectional extension graph from an HDF Results file. Links baselines
|
|
|
144
148
|
|
|
145
149
|
```typescript
|
|
146
150
|
interface Modification {
|
|
147
|
-
field: string; // 'impact', 'title', or '
|
|
151
|
+
field: string; // 'impact', 'title', 'severity', 'effectiveImpact', or 'disposition'
|
|
148
152
|
originalValue: unknown;
|
|
149
153
|
newValue: unknown;
|
|
150
154
|
inBaseline: string; // Name of the baseline making the change
|
|
151
155
|
}
|
|
152
156
|
```
|
|
153
157
|
|
|
158
|
+
## Go
|
|
159
|
+
|
|
160
|
+
The Go module (package `hdfextension`) mirrors the TypeScript package: the same graph, the same derived properties, and `Modification` output that serializes identically. The `test/cross-language-equivalence.test.ts` suite builds the `go/cmd/equivalence-dump` command and compares its canonical graph dump with the TypeScript dumper's (`test/equivalence-dump.ts`) on the same fixtures, so the two implementations cannot drift.
|
|
161
|
+
|
|
162
|
+
```go
|
|
163
|
+
import hdfextension "github.com/mitre/hdf-libs/hdf-extension-graph/go/v3"
|
|
164
|
+
|
|
165
|
+
graph := hdfextension.BuildExtensionGraph(results) // results is a *hdf.HDFResults
|
|
166
|
+
|
|
167
|
+
stig := graph.FindBaseline("rhel9-stig-baseline")
|
|
168
|
+
for _, overlay := range stig.ExtendedBy {
|
|
169
|
+
fmt.Printf("%s extends %s\n", overlay.Data.Name, stig.Data.Name)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
for _, req := range graph.FindRequirements("SV-238196") {
|
|
173
|
+
if !req.IsRedundant() {
|
|
174
|
+
for _, mod := range req.Modifications() {
|
|
175
|
+
fmt.Printf("%s: %v → %v\n", mod.Field, mod.OriginalValue, mod.NewValue)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### `BuildExtensionGraph(results *hdf.HDFResults) *ExtensionGraph`
|
|
182
|
+
|
|
183
|
+
Builds the bidirectional graph from an HDF Results document, linking baselines via `parentBaseline` and requirements by matching `id` across linked baselines.
|
|
184
|
+
|
|
185
|
+
| TypeScript | Go |
|
|
186
|
+
|---|---|
|
|
187
|
+
| `graph.baselines` | `graph.Baselines` (`[]*ContextualizedBaseline`) |
|
|
188
|
+
| `graph.requirements` | `graph.Requirements` (`[]*ContextualizedRequirement`) |
|
|
189
|
+
| `graph.rootBaselines` | `graph.RootBaselines()` |
|
|
190
|
+
| `graph.findBaseline(name)` | `graph.FindBaseline(name)` (nil when absent) |
|
|
191
|
+
| `graph.findRequirements(id)` | `graph.FindRequirements(id)` |
|
|
192
|
+
| `baseline.data` / `sourcedFrom` / `extendsFrom` / `extendedBy` / `requirements` | `Data` / `SourcedFrom` / `ExtendsFrom` / `ExtendedBy` / `Requirements` fields on `ContextualizedBaseline` |
|
|
193
|
+
| `req.data` / `sourcedFrom` / `extendsFrom` / `extendedBy` | `Data` / `SourcedFrom` / `ExtendsFrom` / `ExtendedBy` fields on `ContextualizedRequirement` |
|
|
194
|
+
| `req.root` / `isRedundant` / `fullCode` / `extensionChain` / `modifications` | `Root()` / `IsRedundant()` / `FullCode()` / `ExtensionChain()` / `Modifications()` methods |
|
|
195
|
+
| `Modification` | `Modification{Field, OriginalValue, NewValue, InBaseline}` |
|
|
196
|
+
|
|
197
|
+
`hdfextension.TrackedFields` lists the requirement fields `Modifications()` compares, in emission order.
|
|
198
|
+
|
|
154
199
|
## Notes
|
|
155
200
|
|
|
156
|
-
- **TypeScript only** — there is no Go implementation of hdf-extension-graph.
|
|
157
201
|
- The HDF schemas consumed by this package are documented at <https://mitre.github.io/hdf-libs/schemas/>.
|
|
158
202
|
|
|
159
203
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mitre/hdf-extension-graph",
|
|
3
|
-
"version": "3.6.0-rc.
|
|
3
|
+
"version": "3.6.0-rc.4",
|
|
4
4
|
"description": "Bidirectional extension graph processing for HDF profile/baseline hierarchies",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"author": "MITRE Corporation",
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@mitre/hdf-schema": "^3.6.0-rc.
|
|
28
|
+
"@mitre/hdf-schema": "^3.6.0-rc.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@mitre/hdf-fixtures": "^3.6.0-rc.
|
|
32
|
-
"@mitre/hdf-parsers": "^3.6.0-rc.
|
|
31
|
+
"@mitre/hdf-fixtures": "^3.6.0-rc.4",
|
|
32
|
+
"@mitre/hdf-parsers": "^3.6.0-rc.4"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=22.0.0"
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"test:coverage": "vitest run --coverage",
|
|
52
52
|
"type-check": "tsc --noEmit",
|
|
53
53
|
"lint": "eslint src test",
|
|
54
|
-
"lint:fix": "eslint src test --fix"
|
|
54
|
+
"lint:fix": "eslint src test --fix",
|
|
55
|
+
"test:go": "cd go && go test ./..."
|
|
55
56
|
}
|
|
56
57
|
}
|