MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / admitted_json

Function admitted_json

tools/provenance-export/verify_dsse.py:40–59  ·  view source on GitHub ↗
(raw)

Source from the content-addressed store, hash-verified

38
39
40def admitted_json(raw):
41 if len(raw) > MAX_BYTES:
42 raise ValueError("export exceeds 8 MiB limit")
43 value = json.loads(raw.decode("utf-8"), object_pairs_hook=unique_object, parse_int=integer,
44 parse_float=refuse_number, parse_constant=refuse_number)
45 def validate(item, depth=0):
46 if isinstance(item, (dict, list)):
47 if depth >= 128:
48 raise ValueError("JSON exceeds nesting limit")
49 if isinstance(item, dict):
50 for key, child in item.items():
51 key.encode("utf-8", errors="strict")
52 validate(child, depth + 1)
53 else:
54 for child in item:
55 validate(child, depth + 1)
56 elif isinstance(item, str):
57 item.encode("utf-8", errors="strict")
58 validate(value)
59 return value
60
61
62def decode(value):

Callers 1

verifyFunction · 0.85

Calls 2

validateFunction · 0.70
decodeMethod · 0.45

Tested by

no test coverage detected