Pass Phases
This document details each stage of the VulnParse-Pin v2.1.0 pipeline from streaming ingestion through DuckDB passes, scan-over-scan diffing, counterfactual simulation, and reporting.
Phase 0: Streaming Ingestion & Normalization (iter_batches -> ingest_normalized_batches)
Implemented across src/vulnparse_pin/parsers/*, src/vulnparse_pin/app/normalization.py, and src/vulnparse_pin/storage/repositories.py.
- Input validation & detection:
validate_scanner_input()runsFileInputValidator(size caps, streaming BOM/JSONL/XML prolog checks), andSchemaDetector.select()reads at most 64 KiB to select the winningParserSpec. - Batch streaming: The selected parser yields normalized finding dictionaries via
iter_batches(). - Ingestion quality gates:
enforce_batch_ingestion_gates()enforces--strict-ingestion,--allow-degraded-input/--no-allow-degraded-input, and--min-ingestion-confidenceon each streamed batch. - Asset resolution & cross-scanner deduplication:
ingest_normalized_batches()resolves each target throughAssetContextMatcher(assets.yaml) intoaid_v2_IDs and deduplicates findings intofid_v2_IDs across Track A (cve_threat) and Track B (exposure_weakness). Raw evidence from every scanner detection is appended tofinding_evidence, and distinct CVEs are written tofinding_cves.
Phase 1: DuckDB Threat Intel Snapshot (populate_enrichment_snapshots)
Implemented in src/vulnparse_pin/app/enrichment.py.
- Queries
.vpp.dbfor only the distinct CVEs (finding_cves/findings.primary_cve) andpackage_purlvalues present in the currentrun_id. - Hydrates intelligence from active sources (
NVDFeedCache,EPSSFeedCache,KEVFeedCache,GHSAEnrichmentSource,OSVEnrichmentSource, and Exploit-DBfiles_exploit.csv+ negation-aware text heuristics). - Computes unified CVSS provenance (
NVD > CNA > GHSA > OSV > Scanner-Supplied > Missing) viaresolve_cvss_with_provenance()and source-attributed enrichment confidence. - Computes EPSS trailing velocity (
epss_delta_7d,epss_delta_30d,epss_slope) viacompute_epss_velocity()fromepss_cache.sqlite3(epss_history) and prior DuckDB snapshots, and whenml_pol.mode != "off"andepss_scoreis present, runsPreKEVModel(pre_kev_v1_core) to populatepre_kev_score,pre_kev_flag, andpre_kev_reasons_json. - Bulk-inserts run-scoped rows into
enrichment_snapshotsand updatesruns.intel_metadata_json(EPSS#model_version+ score date, KEV catalog version + SHA-256, NVD/GHSA/OSV status).
Phase 2: run_v2_duckdb_pipeline Pass DAG
Orchestrated by run_v2_duckdb_pipeline() in src/vulnparse_pin/core/passes/__init__.py.
Step 2.1: Nmap Context Adapter (nmap_adapter@1.0)
Implemented in src/vulnparse_pin/core/passes/Nmap/nmap_adapter_pass.py.
- Opt-in via
--nmap/--nmap-ctx <nmap.xml>. - Streams Nmap XML using
safe_iterparse()(lxml.etree.iterparse+_xml_security.py). - Performs deterministic DuckDB reconciliation (
_reconcile_duckdb_hosts) ordered byasset_id ASC, reconciling hosts via hostname/IP/alias lookup (hostnamepreferred before IP), mergingopen_ports_json, separating unmatched Nmap hosts intounmatched_shadowassets, and inferring exposure for unmatched hosts (_infer_unmatched_internet_facing). - Non-blocking on missing/corrupt input; logs
NMAP_CTX_DISABLED,NMAP_CTX_ENABLED,NMAP_CTX_INVALID_FORMAT, orNMAP_CTX_FAILEDtoLedgerService. - See Nmap Context Deep Dive.
Step 2.2: Attack Capability Inference (ACI@2.0)
Implemented in src/vulnparse_pin/core/passes/ACI/aci_pass.py (ACIV2Pass).
- Evaluates finding titles, descriptions, plugin output, structured tags (e.g., Nuclei tags), CWEs (
CWE-78,CWE-89,CWE-502,CWE-798,CWE-918, etc.), and open ports from.vpp.db. - Enforces remote-service-only guardrails so bare port exposure without exploit/auth/RCE context does not fabricate remote execution capabilities.
- When
ml_pol.mode != "off"("shadow"default or"active"opt-in), evaluatesACIModel(aci_v3_core) per memoized finding signature and persistsml_capabilities_json,ml_attributions_json,ml_confidence, andml_model_idalongside rule-basedcapabilities_json,chains_json,matched_tokens_json,confidence, anduplift_scoreinaci_signals.
Step 2.3: Dual-Track Scoring (Scoring@3.0)
Implemented in src/vulnparse_pin/core/passes/Scoring/scoringPass.py (ScoringV3Pass).
- Reads
findings,assets,enrichment_snapshots, andaci_signalsfrom.vpp.db. - Scores Track A (
cve_threat): unified CVSS base score + monotonic piecewise EPSS v5 breakpoints + KEV/verified-exploit bonus (without double-counting KEV and Exploit-DB) + bounded-decay multi-CVE stacking (cve_aggregation_decay=0.35,max_contributors=8) + asset exposure/criticality adjustments +ml_uplift(0.0inshadow/off, up tomax_aci_uplift = 1.25when--ml-mode active). Note thatScoring@3.0Track A does not applysignal_reliabilityscaling ornmap_port_bonus. - Scores Track B (
exposure_weakness): severity baseline (or scanner CVSS) +ACI@2.0capability/chain/CWE uplifts + exposure bonus, multiplied bysignal_reliability, plusml_uplift(0.0inshadow/off, up to1.25when--ml-mode active). - Writes
raw_risk_score,operational_score,risk_band, andscore_trace_jsontoscores, and updatesassets.derived_criticality(Extreme/High/Medium/Low).
Step 2.4: Triage & SSVC Decisioning (Triage@2.0)
Implemented in src/vulnparse_pin/core/passes/Triage/triage_pass.py (TriageDecisionPass).
- Supports
--profile default(legacy OAL-compatibleP1/P2/P3/P4lanes) and--profile bod-26-04(CISA BOD 26-04 SSVC tree mapping toAct/Attend/Track*/Trackand3-day + Forensic Triage,14-day,60-day,Fix on Upgrade). - Applies
static_sast_p1_capguardrail so uncorroboratedstatic_sastfindings cannot saturateP1. - Evaluates
DecisionsRegistry(decisions.yamland inlineassets.yamldecisions) predicates (expires_at,in_kev,max_epss,max_epss_percentile,internet_facing,max_cvss), transitioning violated waivers todeferred_invalidated/accepted_invalidated(whilemitigatedstaysmitigatedinTriage@2.0; stored-assumption re-evaluation invpp diffcan additionally flagmitigated_invalidated). - Writes decisions,
assumed_state_json, andrationale_summarytotriage_decisions.
Step 2.5: Remediation Optimization (Remediation@1.0)
Implemented in src/vulnparse_pin/core/passes/Remediation/remediation_pass.py (RemediationPass).
- Clusters active (non-suppressed) findings into remediation candidates (
upgrade_package,rebuild_image,remediate_service,fix_code_location) and computes a deterministic Minimum Patch Set via greedy weighted set-cover. - Persists ranked actions (
rank,action_type,target_key,finding_count,asset_count,kev_count,p1_count,p2_count,pre_kev_count,operational_risk_reduced,cumulative_risk_share) toremediation_actionsand finding mappings toremediation_action_findings.
Step 2.6: Top-N Ranking (TopN@2.0)
Implemented in src/vulnparse_pin/core/passes/TopN/topn_pass.py (TopNV2Pass).
- Uses DuckDB window/ranking SQL over
findings,scores,triage_decisions,aci_signals,enrichment_snapshots, andassets. - Computes decay-weighted asset priority scores and deterministic per-asset and global top-N ranked lists ordered by priority tier (
P1..P4),operational_score DESC,epss_score DESC,aci.uplift_score DESC, andfinding_id ASC.
Step 2.7: Executive & Technical Summary (Summary@2.0)
Implemented in src/vulnparse_pin/core/passes/Summary/summary_pass.py (SummaryV2Pass).
- Aggregates DuckDB summary views into
SummaryPassOutput(overview,asset_summary,finding_summary,risk_distribution,top_risks,enrichment_metrics,remediation_priorities,decision_trace_summary), tracking shadow assets, CVSS provenance counts, SAST P1 caps, and invalidated decisions.
Phase 3: DiffEngine, Counterfactual Simulation, & Artifact Rendering
- Scan-over-Scan Diffing (
vpp diff/--baseline-run-id):DiffEngine(src/vulnparse_pin/core/diff_engine.py) compares two runs in.vpp.db, categorizing new high-risk findings, threat-intel escalations (KEV additions, EPSS threshold crossings0.04/0.10or percentile0.90/0.95, CVSS deltas>= 1.0), verified remediations, shadow-asset deltas, and stale-assumption waiver invalidations intodiff_events(with--fail-onsupportingp1,p2,kev,pre-kev,stale-assumption,none). - Counterfactual What-If Simulation (
vpp simulate): Evaluates read-only what-if scenarios overRemediation@1.0actions (--top,--action-id,--action-type,--target,--goal clear-kev|clear-p1|clear-3day|clear-pre-kev|risk-pct) and exports Markdown, JSON, or standalone simulator HTML. - Rendering & Exports (
export_v2_outputs/vpp export):src/vulnparse_pin/reporting/renderer.pyrenders self-contained Jinja2 artifacts viavpp export --format(dossier-md,dossier-html,roadmap-md,roadmap-html,remediation-json,remediation-md,simulator-html,csv,json) withautoescape+md_escape;csv_exporter.py,reportgen.py, andrunmanifest.pystream CSV/JSON exports and seal the chunkedRunManifest+ledger_events.
Legacy v1.x in-memory pass chain
For backward compatibility with ScanResult objects outside DuckDB, ScoringPass (Scoring@2.0), AttackCapabilityInferencePass (ACI@1.0), TopNPass (TopN@1.0), and SummaryPass (Summary@1.0) remain in src/vulnparse_pin/core/passes/.