@mitre/hdf-parsers 3.7.2 → 3.8.0-next.42532249979.1

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/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { HDFBaseline, HDFComparison, HDFEvidencePackage, HDFPlan, HDFResults, HDFSystem } from "@mitre/hdf-schema";
2
- //#region typescript/flatten.d.ts
3
2
  interface FlattenResult {
4
3
  results: HDFResults;
5
4
  metadata: FlattenMetadata;
@@ -29,8 +28,6 @@ interface BaselineMerge {
29
28
  * @returns FlattenResult with flattened data and merge metadata
30
29
  */
31
30
  export declare function flattenOverlays(results: HDFResults): FlattenResult;
32
- //#endregion
33
- //#region typescript/saf-supplement.d.ts
34
31
  interface SafNormalizeResult {
35
32
  /** The normalized JSON string (byte-identical to the input when nothing was rewritten). */
36
33
  output: string;
@@ -49,8 +46,6 @@ interface SafNormalizeResult {
49
46
  * valid component type is left in place (with a warning) for the schema to reject.
50
47
  */
51
48
  export declare function normalizeSafSupplement(input: string): SafNormalizeResult;
52
- //#endregion
53
- //#region typescript/index.d.ts
54
49
  /**
55
50
  * Append Z (treat as UTC) to bare ISO timestamps in a JSON string so they
56
51
  * pass schema validation. Exported so other workspace packages can use the
@@ -104,6 +99,5 @@ export declare function parseComparison(input: string | Uint8Array): ParseResult
104
99
  * @returns ParseResult with parsed data, type indicator, or error
105
100
  */
106
101
  export declare function parse(input: string | Uint8Array): ParseResult<HDFResults | HDFBaseline | HDFSystem | HDFPlan | HDFEvidencePackage | HDFComparison>;
107
- //#endregion
108
102
  export type { BaselineMerge, FlattenMetadata, FlattenResult, SafNormalizeResult };
109
103
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../typescript/flatten.ts","../typescript/saf-supplement.ts","../typescript/index.ts"],"mappings":";;UAIiB;EACf,SAAS;EACT,UAAU;;UAGK;EACf;EACA;EACA,QAAQ;EACR;;UAGe;EACf;EACA;EACA;EACA;EACA;;;;;;;;;;;;;wBA2Hc,gBAAgB,SAAS,aAAa;;;UC9HrC;;EAEf;;EAEA;;;;;;;;;;;;;wBAkBc,uBAAuB,gBAAgB;;;;;;;;;wBCNvC,oBAAoB;;;;iBAOnB,YAAY;EAC3B;EACA,OAAO;EACP;EACA;;;EAGA;;;;;;;wBAQc,aAAa,gBAAgB,aAAa,YAAY;;;;;;wBAwDtD,cAAc,gBAAgB,aAAa,YAAY;;;;wBA6CvD,YAAY,gBAAgB,aAAa,YAAY;;;;wBAsBrD,UAAU,gBAAgB,aAAa,YAAY;;;;wBAsBnD,qBAAqB,gBAAgB,aAAa,YAAY;;;;wBAsB9D,gBAAgB,gBAAgB,aAAa,YAAY;;;;;;wBAwBzD,MACd,gBAAgB,aACf,YAAY,aAAa,cAAc,YAAY,UAAU,qBAAqB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../typescript/flatten.ts","../typescript/saf-supplement.ts","../typescript/index.ts"],"mappings":";UAIiB;EACf,SAAS;EACT,UAAU;;UAGK;EACf;EACA;EACA,QAAQ;EACR;;UAGe;EACf;EACA;EACA;EACA;EACA;;;;;;;;;;;;;wBA2Hc,gBAAgB,SAAS,aAAa;UC9HrC;;EAEf;;EAEA;;;;;;;;;;;;;wBAkBc,uBAAuB,gBAAgB;;;;;;;wBCNvC,oBAAoB;;;;iBAOnB,YAAY;EAC3B;EACA,OAAO;EACP;EACA;;;EAGA;;;;;;;wBAQc,aAAa,gBAAgB,aAAa,YAAY;;;;;;wBAwDtD,cAAc,gBAAgB,aAAa,YAAY;;;;wBA6CvD,YAAY,gBAAgB,aAAa,YAAY;;;;wBAsBrD,UAAU,gBAAgB,aAAa,YAAY;;;;wBAsBnD,qBAAqB,gBAAgB,aAAa,YAAY;;;;wBAsB9D,gBAAgB,gBAAgB,aAAa,YAAY;;;;;;wBAwBzD,MACd,gBAAgB,aACf,YAAY,aAAa,cAAc,YAAY,UAAU,qBAAqB"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { validate, validateBaseline, validateComparison, validateEvidencePackage, validatePlan, validateResults, validateSystem } from "@mitre/hdf-validators";
2
- //#region typescript/flatten.ts
2
+ // typescript/flatten.ts
3
3
  /** BFS from root, returns names in top-down order. Cycle-safe. */
4
4
  function collectTree(root, childrenMap) {
5
5
  const order = [];
@@ -166,8 +166,7 @@ function flattenOverlays(results) {
166
166
  }
167
167
  };
168
168
  }
169
- //#endregion
170
- //#region typescript/saf-supplement.ts
169
+ // typescript/saf-supplement.ts
171
170
  const SAF_TARGET_DEPRECATION = "deprecated: top-level 'target' (saf supplement target write) was normalized into components[]; emit a component directly — this compatibility shim will be removed in a future release";
172
171
  const SAF_PROVENANCE_DEPRECATION = "deprecated: top-level 'passthrough' was normalized into extensions.passthrough; write provenance under extensions — this compatibility shim will be removed in a future release";
173
172
  const VALID_COMPONENT_TYPES = /* @__PURE__ */ new Set([
@@ -219,8 +218,8 @@ function normalizeSafSupplement(input) {
219
218
  else warnings.push(`${SAF_TARGET_DEPRECATION} (target.type is not a recognized component type; left for schema validation)`);
220
219
  }
221
220
  if ("passthrough" in doc) {
222
- rewritePassthrough(doc);
223
- warnings.push(SAF_PROVENANCE_DEPRECATION);
221
+ const relocations = rewritePassthrough(doc);
222
+ warnings.push(SAF_PROVENANCE_DEPRECATION, ...relocations);
224
223
  }
225
224
  return {
226
225
  output: JSON.stringify(doc),
@@ -264,16 +263,44 @@ function applyBoundaryLabel(c, boundary) {
264
263
  if (!("boundary" in labels)) labels.boundary = boundary;
265
264
  c.labels = labels;
266
265
  }
267
- /** Move the legacy top-level `passthrough` under extensions.passthrough, merging
268
- * into any existing extensions without clobbering other keys. */
266
+ /** The only keys `extensions` admits. Anything else a producer wrote beside them
267
+ * is exactly what `passthrough` is for. */
268
+ const EXTENSIONS_DEFINED_MEMBERS = /* @__PURE__ */ new Set(["passthrough", "rawSourceArtifacts"]);
269
+ /** Move the legacy top-level `passthrough` under extensions.passthrough, then
270
+ * relocate any other key left beside it into passthrough too: `extensions` is a
271
+ * closed object, so a sibling it does not define makes the document invalid.
272
+ * Returns a warning per relocated or undroppable key. */
269
273
  function rewritePassthrough(doc) {
270
274
  const ext = isObject(doc.extensions) ? doc.extensions : {};
271
275
  if (!("passthrough" in ext)) ext.passthrough = doc.passthrough;
272
276
  doc.extensions = ext;
273
277
  delete doc.passthrough;
278
+ return relocateExtensionSiblings(ext);
274
279
  }
275
- //#endregion
276
- //#region typescript/index.ts
280
+ /** Move undefined `extensions` keys into extensions.passthrough. Without this, a
281
+ * legacy document carrying something like extensions.audit normalizes into a
282
+ * document the closed `extensions` rejects. */
283
+ function relocateExtensionSiblings(ext) {
284
+ const warnings = [];
285
+ const siblings = Object.keys(ext).filter((k) => !EXTENSIONS_DEFINED_MEMBERS.has(k));
286
+ if (siblings.length === 0) return warnings;
287
+ if ("passthrough" in ext && !isObject(ext.passthrough)) {
288
+ for (const k of siblings) warnings.push(`extensions.${k} could not be relocated because extensions.passthrough is not an object; \`extensions\` is closed, so this document will not validate`);
289
+ return warnings;
290
+ }
291
+ const pt = isObject(ext.passthrough) ? ext.passthrough : {};
292
+ for (const k of siblings) {
293
+ if (k in pt) warnings.push(`extensions.${k} was dropped: \`extensions\` is closed and extensions.passthrough.${k} already holds a value`);
294
+ else {
295
+ pt[k] = ext[k];
296
+ warnings.push(`extensions.${k} was moved into extensions.passthrough.${k}; \`extensions\` accepts only its defined members`);
297
+ }
298
+ delete ext[k];
299
+ }
300
+ ext.passthrough = pt;
301
+ return warnings;
302
+ }
303
+ // typescript/index.ts
277
304
  const NO_TZ_TIMESTAMP_REGEX = /"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?)"/g;
278
305
  /**
279
306
  * Append Z (treat as UTC) to bare ISO timestamps in a JSON string so they
@@ -520,7 +547,6 @@ function parse(input) {
520
547
  error: "Unable to determine HDF document type"
521
548
  };
522
549
  }
523
- //#endregion
524
550
  export { flattenOverlays, normalizeSafSupplement, normalizeTimestamps, parse, parseBaseline, parseComparison, parseEvidencePackage, parsePlan, parseResults, parseSystem };
525
551
 
526
552
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["autoValidate"],"sources":["../typescript/flatten.ts","../typescript/saf-supplement.ts","../typescript/index.ts"],"sourcesContent":["import type { HDFResults, EvaluatedBaseline, EvaluatedRequirement } from '@mitre/hdf-schema';\n\n// ── Public Types ────────────────────────────────────────────\n\nexport interface FlattenResult {\n results: HDFResults;\n metadata: FlattenMetadata;\n}\n\nexport interface FlattenMetadata {\n originalBaselineCount: number;\n flattenedBaselineCount: number;\n merges: BaselineMerge[];\n warnings: string[];\n}\n\nexport interface BaselineMerge {\n rootBaseline: string;\n absorbedBaselines: string[];\n controlsBefore: number;\n controlsAfter: number;\n pattern: 'deep' | 'wide' | 'hybrid';\n}\n\n// ── Internal Helpers ───────────────────────────────────────\n\n/** BFS from root, returns names in top-down order. Cycle-safe. */\nfunction collectTree(root: string, childrenMap: Map<string, string[]>): string[] {\n const order: string[] = [];\n const seen = new Set<string>();\n const queue = [root];\n while (queue.length > 0) {\n const name = queue.shift()!;\n if (seen.has(name)) continue;\n seen.add(name);\n order.push(name);\n for (const child of (childrenMap.get(name) || [])) {\n queue.push(child);\n }\n }\n return order;\n}\n\n/** Classify merge pattern based on tree shape */\nfunction detectPattern(root: string, childrenMap: Map<string, string[]>): 'deep' | 'wide' | 'hybrid' {\n const rootChildren = childrenMap.get(root) || [];\n if (rootChildren.length <= 1) {\n return 'deep';\n }\n for (const child of rootChildren) {\n if ((childrenMap.get(child) || []).length > 0) {\n return 'hybrid';\n }\n }\n return 'wide';\n}\n\n/** Merge incoming requirement fields onto existing */\nfunction mergeRequirement(\n existing: EvaluatedRequirement,\n incoming: EvaluatedRequirement\n): EvaluatedRequirement {\n const result: EvaluatedRequirement = { ...existing };\n\n // Impact: incoming always wins (required field, always present)\n result.impact = incoming.impact;\n\n // Results: keep whichever is non-empty (base has them, overlay doesn't)\n if (incoming.results && incoming.results.length > 0) {\n result.results = incoming.results;\n }\n\n // Code: incoming wins if non-empty\n if (incoming.code && incoming.code.trim() !== '') {\n result.code = incoming.code;\n }\n\n // Tags: shallow merge (incoming keys override)\n if (incoming.tags) {\n result.tags = { ...existing.tags, ...incoming.tags };\n }\n\n // Severity: incoming wins if present, else keep existing\n if (incoming.severity !== undefined) {\n result.severity = incoming.severity;\n }\n\n // EffectiveStatus: incoming wins only if it has results (otherwise its\n // effectiveStatus is a computed artifact from empty results, not intentional).\n // Overlays typically have empty results — the base has the real test results.\n if (incoming.effectiveStatus !== undefined && incoming.results && incoming.results.length > 0) {\n result.effectiveStatus = incoming.effectiveStatus;\n }\n\n // Descriptions: merge by label (incoming overrides same label)\n if (incoming.descriptions && incoming.descriptions.length > 0) {\n const descMap = new Map(\n (existing.descriptions || []).map(d => [d.label, d])\n );\n for (const d of incoming.descriptions) {\n descMap.set(d.label, d);\n }\n result.descriptions = [...descMap.values()];\n }\n\n return result;\n}\n\n/**\n * Resolve parentBaseline for a baseline.\n * InSpec parent_profile can use depends-name aliases (e.g., 'k8s' instead of\n * 'k8s-node-stig-baseline'). When the value isn't a direct profile name,\n * find who depends on this baseline — that's the actual parent.\n */\nfunction resolveParentBaseline(\n b: EvaluatedBaseline,\n byName: Map<string, EvaluatedBaseline>,\n allBaselines: EvaluatedBaseline[]\n): string | undefined {\n if (!b.parentBaseline) return undefined;\n if (byName.has(b.parentBaseline)) return b.parentBaseline;\n\n // Alias resolution: find the profile whose depends array includes this baseline\n for (const candidate of allBaselines) {\n if (candidate.depends?.some((d) => d.name === b.name)) {\n return candidate.name;\n }\n }\n return undefined; // orphan\n}\n\n// ── Public API ──────────────────────────────────────────────\n\n/**\n * Flatten overlay/wrapper baselines in an HDF Results document.\n *\n * Handles:\n * - Deep nesting (overlay chains with shared control IDs via parentBaseline)\n * - Wide nesting (wrapper profiles aggregating independent bases)\n * - Hybrid (both patterns in one document)\n *\n * @param results - Parsed HDF Results (from parseResults() or equivalent)\n * @returns FlattenResult with flattened data and merge metadata\n */\nexport function flattenOverlays(results: HDFResults): FlattenResult {\n const { baselines } = results;\n const warnings: string[] = [];\n const merges: BaselineMerge[] = [];\n\n if (!baselines || baselines.length === 0) {\n return {\n results: { ...results, baselines: [] },\n metadata: {\n originalBaselineCount: 0,\n flattenedBaselineCount: 0,\n merges: [],\n warnings: [],\n },\n };\n }\n\n // Index baselines by name\n const byName = new Map<string, EvaluatedBaseline>();\n for (const b of baselines) {\n if (byName.has(b.name)) {\n warnings.push(`Duplicate baseline name \"${b.name}\" — later entry overwrites earlier`);\n }\n byName.set(b.name, b);\n }\n\n // Resolve parentBaseline aliases and build parent map\n const resolvedParent = new Map<string, string | undefined>();\n for (const b of baselines) {\n const parent = resolveParentBaseline(b, byName, baselines);\n resolvedParent.set(b.name, parent);\n if (b.parentBaseline && !parent) {\n warnings.push(\n `Baseline \"${b.name}\" references nonexistent parent \"${b.parentBaseline}\"`\n );\n }\n }\n\n // Build parent → children adjacency using resolved parents\n const childrenMap = new Map<string, string[]>();\n for (const b of baselines) {\n const parent = resolvedParent.get(b.name);\n if (parent) {\n const list = childrenMap.get(parent) || [];\n list.push(b.name);\n childrenMap.set(parent, list);\n }\n }\n\n // Find roots: no resolved parent\n const roots: string[] = [];\n const visited = new Set<string>();\n\n for (const b of baselines) {\n if (!resolvedParent.get(b.name)) {\n roots.push(b.name);\n }\n }\n\n // Mark reachable from roots (iterative DFS to avoid stack overflow on deep trees)\n function markReachable(start: string): void {\n const stack = [start];\n while (stack.length > 0) {\n const name = stack.pop()!;\n if (visited.has(name)) continue;\n visited.add(name);\n const children = childrenMap.get(name);\n if (children) {\n for (const child of children) {\n stack.push(child);\n }\n }\n }\n }\n for (const r of roots) {\n markReachable(r);\n }\n\n // Detect cycles: unvisited baselines are in cycles\n for (const b of baselines) {\n if (!visited.has(b.name)) {\n warnings.push(`Circular parentBaseline detected involving \"${b.name}\"`);\n roots.push(b.name);\n markReachable(b.name);\n }\n }\n\n // Process each root tree\n const flatBaselines: EvaluatedBaseline[] = [];\n\n for (const rootName of roots) {\n const root = byName.get(rootName)!;\n const treeNames = collectTree(rootName, childrenMap);\n\n if (treeNames.length === 1) {\n // Standalone baseline — pass through unchanged (preserve depends)\n flatBaselines.push(root);\n continue;\n }\n\n // Bottom-up order: reverse top-down BFS\n const bottomUp = [...treeNames].reverse();\n\n // Merge requirements across the tree\n const merged = new Map<string, EvaluatedRequirement>();\n let controlsBefore = 0;\n const absorbed: string[] = [];\n\n for (const name of bottomUp) {\n const b = byName.get(name)!;\n controlsBefore += b.requirements.length;\n if (name !== rootName) {\n absorbed.push(name);\n }\n for (const req of b.requirements) {\n if (merged.has(req.id)) {\n merged.set(req.id, mergeRequirement(merged.get(req.id)!, req));\n } else {\n merged.set(req.id, { ...req });\n }\n }\n }\n\n const mergedReqs = [...merged.values()];\n const pattern = detectPattern(rootName, childrenMap);\n\n merges.push({\n rootBaseline: rootName,\n absorbedBaselines: absorbed,\n controlsBefore,\n controlsAfter: mergedReqs.length,\n pattern,\n });\n\n const out: EvaluatedBaseline = {\n ...root,\n requirements: mergedReqs,\n };\n delete out.parentBaseline;\n delete out.depends;\n flatBaselines.push(out);\n }\n\n return {\n results: { ...results, baselines: flatBaselines },\n metadata: {\n originalBaselineCount: baselines.length,\n flattenedBaselineCount: flatBaselines.length,\n merges,\n warnings,\n },\n };\n}\n","// Backwards-compatible normalization of legacy SAF-supplement top-level keys\n// (`target`, `passthrough`) into v3-native carriers, run before schema\n// validation. Mirrors the Go side at hdf-parsers/go/saf_supplement.go — the two\n// are pinned against a shared legacy-in/v3-out fixture pair.\n\nconst SAF_TARGET_DEPRECATION =\n \"deprecated: top-level 'target' (saf supplement target write) was normalized into components[]; emit a component directly — this compatibility shim will be removed in a future release\";\nconst SAF_PROVENANCE_DEPRECATION =\n \"deprecated: top-level 'passthrough' was normalized into extensions.passthrough; write provenance under extensions — this compatibility shim will be removed in a future release\";\n\n// v3 component/target types. Kept in sync with the schema's Target_Type enum; an\n// unknown type is left for the schema to reject rather than guessed.\nconst VALID_COMPONENT_TYPES = new Set([\n 'aiModel', 'application', 'artifact', 'cloudAccount', 'cloudResource',\n 'containerImage', 'containerInstance', 'containerPlatform', 'database',\n 'dataset', 'host', 'network', 'repository',\n]);\n\nexport interface SafNormalizeResult {\n /** The normalized JSON string (byte-identical to the input when nothing was rewritten). */\n output: string;\n /** One deprecation warning per rewritten legacy key. */\n warnings: string[];\n}\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n\n/**\n * Rewrite the legacy SAF-supplement top-level keys into v3-native carriers so a\n * SAF-produced document becomes valid v3 before schema validation: `target` → a\n * components[] entry (type validated; id → name and, for cloudAccount, accountId;\n * boundary → labels.boundary; merged into a matching existing component rather\n * than duplicated); `passthrough` → extensions.passthrough.\n *\n * Deliberately narrow: input that is not a JSON object, or carries neither legacy\n * key, is returned BYTE-IDENTICAL with no warnings. A target whose type is not a\n * valid component type is left in place (with a warning) for the schema to reject.\n */\nexport function normalizeSafSupplement(input: string): SafNormalizeResult {\n let doc: unknown;\n try {\n doc = JSON.parse(input);\n } catch {\n return { output: input, warnings: [] }; // not JSON — let the validator surface it\n }\n if (!isObject(doc) || (!('target' in doc) && !('passthrough' in doc))) {\n return { output: input, warnings: [] }; // no legacy keys — byte-identical\n }\n\n const warnings: string[] = [];\n\n if ('target' in doc) {\n if (rewriteTarget(doc)) {\n warnings.push(SAF_TARGET_DEPRECATION);\n } else {\n warnings.push(\n `${SAF_TARGET_DEPRECATION} (target.type is not a recognized component type; left for schema validation)`,\n );\n }\n }\n\n if ('passthrough' in doc) {\n rewritePassthrough(doc);\n warnings.push(SAF_PROVENANCE_DEPRECATION);\n }\n\n return { output: JSON.stringify(doc), warnings };\n}\n\n/** Lift a legacy top-level `target` object into components[]; returns false\n * (leaving `target` in place) when it is not an object or its type is invalid. */\nfunction rewriteTarget(doc: Record<string, unknown>): boolean {\n const tgt = doc.target;\n if (!isObject(tgt)) return false;\n const typ = typeof tgt.type === 'string' ? tgt.type : '';\n if (!VALID_COMPONENT_TYPES.has(typ)) return false;\n const id = typeof tgt.id === 'string' ? tgt.id : '';\n const boundary = typeof tgt.boundary === 'string' ? tgt.boundary : '';\n\n const comps: unknown[] = Array.isArray(doc.components) ? doc.components : [];\n\n let merged = false;\n for (const c of comps) {\n if (isObject(c) && c.name === id && c.type === typ) {\n applyBoundaryLabel(c, boundary);\n merged = true;\n break;\n }\n }\n if (!merged) {\n const c: Record<string, unknown> = { type: typ, name: id };\n if (typ === 'cloudAccount') c.accountId = id;\n applyBoundaryLabel(c, boundary);\n comps.push(c);\n }\n doc.components = comps;\n delete doc.target;\n return true;\n}\n\n/** Record the legacy target.boundary as a component label (the deferred\n * first-class-field decision — ADR-0015). No-op for an empty boundary. */\nfunction applyBoundaryLabel(c: Record<string, unknown>, boundary: string): void {\n if (boundary === '') return;\n const labels = isObject(c.labels) ? c.labels : {};\n if (!('boundary' in labels)) labels.boundary = boundary;\n c.labels = labels;\n}\n\n/** Move the legacy top-level `passthrough` under extensions.passthrough, merging\n * into any existing extensions without clobbering other keys. */\nfunction rewritePassthrough(doc: Record<string, unknown>): void {\n const ext = isObject(doc.extensions) ? doc.extensions : {};\n if (!('passthrough' in ext)) ext.passthrough = doc.passthrough;\n doc.extensions = ext;\n delete doc.passthrough;\n}\n","import type {\n HDFResults,\n HDFBaseline,\n HDFSystem,\n HDFPlan,\n HDFEvidencePackage,\n HDFComparison,\n} from '@mitre/hdf-schema';\nexport { flattenOverlays } from './flatten.js';\nexport type { FlattenResult, FlattenMetadata, BaselineMerge } from './flatten.js';\nimport { normalizeSafSupplement } from './saf-supplement.js';\nexport { normalizeSafSupplement } from './saf-supplement.js';\nexport type { SafNormalizeResult } from './saf-supplement.js';\nimport {\n validateResults,\n validateBaseline,\n validateSystem,\n validatePlan,\n validateEvidencePackage,\n validateComparison,\n validate as autoValidate,\n} from '@mitre/hdf-validators';\n\n// JSON-quoted ISO 8601 timestamp with no trailing timezone — InSpec emits\n// these (e.g. \"2026-03-25T22:56:27.736808\"). ajv-formats requires RFC 3339\n// for `date-time` and rejects them.\nconst NO_TZ_TIMESTAMP_REGEX = /\"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?)\"/g;\n\n/**\n * Append Z (treat as UTC) to bare ISO timestamps in a JSON string so they\n * pass schema validation. Exported so other workspace packages can use the\n * same regex instead of re-implementing it. Matches the Go side at\n * hdf-parsers/go/parsers.go.\n */\nexport function normalizeTimestamps(input: string): string {\n return input.replace(NO_TZ_TIMESTAMP_REGEX, '\"$1Z\"');\n}\n\n/**\n * Result of parsing operation\n */\nexport interface ParseResult<T> {\n success: boolean;\n data?: T;\n error?: string;\n type?: 'results' | 'baseline' | 'system' | 'plan' | 'evidencePackage' | 'comparison';\n /** Non-fatal notices from pre-validation normalization (e.g. a legacy\n * SAF-supplement shape rewritten to v3-native); callers surface these. */\n warnings?: string[];\n}\n\n/**\n * Parse HDF Results document from string or bytes\n * @param input - JSON string or Uint8Array to parse\n * @returns ParseResult with parsed data or error\n */\nexport function parseResults(input: string | Uint8Array): ParseResult<HDFResults> {\n // Convert Uint8Array to string if needed\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n // Rewrite legacy SAF-supplement top-level keys (target/passthrough) into\n // v3-native carriers BEFORE validation, so a SAF-produced document is accepted\n // (ajv enforces unevaluatedProperties) with its attribution preserved. Sibling\n // to normalizeTimestamps.\n const { output: jsonStr, warnings } = normalizeSafSupplement(normalizeTimestamps(decoded));\n\n // Check for empty input\n if (jsonStr.trim().length === 0) {\n return {\n success: false,\n error: 'Input is empty'\n };\n }\n\n // Parse JSON\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return {\n success: false,\n error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}`\n };\n }\n\n // JSON.parse already rejects trailing garbage (it throws on the first\n // non-whitespace byte after the root value), so the catch above covers\n // that case. A prior length-compare heuristic here false-positived on\n // complex real-world inputs (e.g. `0.70` parsed as `0.7` would re-\n // serialize to a different length) — caught by the cross-language\n // parser parity test in typescript/parse-equivalence.test.ts.\n\n // Validate against schema\n const validationResult = validateResults(data);\n if (!validationResult.valid) {\n return {\n success: false,\n error: `Schema validation failed: ${validationResult.getErrorMessage()}`\n };\n }\n\n return {\n success: true,\n data: data as HDFResults,\n warnings: warnings.length > 0 ? warnings : undefined\n };\n}\n\n/**\n * Parse HDF Baseline document from string or bytes\n * @param input - JSON string or Uint8Array to parse\n * @returns ParseResult with parsed data or error\n */\nexport function parseBaseline(input: string | Uint8Array): ParseResult<HDFBaseline> {\n // Convert Uint8Array to string if needed\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n\n // Check for empty input\n if (jsonStr.trim().length === 0) {\n return {\n success: false,\n error: 'Input is empty'\n };\n }\n\n // Parse JSON\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return {\n success: false,\n error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}`\n };\n }\n\n // Trailing garbage already caught by the JSON.parse catch above; see\n // parseResults for the full rationale.\n\n // Validate against schema\n const validationResult = validateBaseline(data);\n if (!validationResult.valid) {\n return {\n success: false,\n error: `Schema validation failed: ${validationResult.getErrorMessage()}`\n };\n }\n\n return {\n success: true,\n data: data as HDFBaseline\n };\n}\n\n/**\n * Parse HDF System document from string or bytes\n */\nexport function parseSystem(input: string | Uint8Array): ParseResult<HDFSystem> {\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n if (jsonStr.trim().length === 0) {\n return { success: false, error: 'Input is empty' };\n }\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return { success: false, error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}` };\n }\n const validationResult = validateSystem(data);\n if (!validationResult.valid) {\n return { success: false, error: `Schema validation failed: ${validationResult.getErrorMessage()}` };\n }\n return { success: true, data: data as HDFSystem };\n}\n\n/**\n * Parse HDF Plan document from string or bytes\n */\nexport function parsePlan(input: string | Uint8Array): ParseResult<HDFPlan> {\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n if (jsonStr.trim().length === 0) {\n return { success: false, error: 'Input is empty' };\n }\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return { success: false, error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}` };\n }\n const validationResult = validatePlan(data);\n if (!validationResult.valid) {\n return { success: false, error: `Schema validation failed: ${validationResult.getErrorMessage()}` };\n }\n return { success: true, data: data as HDFPlan };\n}\n\n/**\n * Parse HDF Evidence Package document from string or bytes\n */\nexport function parseEvidencePackage(input: string | Uint8Array): ParseResult<HDFEvidencePackage> {\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n if (jsonStr.trim().length === 0) {\n return { success: false, error: 'Input is empty' };\n }\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return { success: false, error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}` };\n }\n const validationResult = validateEvidencePackage(data);\n if (!validationResult.valid) {\n return { success: false, error: `Schema validation failed: ${validationResult.getErrorMessage()}` };\n }\n return { success: true, data: data as HDFEvidencePackage };\n}\n\n/**\n * Parse HDF Comparison document from string or bytes\n */\nexport function parseComparison(input: string | Uint8Array): ParseResult<HDFComparison> {\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n if (jsonStr.trim().length === 0) {\n return { success: false, error: 'Input is empty' };\n }\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return { success: false, error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}` };\n }\n const validationResult = validateComparison(data);\n if (!validationResult.valid) {\n return { success: false, error: `Schema validation failed: ${validationResult.getErrorMessage()}` };\n }\n return { success: true, data: data as HDFComparison };\n}\n\n/**\n * Parse HDF document with auto-detection of type\n * @param input - JSON string or Uint8Array to parse\n * @returns ParseResult with parsed data, type indicator, or error\n */\nexport function parse(\n input: string | Uint8Array,\n): ParseResult<HDFResults | HDFBaseline | HDFSystem | HDFPlan | HDFEvidencePackage | HDFComparison> {\n // Convert Uint8Array to string if needed\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n\n // Check for empty input\n if (jsonStr.trim().length === 0) {\n return {\n success: false,\n error: 'Input is empty'\n };\n }\n\n // Parse JSON\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return {\n success: false,\n error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}`\n };\n }\n\n // Trailing garbage already caught by the JSON.parse catch above; see\n // parseResults for the full rationale.\n\n // Auto-validate and detect type\n const validationResult = autoValidate(data);\n if (!validationResult.valid) {\n return {\n success: false,\n error: `Schema validation failed: ${validationResult.getErrorMessage()}`\n };\n }\n\n // Determine type based on structure\n if (typeof data === 'object' && data !== null) {\n const obj = data as Record<string, unknown>;\n\n // HDF Results has 'baselines' array at root\n if ('baselines' in obj) {\n return {\n success: true,\n data: data as HDFResults,\n type: 'results'\n };\n }\n\n // HDF Comparison has 'requirementDiffs' at root (unique discriminator)\n if ('requirementDiffs' in obj) {\n return { success: true, data: data as HDFComparison, type: 'comparison' };\n }\n\n // HDF Plan has 'assessments' at root\n if ('assessments' in obj) {\n return { success: true, data: data as HDFPlan, type: 'plan' };\n }\n\n // HDF Evidence Package has 'contents' at root\n if ('contents' in obj) {\n return { success: true, data: data as HDFEvidencePackage, type: 'evidencePackage' };\n }\n\n // HDF Baseline has 'name' and 'requirements' at root\n if ('name' in obj && 'requirements' in obj) {\n return {\n success: true,\n data: data as HDFBaseline,\n type: 'baseline'\n };\n }\n\n // HDF System has 'components' at root (Results' baselines check already ruled out)\n if ('components' in obj) {\n return { success: true, data: data as HDFSystem, type: 'system' };\n }\n }\n\n return {\n success: false,\n error: 'Unable to determine HDF document type'\n };\n}\n\n"],"mappings":";;;AA2BA,SAAS,YAAY,MAAc,aAA8C;CAC/E,MAAM,QAAkB,CAAC;CACzB,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,QAAQ,CAAC,IAAI;CACnB,OAAO,MAAM,SAAS,GAAG;EACvB,MAAM,OAAO,MAAM,MAAM;EACzB,IAAI,KAAK,IAAI,IAAI,GAAG;EACpB,KAAK,IAAI,IAAI;EACb,MAAM,KAAK,IAAI;EACf,KAAK,MAAM,SAAU,YAAY,IAAI,IAAI,KAAK,CAAC,GAC7C,MAAM,KAAK,KAAK;CAEpB;CACA,OAAO;AACT;;AAGA,SAAS,cAAc,MAAc,aAAgE;CACnG,MAAM,eAAe,YAAY,IAAI,IAAI,KAAK,CAAC;CAC/C,IAAI,aAAa,UAAU,GACzB,OAAO;CAET,KAAK,MAAM,SAAS,cAClB,KAAK,YAAY,IAAI,KAAK,KAAK,CAAC,EAAA,CAAG,SAAS,GAC1C,OAAO;CAGX,OAAO;AACT;;AAGA,SAAS,iBACP,UACA,UACsB;CACtB,MAAM,SAA+B,EAAE,GAAG,SAAS;CAGnD,OAAO,SAAS,SAAS;CAGzB,IAAI,SAAS,WAAW,SAAS,QAAQ,SAAS,GAChD,OAAO,UAAU,SAAS;CAI5B,IAAI,SAAS,QAAQ,SAAS,KAAK,KAAK,MAAM,IAC5C,OAAO,OAAO,SAAS;CAIzB,IAAI,SAAS,MACX,OAAO,OAAO;EAAE,GAAG,SAAS;EAAM,GAAG,SAAS;CAAK;CAIrD,IAAI,SAAS,aAAa,KAAA,GACxB,OAAO,WAAW,SAAS;CAM7B,IAAI,SAAS,oBAAoB,KAAA,KAAa,SAAS,WAAW,SAAS,QAAQ,SAAS,GAC1F,OAAO,kBAAkB,S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AiB,OACpB,OAAO;EAAE,SAAS;EAAO,OAAO,6BAA6B,iBAAiB,gBAAgB;CAAI;CAEpG,OAAO;EAAE,SAAS;EAAY;CAAsB;AACtD;;;;;;AAOA,SAAgB,MACd,OACkG;CAGlG,MAAM,UAAU,oBADA,OAAO,UAAU,WAAW,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,CACvC;CAG3C,IAAI,QAAQ,KAAK,CAAC,CAAC,WAAW,GAC5B,OAAO;EACL,SAAS;EACT,OAAO;CACT;CAIF,IAAI;CACJ,IAAI;EACF,OAAO,KAAK,MAAM,OAAO;CAC3B,SAAS,KAAK;EACZ,OAAO;GACL,SAAS;GACT,OAAO,iBAAiB,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EACzE;CACF;CAMA,MAAM,mBAAmBA,SAAa,IAAI;CAC1C,IAAI,CAAC,iBAAiB,OACpB,OAAO;EACL,SAAS;EACT,OAAO,6BAA6B,iBAAiB,gBAAgB;CACvE;CAIF,IAAI,OAAO,SAAS,YAAY,SAAS,MAAM;EAC7C,MAAM,MAAM;EAGZ,IAAI,eAAe,KACjB,OAAO;GACL,SAAS;GACH;GACN,MAAM;EACR;EAIF,IAAI,sBAAsB,KACxB,OAAO;GAAE,SAAS;GAAY;GAAuB,MAAM;EAAa;EAI1E,IAAI,iBAAiB,KACnB,OAAO;GAAE,SAAS;GAAY;GAAiB,MAAM;EAAO;EAI9D,IAAI,cAAc,KAChB,OAAO;GAAE,SAAS;GAAY;GAA4B,MAAM;EAAkB;EAIpF,IAAI,UAAU,OAAO,kBAAkB,KACrC,OAAO;GACL,SAAS;GACH;GACN,MAAM;EACR;EAIF,IAAI,gBAAgB,KAClB,OAAO;GAAE,SAAS;GAAY;GAAmB,MAAM;EAAS;CAEpE;CAEA,OAAO;EACL,SAAS;EACT,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"index.js","names":["autoValidate"],"sources":["../typescript/flatten.ts","../typescript/saf-supplement.ts","../typescript/index.ts"],"sourcesContent":["import type { HDFResults, EvaluatedBaseline, EvaluatedRequirement } from '@mitre/hdf-schema';\n\n// ── Public Types ────────────────────────────────────────────\n\nexport interface FlattenResult {\n results: HDFResults;\n metadata: FlattenMetadata;\n}\n\nexport interface FlattenMetadata {\n originalBaselineCount: number;\n flattenedBaselineCount: number;\n merges: BaselineMerge[];\n warnings: string[];\n}\n\nexport interface BaselineMerge {\n rootBaseline: string;\n absorbedBaselines: string[];\n controlsBefore: number;\n controlsAfter: number;\n pattern: 'deep' | 'wide' | 'hybrid';\n}\n\n// ── Internal Helpers ───────────────────────────────────────\n\n/** BFS from root, returns names in top-down order. Cycle-safe. */\nfunction collectTree(root: string, childrenMap: Map<string, string[]>): string[] {\n const order: string[] = [];\n const seen = new Set<string>();\n const queue = [root];\n while (queue.length > 0) {\n const name = queue.shift()!;\n if (seen.has(name)) continue;\n seen.add(name);\n order.push(name);\n for (const child of (childrenMap.get(name) || [])) {\n queue.push(child);\n }\n }\n return order;\n}\n\n/** Classify merge pattern based on tree shape */\nfunction detectPattern(root: string, childrenMap: Map<string, string[]>): 'deep' | 'wide' | 'hybrid' {\n const rootChildren = childrenMap.get(root) || [];\n if (rootChildren.length <= 1) {\n return 'deep';\n }\n for (const child of rootChildren) {\n if ((childrenMap.get(child) || []).length > 0) {\n return 'hybrid';\n }\n }\n return 'wide';\n}\n\n/** Merge incoming requirement fields onto existing */\nfunction mergeRequirement(\n existing: EvaluatedRequirement,\n incoming: EvaluatedRequirement\n): EvaluatedRequirement {\n const result: EvaluatedRequirement = { ...existing };\n\n // Impact: incoming always wins (required field, always present)\n result.impact = incoming.impact;\n\n // Results: keep whichever is non-empty (base has them, overlay doesn't)\n if (incoming.results && incoming.results.length > 0) {\n result.results = incoming.results;\n }\n\n // Code: incoming wins if non-empty\n if (incoming.code && incoming.code.trim() !== '') {\n result.code = incoming.code;\n }\n\n // Tags: shallow merge (incoming keys override)\n if (incoming.tags) {\n result.tags = { ...existing.tags, ...incoming.tags };\n }\n\n // Severity: incoming wins if present, else keep existing\n if (incoming.severity !== undefined) {\n result.severity = incoming.severity;\n }\n\n // EffectiveStatus: incoming wins only if it has results (otherwise its\n // effectiveStatus is a computed artifact from empty results, not intentional).\n // Overlays typically have empty results — the base has the real test results.\n if (incoming.effectiveStatus !== undefined && incoming.results && incoming.results.length > 0) {\n result.effectiveStatus = incoming.effectiveStatus;\n }\n\n // Descriptions: merge by label (incoming overrides same label)\n if (incoming.descriptions && incoming.descriptions.length > 0) {\n const descMap = new Map(\n (existing.descriptions || []).map(d => [d.label, d])\n );\n for (const d of incoming.descriptions) {\n descMap.set(d.label, d);\n }\n result.descriptions = [...descMap.values()];\n }\n\n return result;\n}\n\n/**\n * Resolve parentBaseline for a baseline.\n * InSpec parent_profile can use depends-name aliases (e.g., 'k8s' instead of\n * 'k8s-node-stig-baseline'). When the value isn't a direct profile name,\n * find who depends on this baseline — that's the actual parent.\n */\nfunction resolveParentBaseline(\n b: EvaluatedBaseline,\n byName: Map<string, EvaluatedBaseline>,\n allBaselines: EvaluatedBaseline[]\n): string | undefined {\n if (!b.parentBaseline) return undefined;\n if (byName.has(b.parentBaseline)) return b.parentBaseline;\n\n // Alias resolution: find the profile whose depends array includes this baseline\n for (const candidate of allBaselines) {\n if (candidate.depends?.some((d) => d.name === b.name)) {\n return candidate.name;\n }\n }\n return undefined; // orphan\n}\n\n// ── Public API ──────────────────────────────────────────────\n\n/**\n * Flatten overlay/wrapper baselines in an HDF Results document.\n *\n * Handles:\n * - Deep nesting (overlay chains with shared control IDs via parentBaseline)\n * - Wide nesting (wrapper profiles aggregating independent bases)\n * - Hybrid (both patterns in one document)\n *\n * @param results - Parsed HDF Results (from parseResults() or equivalent)\n * @returns FlattenResult with flattened data and merge metadata\n */\nexport function flattenOverlays(results: HDFResults): FlattenResult {\n const { baselines } = results;\n const warnings: string[] = [];\n const merges: BaselineMerge[] = [];\n\n if (!baselines || baselines.length === 0) {\n return {\n results: { ...results, baselines: [] },\n metadata: {\n originalBaselineCount: 0,\n flattenedBaselineCount: 0,\n merges: [],\n warnings: [],\n },\n };\n }\n\n // Index baselines by name\n const byName = new Map<string, EvaluatedBaseline>();\n for (const b of baselines) {\n if (byName.has(b.name)) {\n warnings.push(`Duplicate baseline name \"${b.name}\" — later entry overwrites earlier`);\n }\n byName.set(b.name, b);\n }\n\n // Resolve parentBaseline aliases and build parent map\n const resolvedParent = new Map<string, string | undefined>();\n for (const b of baselines) {\n const parent = resolveParentBaseline(b, byName, baselines);\n resolvedParent.set(b.name, parent);\n if (b.parentBaseline && !parent) {\n warnings.push(\n `Baseline \"${b.name}\" references nonexistent parent \"${b.parentBaseline}\"`\n );\n }\n }\n\n // Build parent → children adjacency using resolved parents\n const childrenMap = new Map<string, string[]>();\n for (const b of baselines) {\n const parent = resolvedParent.get(b.name);\n if (parent) {\n const list = childrenMap.get(parent) || [];\n list.push(b.name);\n childrenMap.set(parent, list);\n }\n }\n\n // Find roots: no resolved parent\n const roots: string[] = [];\n const visited = new Set<string>();\n\n for (const b of baselines) {\n if (!resolvedParent.get(b.name)) {\n roots.push(b.name);\n }\n }\n\n // Mark reachable from roots (iterative DFS to avoid stack overflow on deep trees)\n function markReachable(start: string): void {\n const stack = [start];\n while (stack.length > 0) {\n const name = stack.pop()!;\n if (visited.has(name)) continue;\n visited.add(name);\n const children = childrenMap.get(name);\n if (children) {\n for (const child of children) {\n stack.push(child);\n }\n }\n }\n }\n for (const r of roots) {\n markReachable(r);\n }\n\n // Detect cycles: unvisited baselines are in cycles\n for (const b of baselines) {\n if (!visited.has(b.name)) {\n warnings.push(`Circular parentBaseline detected involving \"${b.name}\"`);\n roots.push(b.name);\n markReachable(b.name);\n }\n }\n\n // Process each root tree\n const flatBaselines: EvaluatedBaseline[] = [];\n\n for (const rootName of roots) {\n const root = byName.get(rootName)!;\n const treeNames = collectTree(rootName, childrenMap);\n\n if (treeNames.length === 1) {\n // Standalone baseline — pass through unchanged (preserve depends)\n flatBaselines.push(root);\n continue;\n }\n\n // Bottom-up order: reverse top-down BFS\n const bottomUp = [...treeNames].reverse();\n\n // Merge requirements across the tree\n const merged = new Map<string, EvaluatedRequirement>();\n let controlsBefore = 0;\n const absorbed: string[] = [];\n\n for (const name of bottomUp) {\n const b = byName.get(name)!;\n controlsBefore += b.requirements.length;\n if (name !== rootName) {\n absorbed.push(name);\n }\n for (const req of b.requirements) {\n if (merged.has(req.id)) {\n merged.set(req.id, mergeRequirement(merged.get(req.id)!, req));\n } else {\n merged.set(req.id, { ...req });\n }\n }\n }\n\n const mergedReqs = [...merged.values()];\n const pattern = detectPattern(rootName, childrenMap);\n\n merges.push({\n rootBaseline: rootName,\n absorbedBaselines: absorbed,\n controlsBefore,\n controlsAfter: mergedReqs.length,\n pattern,\n });\n\n const out: EvaluatedBaseline = {\n ...root,\n requirements: mergedReqs,\n };\n delete out.parentBaseline;\n delete out.depends;\n flatBaselines.push(out);\n }\n\n return {\n results: { ...results, baselines: flatBaselines },\n metadata: {\n originalBaselineCount: baselines.length,\n flattenedBaselineCount: flatBaselines.length,\n merges,\n warnings,\n },\n };\n}\n","// Backwards-compatible normalization of legacy SAF-supplement top-level keys\n// (`target`, `passthrough`) into v3-native carriers, run before schema\n// validation. Mirrors the Go side at hdf-parsers/go/saf_supplement.go — the two\n// are pinned against a shared legacy-in/v3-out fixture pair.\n\nconst SAF_TARGET_DEPRECATION =\n \"deprecated: top-level 'target' (saf supplement target write) was normalized into components[]; emit a component directly — this compatibility shim will be removed in a future release\";\nconst SAF_PROVENANCE_DEPRECATION =\n \"deprecated: top-level 'passthrough' was normalized into extensions.passthrough; write provenance under extensions — this compatibility shim will be removed in a future release\";\n\n// v3 component/target types. Kept in sync with the schema's Target_Type enum; an\n// unknown type is left for the schema to reject rather than guessed.\nconst VALID_COMPONENT_TYPES = new Set([\n 'aiModel', 'application', 'artifact', 'cloudAccount', 'cloudResource',\n 'containerImage', 'containerInstance', 'containerPlatform', 'database',\n 'dataset', 'host', 'network', 'repository',\n]);\n\nexport interface SafNormalizeResult {\n /** The normalized JSON string (byte-identical to the input when nothing was rewritten). */\n output: string;\n /** One deprecation warning per rewritten legacy key. */\n warnings: string[];\n}\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n\n/**\n * Rewrite the legacy SAF-supplement top-level keys into v3-native carriers so a\n * SAF-produced document becomes valid v3 before schema validation: `target` → a\n * components[] entry (type validated; id → name and, for cloudAccount, accountId;\n * boundary → labels.boundary; merged into a matching existing component rather\n * than duplicated); `passthrough` → extensions.passthrough.\n *\n * Deliberately narrow: input that is not a JSON object, or carries neither legacy\n * key, is returned BYTE-IDENTICAL with no warnings. A target whose type is not a\n * valid component type is left in place (with a warning) for the schema to reject.\n */\nexport function normalizeSafSupplement(input: string): SafNormalizeResult {\n let doc: unknown;\n try {\n doc = JSON.parse(input);\n } catch {\n return { output: input, warnings: [] }; // not JSON — let the validator surface it\n }\n if (!isObject(doc) || (!('target' in doc) && !('passthrough' in doc))) {\n return { output: input, warnings: [] }; // no legacy keys — byte-identical\n }\n\n const warnings: string[] = [];\n\n if ('target' in doc) {\n if (rewriteTarget(doc)) {\n warnings.push(SAF_TARGET_DEPRECATION);\n } else {\n warnings.push(\n `${SAF_TARGET_DEPRECATION} (target.type is not a recognized component type; left for schema validation)`,\n );\n }\n }\n\n if ('passthrough' in doc) {\n const relocations = rewritePassthrough(doc);\n warnings.push(SAF_PROVENANCE_DEPRECATION, ...relocations);\n }\n\n return { output: JSON.stringify(doc), warnings };\n}\n\n/** Lift a legacy top-level `target` object into components[]; returns false\n * (leaving `target` in place) when it is not an object or its type is invalid. */\nfunction rewriteTarget(doc: Record<string, unknown>): boolean {\n const tgt = doc.target;\n if (!isObject(tgt)) return false;\n const typ = typeof tgt.type === 'string' ? tgt.type : '';\n if (!VALID_COMPONENT_TYPES.has(typ)) return false;\n const id = typeof tgt.id === 'string' ? tgt.id : '';\n const boundary = typeof tgt.boundary === 'string' ? tgt.boundary : '';\n\n const comps: unknown[] = Array.isArray(doc.components) ? doc.components : [];\n\n let merged = false;\n for (const c of comps) {\n if (isObject(c) && c.name === id && c.type === typ) {\n applyBoundaryLabel(c, boundary);\n merged = true;\n break;\n }\n }\n if (!merged) {\n const c: Record<string, unknown> = { type: typ, name: id };\n if (typ === 'cloudAccount') c.accountId = id;\n applyBoundaryLabel(c, boundary);\n comps.push(c);\n }\n doc.components = comps;\n delete doc.target;\n return true;\n}\n\n/** Record the legacy target.boundary as a component label (the deferred\n * first-class-field decision — ADR-0015). No-op for an empty boundary. */\nfunction applyBoundaryLabel(c: Record<string, unknown>, boundary: string): void {\n if (boundary === '') return;\n const labels = isObject(c.labels) ? c.labels : {};\n if (!('boundary' in labels)) labels.boundary = boundary;\n c.labels = labels;\n}\n\n/** The only keys `extensions` admits. Anything else a producer wrote beside them\n * is exactly what `passthrough` is for. */\nconst EXTENSIONS_DEFINED_MEMBERS = new Set(['passthrough', 'rawSourceArtifacts']);\n\n/** Move the legacy top-level `passthrough` under extensions.passthrough, then\n * relocate any other key left beside it into passthrough too: `extensions` is a\n * closed object, so a sibling it does not define makes the document invalid.\n * Returns a warning per relocated or undroppable key. */\nfunction rewritePassthrough(doc: Record<string, unknown>): string[] {\n const ext = isObject(doc.extensions) ? doc.extensions : {};\n if (!('passthrough' in ext)) ext.passthrough = doc.passthrough;\n doc.extensions = ext;\n delete doc.passthrough;\n return relocateExtensionSiblings(ext);\n}\n\n/** Move undefined `extensions` keys into extensions.passthrough. Without this, a\n * legacy document carrying something like extensions.audit normalizes into a\n * document the closed `extensions` rejects. */\nfunction relocateExtensionSiblings(ext: Record<string, unknown>): string[] {\n const warnings: string[] = [];\n const siblings = Object.keys(ext).filter((k) => !EXTENSIONS_DEFINED_MEMBERS.has(k));\n if (siblings.length === 0) return warnings;\n\n if ('passthrough' in ext && !isObject(ext.passthrough)) {\n // Nothing can be merged into a non-object passthrough. Leave the document\n // alone and let the schema reject it rather than reshape data we cannot place.\n for (const k of siblings) {\n warnings.push(\n `extensions.${k} could not be relocated because extensions.passthrough is not an object; \\`extensions\\` is closed, so this document will not validate`,\n );\n }\n return warnings;\n }\n\n const pt = isObject(ext.passthrough) ? ext.passthrough : {};\n for (const k of siblings) {\n if (k in pt) {\n warnings.push(\n `extensions.${k} was dropped: \\`extensions\\` is closed and extensions.passthrough.${k} already holds a value`,\n );\n } else {\n pt[k] = ext[k];\n warnings.push(\n `extensions.${k} was moved into extensions.passthrough.${k}; \\`extensions\\` accepts only its defined members`,\n );\n }\n delete ext[k];\n }\n ext.passthrough = pt;\n return warnings;\n}\n","import type {\n HDFResults,\n HDFBaseline,\n HDFSystem,\n HDFPlan,\n HDFEvidencePackage,\n HDFComparison,\n} from '@mitre/hdf-schema';\nexport { flattenOverlays } from './flatten.js';\nexport type { FlattenResult, FlattenMetadata, BaselineMerge } from './flatten.js';\nimport { normalizeSafSupplement } from './saf-supplement.js';\nexport { normalizeSafSupplement } from './saf-supplement.js';\nexport type { SafNormalizeResult } from './saf-supplement.js';\nimport {\n validateResults,\n validateBaseline,\n validateSystem,\n validatePlan,\n validateEvidencePackage,\n validateComparison,\n validate as autoValidate,\n} from '@mitre/hdf-validators';\n\n// JSON-quoted ISO 8601 timestamp with no trailing timezone — InSpec emits\n// these (e.g. \"2026-03-25T22:56:27.736808\"). ajv-formats requires RFC 3339\n// for `date-time` and rejects them.\nconst NO_TZ_TIMESTAMP_REGEX = /\"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?)\"/g;\n\n/**\n * Append Z (treat as UTC) to bare ISO timestamps in a JSON string so they\n * pass schema validation. Exported so other workspace packages can use the\n * same regex instead of re-implementing it. Matches the Go side at\n * hdf-parsers/go/parsers.go.\n */\nexport function normalizeTimestamps(input: string): string {\n return input.replace(NO_TZ_TIMESTAMP_REGEX, '\"$1Z\"');\n}\n\n/**\n * Result of parsing operation\n */\nexport interface ParseResult<T> {\n success: boolean;\n data?: T;\n error?: string;\n type?: 'results' | 'baseline' | 'system' | 'plan' | 'evidencePackage' | 'comparison';\n /** Non-fatal notices from pre-validation normalization (e.g. a legacy\n * SAF-supplement shape rewritten to v3-native); callers surface these. */\n warnings?: string[];\n}\n\n/**\n * Parse HDF Results document from string or bytes\n * @param input - JSON string or Uint8Array to parse\n * @returns ParseResult with parsed data or error\n */\nexport function parseResults(input: string | Uint8Array): ParseResult<HDFResults> {\n // Convert Uint8Array to string if needed\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n // Rewrite legacy SAF-supplement top-level keys (target/passthrough) into\n // v3-native carriers BEFORE validation, so a SAF-produced document is accepted\n // (ajv enforces unevaluatedProperties) with its attribution preserved. Sibling\n // to normalizeTimestamps.\n const { output: jsonStr, warnings } = normalizeSafSupplement(normalizeTimestamps(decoded));\n\n // Check for empty input\n if (jsonStr.trim().length === 0) {\n return {\n success: false,\n error: 'Input is empty'\n };\n }\n\n // Parse JSON\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return {\n success: false,\n error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}`\n };\n }\n\n // JSON.parse already rejects trailing garbage (it throws on the first\n // non-whitespace byte after the root value), so the catch above covers\n // that case. A prior length-compare heuristic here false-positived on\n // complex real-world inputs (e.g. `0.70` parsed as `0.7` would re-\n // serialize to a different length) — caught by the cross-language\n // parser parity test in typescript/parse-equivalence.test.ts.\n\n // Validate against schema\n const validationResult = validateResults(data);\n if (!validationResult.valid) {\n return {\n success: false,\n error: `Schema validation failed: ${validationResult.getErrorMessage()}`\n };\n }\n\n return {\n success: true,\n data: data as HDFResults,\n warnings: warnings.length > 0 ? warnings : undefined\n };\n}\n\n/**\n * Parse HDF Baseline document from string or bytes\n * @param input - JSON string or Uint8Array to parse\n * @returns ParseResult with parsed data or error\n */\nexport function parseBaseline(input: string | Uint8Array): ParseResult<HDFBaseline> {\n // Convert Uint8Array to string if needed\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n\n // Check for empty input\n if (jsonStr.trim().length === 0) {\n return {\n success: false,\n error: 'Input is empty'\n };\n }\n\n // Parse JSON\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return {\n success: false,\n error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}`\n };\n }\n\n // Trailing garbage already caught by the JSON.parse catch above; see\n // parseResults for the full rationale.\n\n // Validate against schema\n const validationResult = validateBaseline(data);\n if (!validationResult.valid) {\n return {\n success: false,\n error: `Schema validation failed: ${validationResult.getErrorMessage()}`\n };\n }\n\n return {\n success: true,\n data: data as HDFBaseline\n };\n}\n\n/**\n * Parse HDF System document from string or bytes\n */\nexport function parseSystem(input: string | Uint8Array): ParseResult<HDFSystem> {\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n if (jsonStr.trim().length === 0) {\n return { success: false, error: 'Input is empty' };\n }\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return { success: false, error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}` };\n }\n const validationResult = validateSystem(data);\n if (!validationResult.valid) {\n return { success: false, error: `Schema validation failed: ${validationResult.getErrorMessage()}` };\n }\n return { success: true, data: data as HDFSystem };\n}\n\n/**\n * Parse HDF Plan document from string or bytes\n */\nexport function parsePlan(input: string | Uint8Array): ParseResult<HDFPlan> {\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n if (jsonStr.trim().length === 0) {\n return { success: false, error: 'Input is empty' };\n }\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return { success: false, error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}` };\n }\n const validationResult = validatePlan(data);\n if (!validationResult.valid) {\n return { success: false, error: `Schema validation failed: ${validationResult.getErrorMessage()}` };\n }\n return { success: true, data: data as HDFPlan };\n}\n\n/**\n * Parse HDF Evidence Package document from string or bytes\n */\nexport function parseEvidencePackage(input: string | Uint8Array): ParseResult<HDFEvidencePackage> {\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n if (jsonStr.trim().length === 0) {\n return { success: false, error: 'Input is empty' };\n }\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return { success: false, error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}` };\n }\n const validationResult = validateEvidencePackage(data);\n if (!validationResult.valid) {\n return { success: false, error: `Schema validation failed: ${validationResult.getErrorMessage()}` };\n }\n return { success: true, data: data as HDFEvidencePackage };\n}\n\n/**\n * Parse HDF Comparison document from string or bytes\n */\nexport function parseComparison(input: string | Uint8Array): ParseResult<HDFComparison> {\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n if (jsonStr.trim().length === 0) {\n return { success: false, error: 'Input is empty' };\n }\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return { success: false, error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}` };\n }\n const validationResult = validateComparison(data);\n if (!validationResult.valid) {\n return { success: false, error: `Schema validation failed: ${validationResult.getErrorMessage()}` };\n }\n return { success: true, data: data as HDFComparison };\n}\n\n/**\n * Parse HDF document with auto-detection of type\n * @param input - JSON string or Uint8Array to parse\n * @returns ParseResult with parsed data, type indicator, or error\n */\nexport function parse(\n input: string | Uint8Array,\n): ParseResult<HDFResults | HDFBaseline | HDFSystem | HDFPlan | HDFEvidencePackage | HDFComparison> {\n // Convert Uint8Array to string if needed\n const decoded = typeof input === 'string' ? input : new TextDecoder().decode(input);\n const jsonStr = normalizeTimestamps(decoded);\n\n // Check for empty input\n if (jsonStr.trim().length === 0) {\n return {\n success: false,\n error: 'Input is empty'\n };\n }\n\n // Parse JSON\n let data: unknown;\n try {\n data = JSON.parse(jsonStr);\n } catch (err) {\n return {\n success: false,\n error: `Invalid JSON: ${err instanceof Error ? err.message : String(err)}`\n };\n }\n\n // Trailing garbage already caught by the JSON.parse catch above; see\n // parseResults for the full rationale.\n\n // Auto-validate and detect type\n const validationResult = autoValidate(data);\n if (!validationResult.valid) {\n return {\n success: false,\n error: `Schema validation failed: ${validationResult.getErrorMessage()}`\n };\n }\n\n // Determine type based on structure\n if (typeof data === 'object' && data !== null) {\n const obj = data as Record<string, unknown>;\n\n // HDF Results has 'baselines' array at root\n if ('baselines' in obj) {\n return {\n success: true,\n data: data as HDFResults,\n type: 'results'\n };\n }\n\n // HDF Comparison has 'requirementDiffs' at root (unique discriminator)\n if ('requirementDiffs' in obj) {\n return { success: true, data: data as HDFComparison, type: 'comparison' };\n }\n\n // HDF Plan has 'assessments' at root\n if ('assessments' in obj) {\n return { success: true, data: data as HDFPlan, type: 'plan' };\n }\n\n // HDF Evidence Package has 'contents' at root\n if ('contents' in obj) {\n return { success: true, data: data as HDFEvidencePackage, type: 'evidencePackage' };\n }\n\n // HDF Baseline has 'name' and 'requirements' at root\n if ('name' in obj && 'requirements' in obj) {\n return {\n success: true,\n data: data as HDFBaseline,\n type: 'baseline'\n };\n }\n\n // HDF System has 'components' at root (Results' baselines check already ruled out)\n if ('components' in obj) {\n return { success: true, data: data as HDFSystem, type: 'system' };\n }\n }\n\n return {\n success: false,\n error: 'Unable to determine HDF document type'\n };\n}\n\n"],"mappings":";;;AA2BA,SAAS,YAAY,MAAc,aAA8C;CAC/E,MAAM,QAAkB,CAAC;CACzB,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,QAAQ,CAAC,IAAI;CACnB,OAAO,MAAM,SAAS,GAAG;EACvB,MAAM,OAAO,MAAM,MAAM;EACzB,IAAI,KAAK,IAAI,IAAI,GAAG;EACpB,KAAK,IAAI,IAAI;EACb,MAAM,KAAK,IAAI;EACf,KAAK,MAAM,SAAU,YAAY,IAAI,IAAI,KAAK,CAAC,GAC7C,MAAM,KAAK,KAAK;CAEpB;CACA,OAAO;AACT;;AAGA,SAAS,cA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AAO;GAAE,SAAS;GAAY;GAAmB,MAAM;EAAS;CAEpE;CAEA,OAAO;EACL,SAAS;EACT,OAAO;CACT;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mitre/hdf-parsers",
3
- "version": "3.7.2",
3
+ "version": "3.8.0-next.42532249979.1",
4
4
  "description": "Parse and load HDF documents with validation",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -25,8 +25,8 @@
25
25
  "author": "MITRE Corporation",
26
26
  "license": "Apache-2.0",
27
27
  "dependencies": {
28
- "@mitre/hdf-schema": "^3.7.2",
29
- "@mitre/hdf-validators": "^3.7.2"
28
+ "@mitre/hdf-schema": "3.8.0-next.42532249979.1",
29
+ "@mitre/hdf-validators": "3.8.0-next.42532249979.1"
30
30
  },
31
31
  "engines": {
32
32
  "node": ">=24.0.0"
@@ -40,7 +40,7 @@
40
40
  "devDependencies": {
41
41
  "@stryker-mutator/core": "^9.5.1",
42
42
  "@stryker-mutator/vitest-runner": "^9.5.1",
43
- "@mitre/hdf-fixtures": "^3.7.2"
43
+ "@mitre/hdf-fixtures": "^3.8.0-next.42532249979.1"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "tsdown",