Testing Guide
This guide explains how to run tests, check v2.1.1 feature suites, and verify performance benchmarks in VulnParse-Pin.
Prerequisites
- Python 3.11+ environment
- 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]"
NOTE
test_tui_pilot.pyand interactivevpp uichecks require the[ui]extra (textual>=2.1.0), whereasvpp guiandtest_gui_workbench.pyrun 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-lockedpackaging/requirements-ci.txtclosure (--require-hashes --only-binary=:all:plus--no-isolationlocal wheel build for.[dev,ui,mcp,sbom]) alongside the system packagesgroff-base,gnupg,zstd,rpm, andcreaterepo-c.
Test Suite Layout (v2.1.1)
Core v2.1 ML, Remediation, Workbench & Inventory Suites
tests/test_ml_aci_v3.py:ACI@3.0distilled ML capability inference,ml.mode: shadowparity (scores unchanged unlessactive), signed artifact validation (VP_MODEL_HMAC_KEY), and size/symlink guardstests/test_epss_velocity_pre_kev.py:EPSSFeedCache90-dayepss_historytracking, EPSS velocity deltas (7d/30d/slope), Pre-KEV predictions, andenrichment_snapshotspersistencetests/test_vpp_ml_cli.py:vpp mlsubcommands (status,eval,calibrate,train) and JSON outputstests/test_remediation_optimizer.py:Remediation@1.0minimum-patch-set clustering, set-cover ranking,remediation_actions/remediation_action_findingstables (14-table DuckDB schema), and read-only simulationtests/test_simulate_cli_and_qbr.py:vpp simulateflags (--top,--goal,--action-id,--target), QBR Markdown/JSON exports, and standalonesimulator-htmltests/test_mcp_server.py:vpp mcp(stdioandstreamable-http),--allow-writegating,Host/Origin/Bearer security checks, and SEP-1865 workbench resourcetests/test_gui_workbench.py:vpp guilocal HTTP workbench (X-VPP-CSRF, zero-CDN CSP, read-only default vs--allow-writedeferral/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-onexit codestests/test_cli_v21_roundtable.py: End-to-endv2.1.0cross-feature CLI integration (all 13 subcommands,ml_governanceinRunManifest,--fail-on pre-kev, andensure_v21_schema()migration)tests/test_validation_showcase.py: Sanitized multi-scanner operational validation showcase checkstests/test_cicd_codeql_and_py311_gates.py: CI/CD workflow CodeQL anti-cache-poisoning and tag-gating checks,ci.yml/release.ymldependency parity,.gitignoreand0o644static asset hygiene, and repo-wide Python 3.11+ syntax compatibilitytests/test_fuzz_parsers.py: 4-pillar tests for the Atheris parser fuzzing harness (fuzz/fuzz_parsers.pyand Atheris-freefuzz/targets.py) covering valid parser formats, 64 KiB boundary & zero temp-dir leak checks, offline socket isolation &SchemaDetectorrouting, hostile XXE/UTF-16/deep-JSON corpora, and strict non-masking ofKeyError/IndexError/RecursionErrortests/test_packaging_repos_and_homebrew.py: End-to-end APT (.deb) and RPM (.rpm) repository generation, RPM 4.18+rpmbuild/rpmsign/rpmkeys/createrepo_csigning (both padded and unpadded RPMs, tampered-sig/foreign-key rejections,EphemeralGPGSignermacro/path safety), and Homebrew bottle/formula verification
Core v2.0 DuckDB, Pipeline, CLI & TUI Suites
tests/test_storage_duckdb.py: 14-table DuckDB.vpp.dbschema (includingv2.0.x -> v2.1.0automatic migration),0o600POSIX permissions, symlink rejection, appender ingestion, deduplication, and parameterized UI/summary queriestests/test_assets_context.py:AssetContextMatcher(5-tier IP/FQDN/URI/CIDR/glob matching & shadow assets) andDecisionsRegistrypredicates + comment-preservingupsert_decisiontests/test_bod_26_04.py:--profile bod-26-04vsdefaultSSVC actions (Act/Attend/Track*/Track), SLA buckets, andstatic_sastP1-cap guardrailtests/test_scoring_v2.py:Scoring@3.0dual-track (cve_threat+exposure_weakness), EPSS v5 monotonic piecewise breakpoints, Signal Reliability weighting, andscore_tracetests/test_aci_v2.py:ACI@2.0DuckDB signal enrichment acrossfinding_cves,finding_evidence, and non-CVE Track B findingstests/test_diff_engine.py:DiffEnginescan-over-scan deltas, stale-assumption deferral invalidations, andevaluate_fail_gateexit code2tests/test_reporting_v2.py: Decision Defense Dossiers (HTML/MD), Executive Roadmaps, Remediation & Simulator exports, Diff PR comments, streaming DuckDB CSV/JSON exports, andRunManifestdigest sealingtests/test_cli_v2.py: Subcommand CLI (13 subcommands), read-onlyvpp verify, exit codes, and legacy compatibility shimstests/test_tui_pilot.py: TextualVppApppilot tests (tier/track/KEV/shadow filters, search, pagination, diff tab, dossier export, and deferral modal)tests/test_demo_offline.py: 100% offlinevpp demoend-to-end execution and bundled multi-scanner fixture validation
Parser, Security, Intel & Integration Suites
tests/test_xxe_hardening.py: Hardened streaminglxml.etree.iterparseXML 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, andvpp intel status/synctests/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 teststests/test_iter2_cross_component.py: Iteration 2 cross-component security, CVSS provenance, TUI/Dossier, andbod-26-04contract tests
Legacy & Contract Suites
tests/test_parser_*.py,tests/test_xml_parsers_realworld.py: Parser behavior, fallback paths, and real-world XML fixture checkstests/test_pass_contracts.py: Pass interface, dependency DAG, and backward-compatibility checkstests/test_cvss_utils.py: Clean-room Apache-2.0 CVSS v2.0 / v3.x / v4.0 calculator andresolve_effective_cvss_fieldstests/test_runmanifest.py:RunManifestv2 schema,ml_governance, SHA-256 hash-chained decision ledger, andvpp verifyenforcementtests/test_security_hardening.py,tests/test_pfh.py,tests/test_csv_sanitization.py:PermFileHandlerpath policy, CSV formula sanitization, and symlink/root confinementtests/test_topn_exposure_inference.py: Exposure and finding-text inference reliability guards (consolidates the formertest_topn_finding_text_inference.pyandtest_topn_inference_reliability_benchmark.py)
Recommended Test Commands
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 formertest_topn_finding_text_inference.pyandtest_topn_inference_reliability_benchmark.py). Run it whenever adjustingtn_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
- Parser changes: Preserve
iter_batches()streaming, XXE/prolog safety,--allow-large(up to 50 GiB), and ingestion confidence/evidence fidelity. - Scoring, ML, remediation & triage changes: Preserve deterministic
Scoring@3.0,ACI@2.0/ACI@3.0(ml.mode: shadowscore parity),Triage@2.0(defaultandbod-26-04),Remediation@1.0, andDiffEnginestale-assumption contracts. - Schema or output changes: Update schemas under
src/vulnparse_pin/core/schemas/,storage/schema.sql,ensure_v21_schema(), and validation tests together. - RunManifest & CLI changes: Validate read-only
vpp verify, exit codes (0,1,2), andRunManifestdigest/ledger/ml_governanceverification.
PR Verification Checklist
- Run focused tests for changed modules (and the full suite via
pytest tests/ -vorpytest -qfor non-trivial changes). - Confirm
tests/test_topn_exposure_inference.pypasses when touching scoring, ACI, exposure inference, or triage rules. - Include exact commands and observed pass/fail counts in your PR description.