test_sarif_validates_against_the_official_schema

Tests › tests/test_guard_report_formats.py

passed Passed in the packaged run.

What this test is for

Why it exists

The SARIF log is schema-valid, with a rule for every check class.

Given

  1. log = json.loads(render(_VIOLATIONS, "sarif"))
  2. jsonschema.validate(log, json.loads(_SCHEMA.read_text()))
  3. (run,) = log["runs"]
→

When

  1. —
→

Then

  1. ✓ {r["id"] for r in run["tool"]["driver"]["rules"]} is at least {"presence", "version", "tag"}
  2. ✓ [ 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)

  1. assert {r["id"] for r in run["tool"]["driver"]["rules"]} >= {"presence", "version", "tag"} not attributed
  2. assert [ 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.