M18: Sync SARIF Exporter Driver Version with verity.__version__¶
- Task ID:
M18 - Priority:
P1(Master Rank#7, Track B — Simple Fixes, Docs & CI Hygiene) - Status:
Done - Dependencies:
M7,M11 - Target Repository:
/Users/ivan/Project/3t.tools.intellij/verityredteam-free(verity-redteam-core) - GitHub Project #5: Verity RedTeam Free Task Board
1. Context & Problem Statement¶
_stdlib_sarif_exporter() (src/verity/cli.py, ~line 106) hardcodes the SARIF tool driver version:
src/verity/__init__.py declares __version__ = "0.2.0", and pyproject.toml declares version = "0.2.0". Result: SARIF output reports 0.1.0, diverging from the rest of the package. This breaks downstream SARIF consumers (GitHub Code Scanning, IDE integrations) that correlate tool version with baseline state — version desync can suppress or duplicate alerts.
2. Requirements & Target Files¶
- Single Source of Truth: Replace the hardcoded
"0.1.0"in_stdlib_sarif_exporter()withverity.__version__(imported from the package root) so the SARIF driver version always tracks the package. - No Regressions: Preserve the existing SARIF v2.1.0 structure (
$schema,version,runs[].tool.driver,rules,results); only the driver version string changes. - Plugin Path Parity: The
verity-proplugin exporter path (_load_sarif_exporter()) is unchanged; the stdlib fallback (_stdlib_sarif_exporter()) is the only edited code path. - Forward Safety: Any future version bump in
pyproject.toml/verity.__version__must propagate automatically — no second hardcoded version constant anywhere insrc/.
3. Automated Tests to Verify (tests/unit/test_cli_auditor_parity.py)¶
test_sarif_driver_version_matches_package(): invokecli.main(["scan", "--format", "sarif"])with the stdlib fallback (monkeypatched_iter_plugin_entry_pointsreturning a stub entry point), parse the JSON output, and assert:data["runs"][0]["tool"]["driver"]["version"] == verity.__version__test_sarif_driver_version_matches_pyproject(): readpyproject.toml(tomllibon Python 3.12+), assertpyproject["project"]["version"] == verity.__version__— guarantees the three sources (pyproject.toml,verity.__version__, SARIF driver) stay in lockstep.- Extend the existing
test_scan_sarif_stdlib_fallbackwith an assertion thatdata["runs"][0]["tool"]["driver"]["version"] == verity.__version__.
4. Acceptance Scenario in Clean Container with Real MCP Server Config¶
Extend tests/e2e_containers/verify_all_scenarios.sh with a new step (inside Scenario 1, or a dedicated Scenario 7):
- Generate a real MCP server config (e.g.
@modelcontextprotocol/server-fetchvianpx -y …) at~/.cursor/mcp.json— reuse the existing fixture. - Export SARIF using the stdlib fallback path (
verity-pronot installed in the container): - Assertions (Python one-liner in the script):
json.loads(open("$OUT_DIR/sarif.json"))["runs"][0]["tool"]["driver"]["version"]equals the installed package version reported bypython -c "import verity; print(verity.__version__)".- Exit
0(findings present, no--fail-on-findings); SARIF parses as valid JSON;versionfield is2.1.0. scan_for_leaks "$OUT_DIR"remains clean (no secrets in SARIF output).
5. Verification Commands¶
cd /Users/ivan/Project/3t.tools.intellij/verityredteam-free
uv run ruff check src tests
uv run pytest tests/unit/test_cli_auditor_parity.py -v -k sarif
uv run pytest tests/
INSTALL_SOURCE=wheel ./tests/e2e_containers/run_e2e.sh
6. Acceptance Criteria¶
- [ ]
_stdlib_sarif_exporter()usesverity.__version__; no hardcoded version string remains insrc/verity/cli.py. - [ ] Unit tests assert SARIF
runs[0].tool.driver.version == verity.__version__and thatpyproject.tomlversion matches, preventing future drift. - [ ] Container E2E scenario runs
verity scan --format sarifagainst a real MCP config and confirms the driver version matches the installed package version. - [ ]
uv run pytest tests/,uv run ruff check src tests, andINSTALL_SOURCE=wheel ./tests/e2e_containers/run_e2e.shall pass cleanly.