← Verifying a Document

PYTHON Python verifier

Uses jsonschema (Draft 2020-12) and requests to fetch the schema at runtime.

1
Install
pip install jsonschema[format-nongpl] requests
2
Verify
verify_dbom.py
import json, sys, requests, jsonschema

SCHEMA_URL = "https://usemakoto.dev/schema/v0.1.json"

dbom   = json.load(open(sys.argv[1]))
schema = requests.get(SCHEMA_URL, timeout=10).json()
steps  = dbom["lineage"]

# structural
errors = [
    f"[{' → '.join(str(p) for p in e.absolute_path) or 'root'}] {e.message}"
    for e in jsonschema.Draft202012Validator(schema).iter_errors(dbom)
]

# provenance
for i in range(1, len(steps)):
    if steps[i]["input_hash"] != steps[i-1]["output_hash"]:
        errors.append(f"step {steps[i]['step']} input_hash does not match step {steps[i-1]['step']} output_hash")
if steps[-1]["output_hash"] != dbom["source"]["hash"]["value"]:
    errors.append("final output_hash does not match source.hash.value")

for e in errors: print(f"✗ {e}")
sys.exit(1 if errors else 0)

For production use with full error reporting, see the GitHub repo →