Free CLI SARIF Pro Gate & Line Precision
Context & Objectives¶
--format sarif is a Verity Pro capability, but the Free CLI must describe that
boundary honestly and deterministically. Two properties matter to a CI customer:
- A Free installation asked for SARIF never writes a partial or empty artifact; it
returns the structured
PRO_FEATURE_REQUIREDerror and exit code2. - When
verity-prois installed, the exported SARIF preserves the real source line and the real file path instead of collapsing every result tostartLine: 1.
This task hardens the Free CLI gate and the line-number propagation only.
Scope¶
| File | Change |
|---|---|
src/verity/cli.py |
Pro-plugin gate for --format sarif and real line/path propagation |
tests/unit/cli/test_sarif_pro_gate.py |
Gate and paired Pro-present control |
tests/unit/cli/test_sarif_line_precision.py |
Line propagation and startLine == 1 fallback |
Out of scope: any reporting engine internals outside the Free CLI surface.
Contract¶
Pro-only gate¶
_pro_plugin_available()remains the single source of truth for edition detection.- When the
verity-proplugin is absent and--format sarifis requested, the CLI must emit the structuredPRO_FEATURE_REQUIREDpayload and return exit code2. - No output file is created or truncated when the gate fires, even if
--outputwas supplied. - No unhandled traceback escapes; the failure is the structured error only.
Line and path precision¶
When the plugin is present, every SARIF result must carry:
physicalLocation.artifactLocation.uriset to the realfile_pathfrom the finding.physicalLocation.region.startLineset tofinding.get('line_number') or finding.get('line') or 1.
A finding without a usable location must degrade to startLine == 1 rather than
omitting the region or crashing.
ATDD Traceability Matrix¶
| Acceptance Criterion | Test Level | Target File / Function | Description | Status |
|---|---|---|---|---|
| AC-40.1 | unit | tests/unit/cli/test_sarif_pro_gate.py::test_sarif_requires_pro_plugin |
Free emits PRO_FEATURE_REQUIRED, exit code 2, and writes no artifact; paired Pro-present control exports successfully. |
Done |
| AC-40.2 | unit | tests/unit/cli/test_sarif_line_precision.py::test_sarif_preserves_line |
Real source line survives export; missing location falls back to startLine == 1. |
Done |
| AC-40.3 | static | uv run ruff check src tests |
Zero lint findings. | Done |
Validation Commands¶
uv run pytest tests/unit/cli/test_sarif_pro_gate.py tests/unit/cli/test_sarif_line_precision.py -q
uv run ruff check src tests
Delivery Checklist¶
- [x]
--format sarifreturnsPRO_FEATURE_REQUIREDwith exit code2when the plugin is absent. - [x] Gate writes no output file, including when
--outputis supplied. - [x] SARIF
region.startLineuses the real finding line. - [x] SARIF
artifactLocation.uriuses the real finding file path. - [x] Missing-location fallback yields
startLine == 1. - [x] Paired test files committed and
uv run ruff check src testsclean.