MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / _identity

Function _identity

scripts/test-impact/coverage_live_v2.py:110–132  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

108
109
110def _identity(path):
111 fd = _regular(path)
112 try:
113 before = os.fstat(fd)
114 if before.st_size > 1024 * 1024 * 1024:
115 _error("resource_limit", "executable exceeds 1GiB identity limit")
116 digest = hashlib.sha256()
117 size = 0
118 while True:
119 part = os.read(fd, 65536)
120 if not part:
121 break
122 size += len(part)
123 if size > 1024 * 1024 * 1024:
124 _error("resource_limit", "executable grew beyond identity limit")
125 digest.update(part)
126 if _signature(before) != _signature(os.fstat(fd)) or size != before.st_size:
127 _error("identity", "executable changed while hashing")
128 if not os.access(path, os.X_OK):
129 _error("input", "executable is not executable")
130 return {"path": path, "sha256": digest.hexdigest(), "bytes": size}
131 finally:
132 os.close(fd)
133
134
135def _pairs(values):

Callers 1

collectFunction · 0.85

Calls 6

_regularFunction · 0.85
_errorFunction · 0.85
_signatureFunction · 0.85
updateMethod · 0.80
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected