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

Function validate_manifest

tools/materialize-bench/imported_guest.py:33–49  ·  view source on GitHub ↗
(manifest)

Source from the content-addressed store, hash-verified

31
32
33def validate_manifest(manifest):
34 if not manifest['files']:
35 raise ValueError('empty manifest')
36 tip = manifest['git_tip']
37 if len(tip) not in (40, 64) or any(char not in '0123456789abcdef' for char in tip):
38 raise ValueError('invalid pinned Git tip')
39 paths = set()
40 for file in manifest['files']:
41 name = file['path']
42 path = PurePosixPath(name)
43 if not name or not path.parts or path.is_absolute() or '..' in path.parts or path.parts[0] in ('.git', '.atomic') or str(path) != name:
44 raise ValueError('unsafe or noncanonical fixture path: ' + name)
45 if name in paths or file['mode'] not in ('100644', '100755', '120000'):
46 raise ValueError('duplicate path or unsupported mode')
47 if len(file['sha256']) != 64 or any(char not in '0123456789abcdef' for char in file['sha256']):
48 raise ValueError('invalid expected content hash')
49 paths.add(name)
50
51
52def isolated_env(root):

Callers 2

prepareFunction · 0.70
measureFunction · 0.70

Calls 2

setFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected