Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@mitre/hdf-diff

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mitre/hdf-diff

Structured comparison of HDF evaluation results — tracks what changed, why, and by how much

Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
30
-82.25%
Maintainers
1
Weekly downloads
 
Created
Source

@mitre/hdf-diff

Structured comparison of HDF evaluation results — tracks what changed, why, and by how much.

What it does

Compares two HDF results documents and produces a structured diff showing:

  • Requirements added, removed, or changed between evaluations
  • Status transitions (passed→failed, failed→passed, etc.) with change reasons
  • Field-level changes (impact, title, severity)
  • Per-baseline and per-component compliance summaries
  • SBOM (CycloneDX/SPDX) package-level diffs

Output formats: JSON, Markdown, CSV, terminal (ANSI-colored).

Relationship to other packages

PackageRelationship
hdf-schemaProvides the HDFResults types that hdf-diff consumes
hdf-validatorsUsed to validate comparison output against the HDF comparison schema
hdf-clihdf diff command wraps this library for CLI use
hdf-parsersNot used — hdf-diff operates on typed structs, not raw JSON

Installation

npm install @mitre/hdf-diff

Usage

import { diffHdf, render } from '@mitre/hdf-diff';

// Compare two evaluation results
const comparison = diffHdf(oldResults, newResults);

// Render as markdown
const md = render(comparison, { format: 'markdown', detail: 'full' });

// Render as JSON
const json = render(comparison, { format: 'json' });

// Check exit codes for CI
import { computeExitCode, EXIT_IDENTICAL } from '@mitre/hdf-diff';
const code = computeExitCode(comparison);
if (code !== EXIT_IDENTICAL) process.exit(code);

Requirement matching

hdf-diff supports multiple strategies for matching requirements across evaluations:

  • Exact ID (default) — match by requirement ID
  • Mapped ID — match via a user-provided ID mapping
  • CCI match — match by shared CCI identifiers
  • Fuzzy title — Jaccard similarity on tokenized titles
import { diffHdf, createFuzzyTitleStrategy } from '@mitre/hdf-diff';

const comparison = diffHdf(oldResults, newResults, {
  matchStrategy: createFuzzyTitleStrategy(0.8), // 80% similarity threshold
});

SBOM comparison

import { diffSboms } from '@mitre/hdf-diff';

const sbomDiff = diffSboms(oldSbom, newSbom);
// Shows packages added, removed, updated, or unchanged

CLI usage

hdf diff old-results.json new-results.json
hdf diff old-results.json new-results.json --format markdown
hdf diff old-results.json new-results.json --json
hdf diff --sbom old-sbom.json new-sbom.json

License

Apache-2.0 © MITRE Corporation

Keywords

hdf

FAQs

Package last updated on 06 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts