Skip to content

HDF Developer Guide ​

Patterns and practices for contributing to the HDF libraries.


Toolchain ​

The toolchain is pinned with mise. mise.toml names the versions and mise.lock records the exact release and each download's checksum and provenance check, so the pre-commit hook and CI run the same releases on every machine.

ToolPinHow mise installs it
Node.jsnode in mise.toml (the Active LTS line); exact release in mise.lockOfficial archive; SHA-256 from SHASUMS256.txt and the OpenPGP signature on that file
pnpmpackageManager in package.jsonRelease binary; SHA-256 and the GitHub attestation from pnpm's release workflow
Gogo line in go.workOfficial archive, checked against the lock's SHA-256
golangci-lintmise.tomlOfficial release binary; SHA-256 and the GitHub attestation from golangci-lint's release workflow
gosecmise.tomlOfficial release binary; SHA-256 and the cosign signature on its checksum file
govulncheckmise.tomlgo install, verified against the Go checksum database
jactionlintmise.tomlOfficial release binary; SHA-256 and the GitHub attestation from jactionlint's release workflow
shellcheckmise.tomlOfficial release binary; SHA-256 as mise.lock recorded it (shellcheck publishes no checksums or signatures)
oapi-codegenmise.tomlgo install, verified against the Go checksum database

Corepack is not used: mise installs pnpm itself, and Node.js stopped shipping Corepack in version 25. CI's shared setup action, the snapshot workflow and the publish job of release.yml install Node.js, and pnpm where a job needs it, through mise-action; the check-go job adds Go's scanners the same way. npm itself stays pinned by the setup-npm action (SHA-512 checked), because mise's npm installer does not cover Windows.

Setup, once per clone (mise 2026.10.9 or newer reads Go's version from go.work):

bash
mise trust     # allow this repository's mise.toml
mise install   # install the pinned tools, verified against mise.lock

The pre-commit hook runs mise exec -- pnpm check, so it uses these versions whether or not mise is activated in your shell. For a single command, prefix it the same way, for example mise exec -- golangci-lint run in a module directory.

Why golangci-lint is pinned to a release binary: its formatters are compiled in from the Go that builds it. A golangci-lint built with a newer Go reports formatting that CI's accepts, so a local build from source (go install, Homebrew) can fail the hook on code CI passes. golangci-lint's own install guide recommends the release binary for the same reason.

To move a pin: edit mise.toml, the go line of go.work or packageManager in package.json, run mise lock to refresh mise.lock for every platform, and commit both. A new Node.js release on the same line needs no edit: mise lock --bump node moves the lock to it. A new golangci-lint or Go release can change gofmt's output; run golangci-lint fmt across the modules in the same change.


Dual Implementation Pattern (TS + Go) ​

Every HDF library must be implemented in both TypeScript and Go simultaneously. Do NOT build one language first and port later.

Why ​

This was learned the hard way with hdf-diff: building TS first (380 tests) and then porting to Go required multiple agent swarms, code review rounds, and bug fixes. The Go nil-slice serialization issue (see below) would have been caught immediately if Go was built alongside TS.

Pattern ​

For each feature:

  1. Design JSON Schema (primitives + top-level)
  2. Write TDD tests in BOTH languages from shared fixture expectations
  3. Implement in both languages
  4. Run differential testing to verify identical output
  5. Code review both implementations

Shared Fixtures ​

Test fixtures live in the package's test/fixtures/ directory and are shared between TS and Go via relative paths. The Go tests load fixtures from ../../../<package>/test/fixtures/. Tests skip gracefully if fixtures are not found.


Differential Testing ​

Differential testing verifies that TypeScript and Go implementations produce identical output for the same inputs.

How It Works ​

  1. Both implementations run on the same shared fixtures
  2. They assert the same expected values (same requirement states, same summary counts, same change reasons, same field changes)
  3. Tests are NOT byte-identical comparison — they verify semantic equivalence because JSON key ordering may differ between languages

Example ​

The hdf-diff differential tests (hdf-diff/go/engine/differential_test.go):

  • Load fixtures from ../../../hdf-diff/test/fixtures/
  • Run Go's engine.DiffHdf() on each fixture pair
  • Assert the same values that the TypeScript tests in hdf-diff/test/diff.test.ts assert

This found a real bug: Go was not threading document timestamps to ComputeEffectiveStatus(), causing incorrect waiver expiration evaluation.


Ground-Truth Anchors ​

Differential (golden) parity proves the TypeScript and Go implementations agree; it cannot prove either is correct. When both misread a format the same way, their goldens match, the suite stays green, and the defect is invisible — and the standard "make the two sides agree" fix actively canonizes a shared misreading into a golden that then defends it. This is not hypothetical: in nhia, neither XCCDF converter traversed nested <Group> elements, dropping ~99% of rules against real SCAP Security Guide content. Parity could never have surfaced it.

Every committed golden is generated from converter output (go test -update), so a golden can only catch a change from current behavior — never confirm that behavior is correct.

The anchor pattern ​

A ground-truth anchor asserts the converter reproduces an item count derived independently from the source document — not from converter output. It is the one assertion whose expected value does not come from the code under test.

Helpers live in hdf-converters/shared/{go/anchor.go,typescript/anchor.ts}. The Go helpers are PascalCase and take t *testing.T as their first argument; the TypeScript helpers mirror them in camelCase without t. Both languages provide:

  • Count XML elements (CountXMLElements / countXmlElements) — count XML start-elements by local name.
  • Count JSON items under a key (CountJSONItemsUnderKey / countJsonItemsUnderKey) — count array items held under an object key at any depth (handles nested containers).
  • Assert requirement count (AssertRequirementCount / assertRequirementCount) — assert emitted requirements equal want, across both output shapes (HDFResults baselines[].requirements and HDFBaseline top-level requirements).
  • Assert override count (AssertOverrideCount / assertOverrideCount) — the amendment analogue for VEX importers, which emit overrides[] rather than requirements.

The independence rule (load-bearing). The count MUST NOT reuse the converter's own parser or typed structs — reusing the converter's traversal would let the same bug corrupt the ground-truth count. Use the generic shared counters, or a small local count that parses the raw source generically.

Emission unit, confirmed per converter. Each anchor asserts emitted == count(source emission unit), confirmed against a real fixture. Where the converter rolls up or filters (one requirement per distinct rule, with one result per instance rather than instances dropped as duplicates; per actionable VEX status; per the busiest ZAP site; per CSV finding row), the anchor counts that same distinct/filtered unit — not the raw array length — so it matches exactly. If no clean source-derived count matches the golden, do not write a meaningless anchor: a passing-but-vacuous anchor is worse than none. Every anchor fixture must contain ≥1 source unit (want != 0) or it proves nothing.

Mask discipline ​

The importer snapshot harness blanks a small set of volatile keys before comparison (shared/go/testing.go volatileKeys / shared/typescript/snapshot.tsVOLATILE_KEYS). Every masked key needs a stated reason it cannot be derived from the input. A masked key that can be input-derived is a hidden bug, not volatility — inside a mask, "volatile" and "wrong" are indistinguishable (u6j3: an oscal-sar golden froze a conversion timestamp that the mask then hid).

  • timestamp — document write/conversion time (volatile).
  • startTime — conversion-time fallback for importers whose source carries no scan time (volatile for those; input-derived for those that do — a per-converter refinement is tracked as a follow-up).
  • resultsChecksum is not masked: it is sha256(input), deterministic and identical across Go/TS, so asserting it catches real checksum divergence.

Audit results ​

  • Scalar-for-repeatable audit: clean. A sweep of the dual converters for spec-repeatable elements modeled as a single (non-slice) field — the nhia / i86q class — found every repeatable element correctly modeled as a slice and every nested container (Groups, Controls, Parts) traversed recursively. Only anchors catch this class regardless of code inspection.
  • Zero-golden importers closed. ckl-to-hdf and cklb-to-hdf had no whole-output golden at all and are now in the snapshot harness. hdf-passthrough (an identity converter) remains golden-less — low risk, tracked as a follow-up.

Go Nil-Slice JSON Serialization ​

The Problem ​

Go's encoding/json serializes nil slices as null. HDF JSON Schema 2020-12 with unevaluatedProperties: false rejects null for optional array fields that aren't explicitly nullable. TypeScript omits undefined fields entirely from serialized JSON.

The Fix ​

hdf-diff/go/validate/validate.go exports NormalizeForSchema() which:

  • Preserves null for explicitly nullable fields (before, after)
  • Converts null to [] for required array fields (fieldChanges, changeReasons)
  • Strips all other null values (matches JS undefined behavior)

ValidateComparison() calls NormalizeForSchema() automatically.

Long-Term Fix ​

Update the quicktype Go code generator to emit omitempty on optional array fields, or add custom MarshalJSON methods on EvaluatedRequirement. Tracked in beads memory go-nil-slice-null.

Rule ​

Any Go code producing HDF documents for schema validation must call validate.NormalizeForSchema() before validation. This applies to all future HDF document types (hdf-system, hdf-plan, hdf-amendments, hdf-evidence).


Timestamp Handling ​

Canonical form ​

Every timestamp in an HDF document (timestamp, result startTime, etc.) is RFC 3339 in UTC, with trailing fractional-second zeros trimmed and at most millisecond precision — e.g. 2024-11-15T10:30:00Z, 2024-01-01T00:00:00.12Z. This is the single canonical form both the TypeScript and Go converters emit, so their output is byte-identical and independent of the host machine's timezone.

UTC is canonical because startTime/timestamp are instants (when something ran), not wall-clock-with-offset; UTC has exactly one rendering, which makes cross-language parity trivial and eliminates the entire class of host-timezone-dependent bugs.

The Problem ​

Two traps produce drift:

  1. Zone-less parsing. new Date("2012-12-10T13:47:29") (no Z/offset) is read as host-local time in JavaScript, but as UTC by Go's time.Parse. A converter using raw new Date(value) therefore produces different output depending on the machine it runs on.
  2. Offset / precision divergence. A bare time.Parse(time.RFC3339, ...) in Go preserves the source offset (-05:00) and nanoseconds, while the TS side serializes a Date as UTC milliseconds — the two never match byte-for-byte.

The Fix — always go through the shared helpers ​

TypeScriptGo
Parse a tool timestampparseTimestamp(s) from @mitre/hdf-utilities (zone-less → UTC, returns Date | null)hdfutil.ParseTimestamp(s) (zone-less → UTC, .UTC().Truncate(ms), returns zero time.Time if unparseable)
Format for outputformatTimestamp(d) / let buildHdfResults / serializeHdf serialize the Date (they trim the fraction)marshal the time.Time (RFC3339Nano of a UTC value is already trimmed)

These helpers are the single source of truth — import them, never re-implement timestamp parsing.

Rules ​

  • Never parse a tool-supplied timestamp with raw new Date(value) (TS) or time.Parse(time.RFC3339, ...) (Go). Use the shared helpers.
  • A converter that builds HDF output by hand (a direct JSON.stringify) must use serializeHdf() from converterutil, not a bare JSON.stringify, so the fractional-second trim is applied.
  • Result startTime is schema-required. When the source timestamp is absent or unparseable, fall back to a valid value (conversion time new Date() / the Go zero time.Time) — never undefined / omitted.
  • A custom-layout time.Parse("<layout>", ...) is allowed only for formats hdfutil.ParseTimestamp does not cover (e.g. vendor-specific strings); pass the result through hdfutil.NormalizeTimestamp(t) (UTC + millisecond precision) to keep it canonical.

Enforcement ​

These rules are enforced mechanically so the drift cannot recur:

  • TS: a no-restricted-syntax ESLint rule in the root eslint.config.mjs bans new Date(<identifier|member>) across hdf-converters/{converters,shared,fetchers} and hdf-diff/src, hdf-utilities/src — importers parse tool timestamps and exporters parse HDF's own, so both directions are covered.
  • Go: scripts/check-timestamp-usage.mjs (run as pnpm lint:timestamps, part of pnpm check) bans time.Parse(time.RFC3339...) in converter Go.

Decision and rationale are recorded in beads memory hdf-timestamp-canonical-utc.


Number Formatting ​

The Problem ​

Go and JavaScript disagree about numbers in two places, and neither shows up in a fixture unless someone goes looking for the triggering value.

Fixed precision. fmt.Sprintf("%.1f", v) rounds halves to EVEN; JavaScript's toFixed(1) rounds them AWAY FROM ZERO. Any value whose exact binary expansion ends in a 5 at the cut point renders differently: 7.25 becomes 7.2 in Go and 7.3 in TypeScript. Ties are reachable at every precision the converters use, including six decimals, where a score has to land on an odd multiple of 1/128.

Negative zero. Go's encoder keeps the sign on -0; JSON.stringify drops it. A small negative impact rounds to negative zero in both languages, so they agree on the value and part company only at serialization.

The Fix ​

  • Fixed precision → hdfutil.FormatFixed(v, prec) (Go). It uses exact rational arithmetic and matches toFixed for every finite value below 1e21. Never reach for %.Nf when a TypeScript peer uses toFixed.
  • Raw JSON numbers on the export path → already handled: EncodeLine normalizes negative zero away, and shared/export-number-cases.json pins the rendering contract that both languages assert.
  • Rendering a number as text anywhere else → positional at every magnitude: strconv.FormatFloat(f, 'f', -1, 64) (Go) and formatJsonNumber (TypeScript), which are exactly equivalent. Go's %.0f truncates and JavaScript's String() switches to exponent notation, so neither is safe on its own. This is the form FloatToken/floatNumber and the XML scalar renderer all use.

Hashing is deliberately different. hdfutil.CanonicalJSON and canonicalJson both KEEP the sign on negative zero, because a checksum must reflect the bytes it was handed. Export is a presentation boundary; hashing is an identity boundary. Do not unify them.

Rule ​

A new %.Nf in a converter that has a TypeScript peer is a bug, not a style choice. Route it through FormatFixed and add a case whose value is an exact tie at that precision — a test using a non-tie value passes with the broken code and proves nothing.

The same applies to %.0f against a peer that interpolates the raw number: both sides must render positionally and losslessly, because truncating or rounding a value silently changes data the converter was only meant to carry through.


Schema format Assertion ​

JSON Schema 2020-12 treats format as an annotation unless a validator opts in. Both test harnesses opt in, so a uuid, date-time, uri or date violation fails validation rather than passing silently — which matters because converter tests assert "this input is valid HDF" before converting, and a validator that skips format lets such a test prove nothing while looking green.

Vocabularies asserted ​

The HDF schemas assert eight formats: uuid, date-time, date, uri, uri-reference, hostname, ipv4 and ipv6. Both harnesses implement all eight. Enabling more later changes what every existing test accepts, so treat it as a deliberate change, not a dependency bump.

The two harnesses are pinned to each other ​

hdf-converters/shared/testdata/format-assertion-cases.json is read by both shared/go/schemavalidation_test.go and shared/typescript/format-assertion.test.ts. Each case records the verdict the validators must produce, in both dialects. Three libraries are involved — santhosh-tekuri (Go, 2020-12), gojsonschema (Go, draft-07) and ajv-formats (TypeScript, both) — and where they genuinely disagree the table records each side's verdict instead of forcing one to imitate the other, so a library upgrade that changes either answer fails a test. The divergences array in that file explains every case that does this and why.

One divergence was closed rather than recorded: ajv-formats accepted the RFC 3339 space separator (2020-01-01 00:00:00Z) where Go required the T. HDF's canonical timestamp requires the T, so loadSchemaValidatorWithResources overrides ajv's date-time to match Go.


CLI exit codes ​

The user-facing table is the "Exit codes" section of hdf-cli/README.md; this section is the contributor side of it. One vocabulary for every command: 0 success, 1 the operation failed, 2 the invocation was wrong, 3 a bulk run was partial, 4 there was nothing to do.

How a command produces a code ​

  • Return an error; never call os.Exit. The only os.Exit in the CLI is in cmd/hdf/main.go, which passes the error Execute returned through ExitStatus (cmd/hdf/cmd/root.go) and exits with what it says. A test asserts a code by calling ExitStatus on the error executeCommand returned.
  • A specific code travels as an exitCodeError (root.go), which implements ExitCoder. A command that returns one has usually already said everything, such as a diff verdict, a bulk summary or a validation report, so main prints no Error: line for it unless the error sets report; the nothing-to-do errors do. Every other error is printed.
  • A plain error from a command's run is 1. NewRootCmd wraps every RunE in the tree (markRunErrors in root.go) so the error is marked as coming from a run; ExitStatus maps that mark to 1.
  • Anything unmarked is 2. Cobra raises unknown-flag, unknown-command, arity and required-flag errors before a RunE runs and offers no hook for most of them, so the run side is marked instead (ExitStatus in root.go) and everything else is a usage error. A command that detects a usage mistake itself returns an exitCodeError with exitUsage. Cobra applies its own unknown-command check to the root only, because that check tests for a parent, and a command that cannot run returns a help sentinel that ExecuteC swallows — so rejectUnknownSubcommands (root.go) gives every group a run of its own and an argument validator, which is what makes a typo'd subcommand a 2 rather than a silent 0. A new group inherits this; do not add a per-group check.
  • Bulk commands go through runBulk (bulk.go) and inherit 3 for a mixed run and 1 when every file failed. Do not hand-roll a per-file loop or a summary line. A verdict gate (validate threshold) or an all-or-nothing batch (system add-component) passes withFailClosed() so it is never partial.
  • A command that builds one output from several inputs (events fold and apply, evidence build) is not bulk: an input it cannot read fails the whole run with 1, and no partial output is written. What counts as unreadable is each command's own contract, not this rule's — evidence build hashes what it is handed and leaves document validity to hdf validate, so a results file containing nonsense is packaged and the run exits 0.
  • 4 is for an empty input set: expandGlobs (bulk.go) returns it when a pattern matches nothing, and evidence build when it was given no results files. A command that takes literal paths rather than expanding globs never reaches it: events fold reports a non-matching pattern as a missing file, which is a 1. It is also not for an operation that legitimately found nothing to change; amend apply with no matching override exits 0 unless --require-match is passed, because a register carried across documents is expected to miss.
  • Every new code or exception lands in the README table in the same commit, and every sentence about a code is checked by running the built binary, not recalled.

The one command-local exception: diff ​

hdf diff keeps its own verdict codes because they encode the comparison, not the run. A diff that fails to run (an unreadable input, a bad flag) uses the codes above.

Basic mode, always on and GNU diff compatible: 0 identical, 1 differences. --exit-code is accepted and changes nothing, and a failed run is also 1.

Detailed mode (--detailed-exitcode):

CodeMeaningCI Action
0IdenticalPass
1ErrorFail
10Fixes onlyPass (improved)
11Regressions onlyFail (degraded)
12MixedReview
13Baseline changedInform
14Drift onlyInform

Range 10-14 chosen to avoid sysexits.h (64-78), signal range (128+), and InSpec (100-101). Full rationale documented in CHANGELOG.md.


Schema Development Pattern ​

Adding a New Document Type ​

  1. Create primitives/<name>.schema.json with $defs for type-specific types
  2. Create hdf-<name>.schema.json as the top-level document
  3. Use $ref to existing primitives (Identity, Checksum, Signature, Target, etc.)
  4. Set unevaluatedProperties: false on all object types
  5. Add to test/setup.ts createAjvWithPrimitives() primitive list
  6. Write test/hdf-<name>.test.ts with 20+ validation tests
  7. Add to src/generate-types.ts for TS/Go type generation
  8. Add subpath export to package.json
  9. Add to src/create-index.ts for barrel exports

Adding or Changing a Field — Propagate to Every Output Converter ​

A new HDF field is invisible to consumers until the converters emit it. When you add a field to a schema, before release confirm it reaches the whole pipeline:

  1. Importers (*-to-hdf) — populate the field wherever a source carries the data.
  2. Every output converter (hdf-to-*) — map the field into the target format's home, or record a documented reason it can't (NOT-IN-SOURCE / no target home). hdf-to-xml is a generic serializer and renders any field automatically — no change needed there — but the other exporters (asff, ckl, cklb, oscal-poam, oscal-sar, xccdf, csv, ocsf, ecs, csaf-vex, openvex, cyclonedx-vex, splunk) each need the field mapped by hand.
  3. New plural/array field? Add its plural→singular entry to hdf-to-xml's container map so its XML child element is named (unmapped array keys fall back to <item> — lossless but generically named).
  4. Tool-specific metadata with no typed home goes to extensions.passthrough/namespaced tags, not a new field — see "Auxiliary Tool Metadata" above.

Naming Conventions ​

  • Schema $defs: Snake_Case (e.g., Evaluated_Requirement, Authorization_Status)
  • JSON fields: camelCase (e.g., authorizationStatus, baselineRefs)
  • Enum values: camelCase (e.g., conditionallyAuthorized, notApplicable)
  • Go types: PascalCase (e.g., AuthorizationStatus, BaselineRef)
  • Go constants: PascalCase with prefix (e.g., StatusAuthorized, ModeBaseline)

$ref URI Pattern ​

https://mitre.github.io/hdf-libs/schemas/primitives/<name>/v3.8.0#/$defs/<Type>
https://mitre.github.io/hdf-libs/schemas/hdf-<name>/v3.8.0#/$defs/<Type>

Cross-Platform Compatibility ​

Scripts ​

  • Use rimraf instead of rm -rf in package.json scripts (Windows compatibility)
  • Use node:fs in a small Node script instead of cp -r or a shell glob (Windows compatibility) — see hdf-schema/src/sync-validator-schemas.ts
  • Use node --watch-path=<dir> instead of nodemon for file-watching scripts
  • Use readdirSync instead of shell globs in Node scripts (tsc dist/ts/*.ts fails on Windows PowerShell)
  • Use working-directory in GitHub Actions instead of cd && command

Testing ​

  • Use fileParallelism: false in vitest config for packages whose tests mutate shared state (e.g., hdf-schema's create-index tests clean and rebuild dist/)
  • Use server.deps.inline: [/@mitre\//] in vitest config for packages that import workspace dependencies (fixes pnpm junction resolution on Windows)
  • Go tests that load fixtures from sibling packages should skip gracefully if fixture files are not found

Coverage Standards ​

  • 95% minimum for statements, branches, functions, and lines in all packages
  • Coverage is enforced in CI — continue-on-error is never used
  • Unreachable defensive branches can be annotated with /* c8 ignore next */ (TS) or excluded via test-time assertions (Go), but MUST include a comment explaining why the branch is unreachable
  • "Pre-existing" coverage gaps are not an excuse — if we find it, we fix it

Progressive Enrichment Principle ​

When adding optional fields to HDF schemas (labels, sbomRef, systemRef, typed inputs, signatures), follow the progressive enrichment pattern:

  1. The field MUST be optional in the schema
  2. Documents without the field MUST be fully valid and functional
  3. Tests MUST cover both the "field present" and "field absent" cases
  4. Converters SHOULD populate the field when source data is available, but MUST NOT fabricate data when it's not
  5. Consumers (Heimdall, CLI) MAY prompt users to add enrichment, but MUST NOT fail when enrichment is absent

See CHANGELOG.md for the full rationale.

SBOM References ​

sbomRef fields reference external SBOM documents (CycloneDX/SPDX) by URI. HDF does not define its own SBOM format. Both CycloneDX and SPDX are supported from day one.

Rules:

  • sbomRef is always optional
  • When a system document's component has sbomRef, results for matching targets SHOULD reference the same SBOM (if the pipeline has access to it)
  • When a vulnerability finding references a package not in any known SBOM, the sbomRef is absent — never fabricated
  • Package-level data enters HDF through tags.purl on findings (populated by SCA converters like Grype/Trivy). Config scanners (InSpec, Nessus) never produce purls.

SBOM Library Adoption ​

Full research: docs/reviews/2026-03-15-sbom-library-research.md

Go: Adopt protobom (OpenSSF) for unified CycloneDX + SPDX parsing with built-in diff primitives. Also packageurl-go for PURL matching.

TypeScript: Adopt @cyclonedx/cyclonedx-library for CycloneDX validation + packageurl-js for PURLs. Build custom format-agnostic parser (~100-200 lines) normalizing CycloneDX components[] and SPDX packages[] into a common model. The diff algorithm is format-agnostic once components are extracted.


Auxiliary Tool Metadata (extensions.passthrough + namespaced tags) ​

Some source tools carry metadata that has no typed HDF home — scanner run statistics, per-finding hashes/keys, raw analysis flags. HDF does not need a new field for these: the schema already provides two open sinks. Route auxiliary data there under a reserved tool-named namespace rather than dropping it or inventing schema.

Two homes, by scope ​

  • Scan / baseline scope → baseline.extensions.passthrough['<tool>'] (an object). extensions itself is a closed object — its only members are passthrough and rawSourceArtifacts, and a key written beside them makes the document invalid in both the TypeScript and Go validators. passthrough is the permissive surface inside it. Use it for whole-scan exhaust: gosec Stats (files/lines/nosec counts) + Go build errors, NeuVector report.cmds, IonChannel run-verdict metadata.
  • Requirement scope → tags['<tool>/<key>']. tags is an open string map, so a namespaced key absorbs per-finding extras: SonarQube hash/key/flows, IonChannel trigger_*.

Rules ​

  • Namespace under the tool name. baseline.extensions.passthrough['gosec'], tags['sonarqube/hash'] — never a bare key on extensions (which rejects it) and never a bare top-level key inside passthrough, so two converters never collide and consumers can filter by tool.
  • Only genuinely-homeless data. Anything with a typed field (cvss, cwe, refs, severity, status) goes to the typed field. extensions/namespaced-tags are the last resort for data the typed model can't express, not a shortcut around it.
  • Scan-level data goes once, at baseline scope — do not duplicate a whole-scan array onto every requirement's tags.
  • Populate conditionally (only when the source carries the field); Go+TS byte-parity as always.

Go Modules: Downgrades Drop Sibling Pins ​

A go get that downgrades a dependency below what a sibling module requires removes that sibling's require line, and the next go mod tidy adds it back at the zero pseudo-version v3.0.0-00010101000000-000000000000, because the replace directive resolves the sibling from its local directory. Tidy calls that tidy, every local build passes, and the module is unpublishable: a consumer cannot fetch a version no tag provides. This happens in and out of workspace mode alike; go mod tidy ignores go.work entirely. After any go get, read its go: removed ... and go: downgraded ... lines and git diff go.mod before tidying, and restore a removed sibling pin by hand. CI's check-go job runs pnpm run lint:go-mod-tidy, which fails if go mod tidy -diff would change any module or if any github.com/mitre/hdf-libs/... require sits at the zero pseudo-version, naming the module either way; the release workflow's --check is the last line, this one is the first. Tidiness also matters because the dependency scanner reads each go.mod as text, so a require that lags the resolved graph is what it judges.

Dependency Audit Overrides ​

The security gate (pnpm security) fails on prod advisories at moderate+ and dev advisories at high+. Because most advisories are in transitive dev dependencies we don't control (eslint, vitepress, …), we force patched versions via the overrides: block in pnpm-workspace.yaml rather than waiting for every upstream to re-release.

These overrides go stale, and stale overrides fail the gate. An advisory's patched-version floor gets raised (a new GHSA supersedes an old one, or the range widens), and the version we pinned as "patched" becomes the new vulnerable floor. The next unrelated commit then trips the pre-commit gate on a failure that has nothing to do with its change.

Two rules keep the block from rotting, and pnpm run lint:overrides enforces both on every commit:

Targets are ranges, never exact versions. Write "pkg@<X": "^X", not "pkg@<X": "X". An exact target is what caused the two outages above: it names precisely the version a later advisory goes on to name. A range target is not a cure — pnpm reuses the lockfile's resolution, so the held version only moves on a re-resolve, and an advisory naming the held version still turns the gate red. What it buys is that the remedy is then pnpm update <pkg> rather than an edit here, and the pin stops asserting a floor that will age. Verify the floor actually exists on the registry (npm view <pkg>@<version> version) — advisories state >=X.Y.Z semantically, but the real release may skip that exact version (shell-quote had no 1.8.5; the fix shipped in 1.10.0, so the target is ^1.10.0).

Every entry carries a comment saying what it holds back and what would let it go. A pin nobody can tell is still load-bearing survives every audit by default, and the block only grows.

Re-validate the overrides on each dependabot cycle (when a batch of dep PRs lands), not reactively when a commit trips over them:

  1. pnpm audit --prod --audit-level=moderate and pnpm audit --dev --audit-level=high.
  2. Test each entry for inertness, and remove the inert ones — do not bump them. An entry is inert when removing it introduces no advisory. That is the whole test, and it is the only one that is sound: do not instead ask whether some resolved version still matches the entry's range. The range is a selector a human wrote and it can be broader than the advisory it was written for — a brace-expansion@<5.0.12 pin matched a resolved 1.1.21 while the advisory only ever affected 5.x, so the range test called it load-bearing when it protected nothing and merely forced a cross-major substitution. So: remove the entry, pnpm install --lockfile-only, and diff the advisory set (step 3). No new advisory means the entry goes. A pin kept "just in case" is the precedent that leaves the block littered with dead entries. Watch the lockfile quoting: scoped names are quoted ('@babel/core@7.28.6':), so a parser that assumes an unquoted key will report a live pin as absent.
  3. pnpm install, re-run both audits to confirm exit 0, and diff the advisory set against the pre-change baseline — removing an entry that was actually load-bearing shows up here as a new advisory and nowhere else. Then pnpm build plus the affected package's tests, since an override can pull a breaking transitive major.
  4. Advisories with no viable fix are suppressed by GHSA id under auditConfig.ignoreGhsas — use sparingly and only when there's genuinely no patched version. Re-check these too: once an advisory has a reachable patched version, it belongs in overrides: or a plain dependency update, not in a standing ignore.

Released under the Apache 2.0 License.