Skip to content

Commit 167b34a

Browse files
committed
chore: add support for sha256 hashes in maven
Signed-off-by: Ben Selwyn-Smith <[email protected]>
1 parent 69099a8 commit 167b34a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/macaron/slsa_analyzer/package_registry/maven_central_registry.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,15 @@ def get_artifact_hash(self, purl: PackageURL, hash_algorithm: Any) -> str | None
282282
if not file_name:
283283
return None
284284

285+
# Maven supports but does not require a sha256 hash of uploaded artifacts. Check that first.
285286
artifact_url = self.registry_url + "/" + artifact_path + "/" + file_name
286-
logger.debug("Search for artifact using URL: %s", artifact_url)
287+
sha256_url = artifact_url + ".sha256"
288+
logger.debug("Search for artifact hash using URL: %s", [sha256_url, artifact_url])
289+
290+
response = send_get_http_raw(sha256_url, {})
291+
if response and response.text:
292+
logger.debug("Found hash of artifact: %s", response.text)
293+
return response.text
287294

288295
try:
289296
response = requests.get(artifact_url, stream=True, timeout=40)

0 commit comments

Comments
 (0)