fix: use chunked read for extension manifest hash (#3841)

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().
This commit is contained in:
Quratulain-bilal
2026-07-30 19:22:35 +05:00
committed by GitHub
parent e916fd1b3b
commit 4803a22b33

View File

@@ -566,8 +566,11 @@ class ExtensionManifest:
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: