From 0ab9211cea38fc169fe4f8f1e5d75e644f2bdaff Mon Sep 17 00:00:00 2001 From: Quratulain-bilal Date: Wed, 29 Jul 2026 12:54:12 +0500 Subject: [PATCH] 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(). --- src/specify_cli/extensions/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/specify_cli/extensions/__init__.py b/src/specify_cli/extensions/__init__.py index 6cd48582b0..834811498e 100644 --- a/src/specify_cli/extensions/__init__.py +++ b/src/specify_cli/extensions/__init__.py @@ -509,8 +509,11 @@ def hooks(self) -> Dict[str, Any]: def get_hash(self) -> str: """Calculate SHA256 hash of manifest file.""" + h = hashlib.sha256() with open(self.path, "rb") as f: - return f"sha256:{hashlib.sha256(f.read()).hexdigest()}" + for chunk in iter(lambda: f.read(8192), b""): + h.update(chunk) + return f"sha256:{h.hexdigest()}" class ExtensionRegistry: