Skip to content

Commit 0ab9211

Browse files
fix: use chunked read for extension manifest hash
Replace unbounded f.read() with chunked iteration to prevent excessive memory allocation on large or corrupted manifest files. Matches the pattern used in integrations/manifest.py _sha256().
1 parent be33d2a commit 0ab9211

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/specify_cli/extensions/__init__.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,11 @@ def hooks(self) -> Dict[str, Any]:
509509

510510
def get_hash(self) -> str:
511511
"""Calculate SHA256 hash of manifest file."""
512+
h = hashlib.sha256()
512513
with open(self.path, "rb") as f:
513-
return f"sha256:{hashlib.sha256(f.read()).hexdigest()}"
514+
for chunk in iter(lambda: f.read(8192), b""):
515+
h.update(chunk)
516+
return f"sha256:{h.hexdigest()}"
514517

515518

516519
class ExtensionRegistry:

0 commit comments

Comments
 (0)