@mitre/hdf-schema 2.0.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/LICENSE.md +55 -0
- package/README.md +143 -0
- package/dist/go/go.mod +4 -0
- package/dist/go/hdf.go +2224 -0
- package/dist/helpers.d.ts +77 -0
- package/dist/helpers.js +242 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +37 -0
- package/dist/python/hdf_amendments.py +695 -0
- package/dist/python/hdf_baseline.py +782 -0
- package/dist/python/hdf_comparison.py +1771 -0
- package/dist/python/hdf_evidence_package.py +593 -0
- package/dist/python/hdf_plan.py +363 -0
- package/dist/python/hdf_results.py +2163 -0
- package/dist/python/hdf_system.py +904 -0
- package/dist/schemas/hdf-amendments.schema.json +1562 -0
- package/dist/schemas/hdf-baseline.schema.json +1787 -0
- package/dist/schemas/hdf-comparison.schema.json +3730 -0
- package/dist/schemas/hdf-evidence-package.schema.json +1738 -0
- package/dist/schemas/hdf-plan.schema.json +1821 -0
- package/dist/schemas/hdf-results.schema.json +2810 -0
- package/dist/schemas/hdf-system.schema.json +2512 -0
- package/dist/ts/hdf-amendments.d.ts +446 -0
- package/dist/ts/hdf-amendments.js +77 -0
- package/dist/ts/hdf-amendments.ts +457 -0
- package/dist/ts/hdf-baseline.d.ts +472 -0
- package/dist/ts/hdf-baseline.js +58 -0
- package/dist/ts/hdf-baseline.ts +483 -0
- package/dist/ts/hdf-comparison.d.ts +1185 -0
- package/dist/ts/hdf-comparison.js +216 -0
- package/dist/ts/hdf-comparison.ts +1210 -0
- package/dist/ts/hdf-evidence-package.d.ts +348 -0
- package/dist/ts/hdf-evidence-package.js +39 -0
- package/dist/ts/hdf-evidence-package.ts +356 -0
- package/dist/ts/hdf-plan.d.ts +204 -0
- package/dist/ts/hdf-plan.js +23 -0
- package/dist/ts/hdf-plan.ts +205 -0
- package/dist/ts/hdf-results.d.ts +1457 -0
- package/dist/ts/hdf-results.js +174 -0
- package/dist/ts/hdf-results.ts +1481 -0
- package/dist/ts/hdf-system.d.ts +609 -0
- package/dist/ts/hdf-system.js +102 -0
- package/dist/ts/hdf-system.ts +617 -0
- package/package.json +98 -0
- package/src/schemas/hdf-amendments.schema.json +97 -0
- package/src/schemas/hdf-baseline.schema.json +190 -0
- package/src/schemas/hdf-comparison.schema.json +107 -0
- package/src/schemas/hdf-evidence-package.schema.json +227 -0
- package/src/schemas/hdf-plan.schema.json +92 -0
- package/src/schemas/hdf-results.schema.json +304 -0
- package/src/schemas/hdf-system.schema.json +136 -0
- package/src/schemas/primitives/amendments.schema.json +155 -0
- package/src/schemas/primitives/common.schema.json +814 -0
- package/src/schemas/primitives/comparison.schema.json +809 -0
- package/src/schemas/primitives/component.schema.json +518 -0
- package/src/schemas/primitives/data-flow.schema.json +158 -0
- package/src/schemas/primitives/extensions.schema.json +342 -0
- package/src/schemas/primitives/parameter.schema.json +128 -0
- package/src/schemas/primitives/plan.schema.json +128 -0
- package/src/schemas/primitives/platform.schema.json +32 -0
- package/src/schemas/primitives/result.schema.json +133 -0
- package/src/schemas/primitives/runner.schema.json +83 -0
- package/src/schemas/primitives/statistics.schema.json +71 -0
- package/src/schemas/primitives/system.schema.json +132 -0
- package/src/schemas/primitives/target.schema.json +523 -0
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
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# @mitre/hdf-schema
|
|
2
|
+
|
|
3
|
+
JSON schemas and multi-language type definitions for **Heimdall Data Format (HDF)**.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
HDF is a standardized format for representing security assessment results. This package provides:
|
|
8
|
+
|
|
9
|
+
- **JSON Schemas** for validating HDF documents
|
|
10
|
+
- **Generated types** for TypeScript, Go, and Python
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @mitre/hdf-schema
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Schema Types
|
|
19
|
+
|
|
20
|
+
### HDF Results
|
|
21
|
+
|
|
22
|
+
Assessment results from running security checks against target systems. Contains:
|
|
23
|
+
|
|
24
|
+
- Target system information (hosts, containers, cloud accounts, etc.)
|
|
25
|
+
- Evaluated baselines with requirement results
|
|
26
|
+
- Pass/fail status for each check
|
|
27
|
+
- Statistics and timing data
|
|
28
|
+
|
|
29
|
+
### HDF Baseline
|
|
30
|
+
|
|
31
|
+
Security requirement definitions without results. Contains:
|
|
32
|
+
|
|
33
|
+
- Requirement metadata (title, description, severity)
|
|
34
|
+
- Check and fix instructions
|
|
35
|
+
- Framework mappings (NIST, CIS, etc.)
|
|
36
|
+
- Dependencies between requirements
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
### Validating Documents (TypeScript/JavaScript)
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import Ajv from 'ajv';
|
|
44
|
+
import hdfResultsSchema from '@mitre/hdf-schema/schemas/hdf-results.schema.json';
|
|
45
|
+
|
|
46
|
+
const ajv = new Ajv({ strict: false });
|
|
47
|
+
const validate = ajv.compile(hdfResultsSchema);
|
|
48
|
+
|
|
49
|
+
const isValid = validate(myDocument);
|
|
50
|
+
if (!isValid) {
|
|
51
|
+
console.error(validate.errors);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Using Generated Types (TypeScript)
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import type { HdfResults, HdfBaseline } from '@mitre/hdf-schema';
|
|
59
|
+
|
|
60
|
+
function processResults(results: HdfResults) {
|
|
61
|
+
for (const baseline of results.profiles) {
|
|
62
|
+
for (const requirement of baseline.controls) {
|
|
63
|
+
console.log(`${requirement.id}: ${requirement.results[0]?.status}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Using Generated Types (Go)
|
|
70
|
+
|
|
71
|
+
```go
|
|
72
|
+
import "github.com/mitre/hdf-libs/hdf-schema/dist/go/hdf"
|
|
73
|
+
|
|
74
|
+
func main() {
|
|
75
|
+
data := []byte(`{"platform": {...}, "profiles": [...]}`)
|
|
76
|
+
results, err := hdf.UnmarshalHdfResults(data)
|
|
77
|
+
if err != nil {
|
|
78
|
+
panic(err)
|
|
79
|
+
}
|
|
80
|
+
fmt.Println(results.Version)
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Using Generated Types (Python)
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from hdf_results import HdfResults
|
|
88
|
+
import json
|
|
89
|
+
|
|
90
|
+
with open('results.json') as f:
|
|
91
|
+
data = json.load(f)
|
|
92
|
+
results = HdfResults.from_dict(data)
|
|
93
|
+
print(results.version)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Schema Files
|
|
97
|
+
|
|
98
|
+
| File | Description |
|
|
99
|
+
|------|-------------|
|
|
100
|
+
| `src/schemas/hdf-results.schema.json` | Results schema (modular, uses $ref) |
|
|
101
|
+
| `src/schemas/hdf-baseline.schema.json` | Baseline schema (modular, uses $ref) |
|
|
102
|
+
| `src/schemas/primitives/*.schema.json` | Shared type definitions |
|
|
103
|
+
| `dist/schemas/hdf-results.schema.json` | Bundled results schema (self-contained) |
|
|
104
|
+
| `dist/schemas/hdf-baseline.schema.json` | Bundled baseline schema (self-contained) |
|
|
105
|
+
|
|
106
|
+
### Modular vs Bundled Schemas
|
|
107
|
+
|
|
108
|
+
**Modular schemas** (`src/schemas/`) use `$ref` to reference shared definitions from primitive files. Use these if your validator supports `$ref` resolution.
|
|
109
|
+
|
|
110
|
+
**Bundled schemas** (`dist/schemas/`) have all references inlined. Use these for tools that don't support `$ref` or for simpler integration.
|
|
111
|
+
|
|
112
|
+
## Generated Types
|
|
113
|
+
|
|
114
|
+
After building, types are available in:
|
|
115
|
+
|
|
116
|
+
| Language | Location |
|
|
117
|
+
|----------|----------|
|
|
118
|
+
| TypeScript | `dist/ts/hdf-results.ts`, `dist/ts/hdf-baseline.ts` |
|
|
119
|
+
| Go | `dist/go/hdf_results.go`, `dist/go/hdf_baseline.go` |
|
|
120
|
+
| Python | `dist/python/hdf_results.py`, `dist/python/hdf_baseline.py` |
|
|
121
|
+
|
|
122
|
+
## Development
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Install dependencies
|
|
126
|
+
pnpm install
|
|
127
|
+
|
|
128
|
+
# Run tests
|
|
129
|
+
pnpm test
|
|
130
|
+
|
|
131
|
+
# Build everything (schemas + types)
|
|
132
|
+
pnpm build
|
|
133
|
+
|
|
134
|
+
# Build only bundled schemas
|
|
135
|
+
pnpm build:schemas
|
|
136
|
+
|
|
137
|
+
# Build only generated types
|
|
138
|
+
pnpm build:types
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Schema Version
|
|
142
|
+
|
|
143
|
+
This package uses **JSON Schema draft/2020-12**.
|
package/dist/go/go.mod
ADDED