Skip to main content
VulnParse-Pin emblem VulnParse-Pin emblem
VulnParse-Pin
Installation and Usage Testing Guide.md
View source on GitHub ↗

Testing Guide

This guide explains how to run tests, check v2.1.1 feature suites, and verify performance benchmarks in VulnParse-Pin.

Prerequisites

  1. Python 3.11+ environment
  2. Editable install with dev and optional TUI ([ui]) dependencies:
python -m venv .venv
# Linux / macOS:
source .venv/bin/activate
# Windows PowerShell:
# .venv\Scripts\Activate.ps1
# Windows cmd.exe:
# .venv\Scripts\activate.bat

pip install -e ".[dev,ui]"

NOTEtest_tui_pilot.py and interactive vpp ui checks require the [ui] extra (textual>=2.1.0), whereas vpp gui and test_gui_workbench.py run with zero extra dependencies. Optional extras [ml] (onnxruntime) and [ml-train] (scikit-learn) unlock ONNX inference and model retraining checks. Full CI parity installs from the hash-locked packaging/requirements-ci.txt closure (--require-hashes --only-binary=:all: plus --no-isolation local wheel build for .[dev,ui,mcp,sbom]) alongside the system packages groff-base, gnupg, zstd, rpm, and createrepo-c.

Test Suite Layout (v2.1.1)

Core v2.1 ML, Remediation, Workbench & Inventory Suites

  • tests/test_ml_aci_v3.py: ACI@3.0 distilled ML capability inference, ml.mode: shadow parity (scores unchanged unless active), signed artifact validation (VP_MODEL_HMAC_KEY), and size/symlink guards
  • tests/test_epss_velocity_pre_kev.py: EPSSFeedCache 90-day epss_history tracking, EPSS velocity deltas (7d/30d/slope), Pre-KEV predictions, and enrichment_snapshots persistence
  • tests/test_vpp_ml_cli.py: vpp ml subcommands (status, eval, calibrate, train) and JSON outputs
  • tests/test_remediation_optimizer.py: Remediation@1.0 minimum-patch-set clustering, set-cover ranking, remediation_actions / remediation_action_findings tables (14-table DuckDB schema), and read-only simulation
  • tests/test_simulate_cli_and_qbr.py: vpp simulate flags (--top, --goal, --action-id, --target), QBR Markdown/JSON exports, and standalone simulator-html
  • tests/test_mcp_server.py: vpp mcp (stdio and streamable-http), --allow-write gating, Host/Origin/Bearer security checks, and SEP-1865 workbench resource
  • tests/test_gui_workbench.py: vpp gui local HTTP workbench (X-VPP-CSRF, zero-CDN CSP, read-only default vs --allow-write deferral/Shadow-IT promotion, exports)
  • tests/test_inventory_compiler.py: vpp assets (compile, audit, bootstrap), multi-source CMDB/cloud/Nmap compilation, pinned-field preservation, and --fail-on exit codes
  • tests/test_cli_v21_roundtable.py: End-to-end v2.1.0 cross-feature CLI integration (all 13 subcommands, ml_governance in RunManifest, --fail-on pre-kev, and ensure_v21_schema() migration)
  • tests/test_validation_showcase.py: Sanitized multi-scanner operational validation showcase checks
  • tests/test_cicd_codeql_and_py311_gates.py: CI/CD workflow CodeQL anti-cache-poisoning and tag-gating checks, ci.yml/release.yml dependency parity, .gitignore and 0o644 static asset hygiene, and repo-wide Python 3.11+ syntax compatibility
  • tests/test_fuzz_parsers.py: 4-pillar tests for the Atheris parser fuzzing harness (fuzz/fuzz_parsers.py and Atheris-free fuzz/targets.py) covering valid parser formats, 64 KiB boundary & zero temp-dir leak checks, offline socket isolation & SchemaDetector routing, hostile XXE/UTF-16/deep-JSON corpora, and strict non-masking of KeyError/IndexError/RecursionError
  • tests/test_packaging_repos_and_homebrew.py: End-to-end APT (.deb) and RPM (.rpm) repository generation, RPM 4.18+ rpmbuild/rpmsign/rpmkeys/createrepo_c signing (both padded and unpadded RPMs, tampered-sig/foreign-key rejections, EphemeralGPGSigner macro/path safety), and Homebrew bottle/formula verification

Core v2.0 DuckDB, Pipeline, CLI & TUI Suites

  • tests/test_storage_duckdb.py: 14-table DuckDB .vpp.db schema (including v2.0.x -> v2.1.0 automatic migration), 0o600 POSIX permissions, symlink rejection, appender ingestion, deduplication, and parameterized UI/summary queries
  • tests/test_assets_context.py: AssetContextMatcher (5-tier IP/FQDN/URI/CIDR/glob matching & shadow assets) and DecisionsRegistry predicates + comment-preserving upsert_decision
  • tests/test_bod_26_04.py: --profile bod-26-04 vs default SSVC actions (Act/Attend/Track*/Track), SLA buckets, and static_sast P1-cap guardrail
  • tests/test_scoring_v2.py: Scoring@3.0 dual-track (cve_threat + exposure_weakness), EPSS v5 monotonic piecewise breakpoints, Signal Reliability weighting, and score_trace
  • tests/test_aci_v2.py: ACI@2.0 DuckDB signal enrichment across finding_cves, finding_evidence, and non-CVE Track B findings
  • tests/test_diff_engine.py: DiffEngine scan-over-scan deltas, stale-assumption deferral invalidations, and evaluate_fail_gate exit code 2
  • tests/test_reporting_v2.py: Decision Defense Dossiers (HTML/MD), Executive Roadmaps, Remediation & Simulator exports, Diff PR comments, streaming DuckDB CSV/JSON exports, and RunManifest digest sealing
  • tests/test_cli_v2.py: Subcommand CLI (13 subcommands), read-only vpp verify, exit codes, and legacy compatibility shims
  • tests/test_tui_pilot.py: Textual VppApp pilot tests (tier/track/KEV/shadow filters, search, pagination, diff tab, dossier export, and deferral modal)
  • tests/test_demo_offline.py: 100% offline vpp demo end-to-end execution and bundled multi-scanner fixture validation

Parser, Security, Intel & Integration Suites

  • tests/test_xxe_hardening.py: Hardened streaming lxml.etree.iterparse XML guards blocking external DTDs, XXE, and Billion Laughs while permitting benign <!DOCTYPE nmaprun> / <!DOCTYPE SCAN>
  • tests/test_streaming_parsers.py: Bounded 64 KB sniffing, UTF-8 BOM handling, iter_batches(), chunked SARIF 2.1.0, Nuclei JSONL, and --allow-large (up to 50 GiB)
  • tests/test_intel_v2.py: CVSS v4.0/v3.x/v2.0 provenance precedence, EPSS v5 / KEV SQLite caches, GHSA package index, OSV archive hardening, and vpp intel status/sync
  • tests/test_iter1_intel_sec.py, tests/test_iter1_math_diff.py, tests/test_iter1_parsers_cli.py: Iteration 1 security, math/diff, and parser/CLI hardening regression tests
  • tests/test_iter2_cross_component.py: Iteration 2 cross-component security, CVSS provenance, TUI/Dossier, and bod-26-04 contract tests

Legacy & Contract Suites

  • tests/test_parser_*.py, tests/test_xml_parsers_realworld.py: Parser behavior, fallback paths, and real-world XML fixture checks
  • tests/test_pass_contracts.py: Pass interface, dependency DAG, and backward-compatibility checks
  • tests/test_cvss_utils.py: Clean-room Apache-2.0 CVSS v2.0 / v3.x / v4.0 calculator and resolve_effective_cvss_fields
  • tests/test_runmanifest.py: RunManifest v2 schema, ml_governance, SHA-256 hash-chained decision ledger, and vpp verify enforcement
  • tests/test_security_hardening.py, tests/test_pfh.py, tests/test_csv_sanitization.py: PermFileHandler path policy, CSV formula sanitization, and symlink/root confinement
  • tests/test_topn_exposure_inference.py: Exposure and finding-text inference reliability guards (consolidates the former test_topn_finding_text_inference.py and test_topn_inference_reliability_benchmark.py)

Full suite

Run the entire test suite directly on a fresh clone (all required fixtures are bundled in the repository):

# Verbose run
pytest tests/ -v

# Quiet summary run
pytest -q

Targeted v2.1 ML, Remediation, Workbench & Inventory verification

pytest tests/test_ml_aci_v3.py tests/test_epss_velocity_pre_kev.py tests/test_vpp_ml_cli.py tests/test_remediation_optimizer.py tests/test_simulate_cli_and_qbr.py tests/test_mcp_server.py tests/test_gui_workbench.py tests/test_inventory_compiler.py tests/test_cli_v21_roundtable.py tests/test_validation_showcase.py tests/test_cicd_codeql_and_py311_gates.py -v

Targeted v2.0 pipeline & storage verification

pytest tests/test_storage_duckdb.py tests/test_assets_context.py tests/test_scoring_v2.py tests/test_aci_v2.py tests/test_bod_26_04.py -v

CLI, Diff, Reporting, RunManifest & TUI verification

pytest tests/test_cli_v2.py tests/test_diff_engine.py tests/test_reporting_v2.py tests/test_runmanifest.py tests/test_tui_pilot.py tests/test_demo_offline.py -v

Security, streaming parsers, fuzzing, packaging & threat-intel verification

pytest tests/test_xxe_hardening.py tests/test_streaming_parsers.py tests/test_fuzz_parsers.py tests/test_packaging_repos_and_homebrew.py tests/test_intel_v2.py tests/test_cvss_utils.py tests/test_security_hardening.py -v

Coverage-Guided Parser Fuzzing (fuzz/)

VulnParse-Pin ships a coverage-guided Atheris harness (fuzz/fuzz_parsers.py) backed by an Atheris-free target (fuzz/targets.py) so standard pytest runs require no Atheris installation while continuous fuzzers can instrument all parsers offline:

# Run the 4-pillar offline fuzzing regression suite without Atheris
pytest tests/test_fuzz_parsers.py -v

# Optional: run coverage-guided fuzzing locally with Atheris installed
python fuzz/fuzz_parsers.py -max_len=65536 -runs=10000

Release Drift Gate & Non-Prod Rehearsal (scripts/check_release_drift.py)

Before pushing release branches, packaging changes, container manifests, or documentation updates, run the zero-dependency release drift gate locally (automatically enforced on PRs and release branches by .github/workflows/release-rehearsal.yml):

# Verify version, changelog, lockfile, ignore, workflow, and documentation parity (stdlib-only)
python scripts/check_release_drift.py

Iteration 1 & 2 cross-component suites

pytest tests/test_iter1_intel_sec.py tests/test_iter1_math_diff.py tests/test_iter1_parsers_cli.py tests/test_iter2_cross_component.py -v

Exposure Inference Invariant Notes

  • tests/test_topn_exposure_inference.py: Consolidated regression and reliability suite covering finding-text and exposure inference rules (replacing the former test_topn_finding_text_inference.py and test_topn_inference_reliability_benchmark.py). Run it whenever adjusting tn_triage.json, exposure rules, or TopN ranking logic.

Scale & Performance Validation (benchmarks/bench_scale.py)

Use benchmarks/bench_scale.py to benchmark end-to-end streaming ingestion, matched-CVE snapshot hydration, the DuckDB pass DAG, and paged UI/summary queries in isolated subprocesses:

# Quick developer smoke benchmark (10,000 findings)
python benchmarks/bench_scale.py --findings 10000

# Full 500k-700k scale benchmark with JSON output
python benchmarks/bench_scale.py --findings 500000 --findings 700000 --json-out bench_v2_results.json

See Benchmarks and Performance Optimizations for measured v2.0.0 reference numbers and hardware context.

Test Expectations for Changes

  1. Parser changes: Preserve iter_batches() streaming, XXE/prolog safety, --allow-large (up to 50 GiB), and ingestion confidence/evidence fidelity.
  2. Scoring, ML, remediation & triage changes: Preserve deterministic Scoring@3.0, ACI@2.0/ACI@3.0 (ml.mode: shadow score parity), Triage@2.0 (default and bod-26-04), Remediation@1.0, and DiffEngine stale-assumption contracts.
  3. Schema or output changes: Update schemas under src/vulnparse_pin/core/schemas/, storage/schema.sql, ensure_v21_schema(), and validation tests together.
  4. RunManifest & CLI changes: Validate read-only vpp verify, exit codes (0, 1, 2), and RunManifest digest/ledger/ml_governance verification.

PR Verification Checklist

  1. Run focused tests for changed modules (and the full suite via pytest tests/ -v or pytest -q for non-trivial changes).
  2. Confirm tests/test_topn_exposure_inference.py passes when touching scoring, ACI, exposure inference, or triage rules.
  3. Include exact commands and observed pass/fail counts in your PR description.