mirror of
https://github.com/github/spec-kit.git
synced 2026-08-03 06:26:30 +08:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user