RunManifest Technical Deep Dive
This document explains the internal mechanics of RunManifest v2 (manifest_version: "2.0"): DuckDB construction (build_runmanifest_from_db), multi-CVE KEV parity, --output-all artifact hashing, ledger_events SHA-256 hash chaining, canonical digesting, and strictly read-only vpp verify enforcement.
Primary Implementation Files
src/vulnparse_pin/utils/runmanifest.py(build_runmanifest_from_db,verify_runmanifest,verify_runmanifest_file,verify_runmanifest_integrity,VOLATILE_PATHS)src/vulnparse_pin/core/classes/execution_manifest.py(LedgerService,DecisionLedgerEntry,EMPTY_LEDGER_ROOT)src/vulnparse_pin/storage/schema.sql(runs,ledger_eventstables)src/vulnparse_pin/app/output.py(export_v2_outputs)src/vulnparse_pin/cli/commands.py(_build_verify_pfh,_verify_listed_manifest_outputs,run_verify_command)src/vulnparse_pin/core/schemas/runManifest.schema.json
Architecture & DuckDB Data Flow
During vpp scan and vpp demo:
LedgerServiceappends hash-chained events in memory during ingestion, enrichment, passes, and webhook delivery._flush_ledger_to_db(db, run_id, ctx)persists those entries into DuckDBledger_events.export_v2_outputs()writes all requested output files (json,csv,executive_markdown,technical_markdown,dossier_markdown,dossier_html) before building the RunManifest so every written artifact exists on disk when hashed.build_runmanifest_from_db(db, run_id, config_hashes=..., outputs=..., mode=...)constructs the manifest directly from DuckDB tables (runs,assets,findings,finding_cves,enrichment_snapshots,aci_signals,scores,triage_decisions,ledger_events).write_runmanifest()validates the payload againstrunManifest.schema.jsonand runsverify_runmanifest_integrity()before writing to disk.- The resulting
verification.manifest_digestis written back toruns.manifest_digestin.vpp.db(so subsequentvpp exportcalls embed the sealed digest in dossiers/roadmaps).
Output Artifact Hashing (--output-all)
In export_v2_outputs(), outputs_meta populates all six exported artifact keys when --output-all <BASENAME> is used:
json(<stem>.json)csv(<stem>.csv)executive_markdown(<stem>_summary.md)technical_markdown(<stem>_technical.md)dossier_markdown(<stem>_dossier.md)dossier_html(<stem>_dossier.html)
_collect_output_hashes() streams each non-null regular file in 1 MiB chunks (_HASH_CHUNK_BYTES), skipping symlinks, and records "sha256:<hex>" under manifest["output_hashes"]. Input scan files are similarly hashed into inputs.input_files_sha256 and combined into inputs.target_sha256.
Multi-CVE kev_findings Parity and pass_summaries
In _build_db_pass_summaries() (src/vulnparse_pin/utils/runmanifest.py), DuckDB-backed manifests emit four pass summaries when populated:
ACI@2.0(aci_signals)Scoring@3.0(scores)Triage@2.0(triage_decisions)Summary@2.0(assets,findings,enrichment_snapshots)
NmapAdapter, Remediation@1.0, and TopN@2.0 are not emitted in _build_db_pass_summaries() (though Remediation@1.0 actions persist in DuckDB remediation_actions / remediation_action_findings and emit ledger_events).
For Summary@2.0, _build_db_pass_summaries() computes kev_findings with full multi-CVE parity across:
enrichment_snapshotsmatched on the effective primary CVE (COALESCE(score_trace.$.primary_cve, f.primary_cve)),finding_cvesjoined toenrichment_snapshots(BOOL_OR(COALESCE(es.in_kev, FALSE))), so findings whose secondary CVE is in CISA KEV are still counted, andTRY_CAST(json_extract(s.score_trace_json, '$.in_kev') AS BOOLEAN).
This guarantees pass_summaries[*].metrics.kev_findings matches repositories.get_run_summary_counts(), SummaryV2Pass, and Decision Defense Dossiers.
ML Governance (ml_governance) Emission & Verification
build_runmanifest_from_db() emits manifest["ml_governance"] via _resolve_ml_governance_from_db(conn, rid, intel_meta, ml_governance) (src/vulnparse_pin/utils/runmanifest.py, schema in runManifest.schema.json $defs/properties ml_governance):
- Resolution sources: Uses an explicit
ml_governanceargument orintel_meta["ml_governance"]if provided; otherwise reconstructsml_mode,provider,model_ids, andmodel_hashesfromruns.intel_metadata_json(pre_kev_model_id/sha256,aci_model_id/sha256),aci_signals.ml_model_id,scores.score_trace_json($.ml_aci), andload_signed_model()/get_ml_status()(returning emptymodel_ids: []andmodel_hashes: {}whenml_mode == "off", and failing closed if an observed model ID lacks a validsha256:<64-hex>digest). - Digest inclusion:
ml_governanceis not inVOLATILE_PATHS, so_compute_manifest_digest()includesml_governanceinverification.manifest_digest. - Integrity checks (
_verify_ml_governance_block()): Validatesml_modein{"off", "shadow", "active"},providerin{"auto", "core", "onnx"},model_idsas a duplicate-free list of non-empty strings,model_hashesvalues matching^sha256:[0-9a-f]{64}$, exact key-set equalityset(model_ids) == set(model_hashes.keys()), and emptymodel_idswheneverml_mode == "off".verify_runmanifest_integrity()calls_verify_ml_governance_block()whenever"ml_governance"is present.
ledger_events SHA-256 Hash Chain
Each LedgerService entry is persisted to ledger_events (run_id, seq, ts, component, event_type, subject_ref, why, evidence_digest, prev_hash, entry_hash):
EMPTY_LEDGER_ROOT = "sha256:" + sha256("vpp-ledger-empty-root-v1").hexdigest()evidence_digest = "sha256:" + sha256(_canonical_json(evidence)).hexdigest()prev_hash=EMPTY_LEDGER_ROOTforseq == 1, else previousentry_hashentry_hash = "sha256:" + sha256(_canonical_json({seq, ts, component, event_type, subject_ref, why, evidence_digest, prev_hash})).hexdigest()
verify_runmanifest_integrity() verifies:
decision_ledger.entry_count == len(entries)(rejecting booleans or mismatched counts)seqis contiguous1..Nprev_hashmatchesexpected_prev- Recomputed
entry_hashmatchesentry["entry_hash"] chain_rootequals the finalentry_hash(orEMPTY_LEDGER_ROOTwhenN == 0)
Canonical verification.manifest_digest
_compute_manifest_digest() removes VOLATILE_PATHS:
generated_at_utcpass_summaries.started_at_utcpass_summaries.ended_at_utcdecision_ledger.entries.ts
Sets verification.manifest_digest = None, serializes with _canonical_json() (sort_keys=True, separators=(",", ":"), ensure_ascii=True), and computes sha256:<hex>. Note that ts remains covered by each ledger entry’s entry_hash, while manifest_digest stays invariant across timestamp-only differences.
Strictly Read-Only vpp verify Enforcement
run_verify_command() (vpp verify <runmanifest.json>) is strictly read-only by default:
_build_verify_pfh(args): ConstructsPermFileHandlerwith alogging.NullHandler()logger and does not callpaths.ensure_dirs()or create log files unless the operator explicitly passes a non-default--log-file <name>(!= "vulnparse_pin.log"). This allowsvpp verifyto run cleanly inside0o500/ read-only XDG environments and air-gapped CI containers.- Symlink & Root Guardrails:
- By default (
--forbid-symlinks-read,True),_check_no_symlinks_or_loops()rejects symlinks on both the manifest path and every non-null output artifact inoutputs. Pass--allow-symlinks-readonly when intentionally verifying symlinked artifacts. - Pass
--enforce-root-read(-err) to confine manifest and listed output reads to acceptablePermFileHandlerroots.
- By default (
- Listed Output Verification (
_verify_listed_manifest_outputs): For every non-null entry inoutputsand every recorded digest inoutput_hashes, verifies file existence and checkshmac.compare_digest(expected_hash, _file_sha256(out_path)). Any missing file, symlink violation, or digest mismatch exits with code1.
Practical Limits
expandedmode increases manifest and.vpp.dbsize proportionally to logged events.- SHA-256 hash chains and
manifest_digestprovide tamper evidence, not asymmetric cryptographic signatures (combine with CI artifact signing / SLSA attestations for non-repudiation).