test_sarif_validates_against_the_official_schema¶
Tests › tests/test_guard_report_formats.py
What this test is for
Why it exists
The SARIF log is schema-valid, with a rule for every check class.
Given
log = json.loads(render(_VIOLATIONS, "sarif"))jsonschema.validate(log, json.loads(_SCHEMA.read_text()))(run,) = log["runs"]
When
- —
Then
- ✓ {r["id"] for r in run["tool"]["driver"]["rules"]} is at least {"presence", "version", "tag"}
- ✓ [ r["locations"][0]["physicalLocation"]["region"]["startLine"] for r in run["results"] ] equals [3, 12, 7]
tests/test_guard_report_formats.py:38 · its file's page
What it checks (2)
assert {r["id"] for r in run["tool"]["driver"]["rules"]} >= {"presence", "version", "tag"}not attributedassert [ r["locations"][0]["physicalLocation"]["region"]["startLine"] for r in run["results"] ] == [3, 12, 7]not attributed
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 1 requirement
Its run touches their code; that is reach, not proof.
- REQ-DDB-GUARD-001 measured