Skip to content

Commit ba8c991

Browse files
Reject nested Grype database statuses marked invalid (db.status.valid: false)
Codex review P1 on #170: the db.status merge ignored the scanner-declared validity flag, so an invalid-database report with zero matches could pass the severity gate and ship as release security evidence. Reject such reports explicitly; adds a regression test. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
1 parent de50050 commit ba8c991

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

scripts/release_evidence.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,10 @@ def container_scan_artifact(root: Path, path: Path) -> dict[str, Any]:
722722
# wrote built/schemaVersion/checksum|from directly on db. Accept both shapes.
723723
status = database.get("status")
724724
if isinstance(status, dict):
725+
if status.get("valid") is False:
726+
raise EvidenceError(
727+
"container vulnerability database is marked invalid by the scanner"
728+
)
725729
database = {**database, **status}
726730
built = database.get("built")
727731
schema_version = database.get("schemaVersion")

tests/test_release_evidence.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,30 @@ def test_release_evidence_accepts_grype_0110_nested_db_status_shape(tmp_path):
11431143
}
11441144

11451145

1146+
def test_release_evidence_rejects_grype_0110_database_marked_invalid(tmp_path):
1147+
root = _root(tmp_path)
1148+
dist = _dist(root)
1149+
inputs = _release_inputs(root, dist)
1150+
report = json.loads(inputs["image_scan"].read_text(encoding="utf-8"))
1151+
report["descriptor"]["db"] = {
1152+
"status": {
1153+
"schemaVersion": "v6.1.9",
1154+
"from": (
1155+
"https://grype.anchore.io/databases/v6/vulnerability-db_v6.1.9_"
1156+
"2026-08-25T00:17:00Z_1787638635.tar.zst"
1157+
"?checksum=sha256%3A" + "f" * 64
1158+
),
1159+
"built": "2026-08-25T06:17:15Z",
1160+
"path": "/home/runner/.cache/grype/db/6/vulnerability.db",
1161+
"valid": False,
1162+
},
1163+
}
1164+
inputs["image_scan"].write_text(json.dumps(report), encoding="utf-8")
1165+
1166+
with pytest.raises(EvidenceError, match="marked invalid"):
1167+
_build(root, dist, inputs=inputs)
1168+
1169+
11461170
def test_repair_run_candidates_are_newest_first_and_bound_to_tag_commit_event():
11471171
runs = [
11481172
{

0 commit comments

Comments
 (0)