From 934149da9e7b22940d3f4d0e98fa4ced882903fa Mon Sep 17 00:00:00 2001 From: Will Murphy Date: Fri, 16 Jun 2023 10:15:26 -0400 Subject: [PATCH] Pad artifact IDs Otherwise the hash can sometimes be short if it results in a low uint64. Signed-off-by: Will Murphy --- syft/artifact/id.go | 2 +- .../test-fixtures/snapshot/TestEncodeFullJSONDocument.golden | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/syft/artifact/id.go b/syft/artifact/id.go index 4b87fd293c1..c53ca7c9ad0 100644 --- a/syft/artifact/id.go +++ b/syft/artifact/id.go @@ -22,5 +22,5 @@ func IDByHash(obj interface{}) (ID, error) { return "", fmt.Errorf("could not build ID for object=%+v: %w", obj, err) } - return ID(fmt.Sprintf("%x", f)), nil + return ID(fmt.Sprintf("%016x", f)), nil } diff --git a/syft/formats/syftjson/test-fixtures/snapshot/TestEncodeFullJSONDocument.golden b/syft/formats/syftjson/test-fixtures/snapshot/TestEncodeFullJSONDocument.golden index c039a245730..daca7eb5ed6 100644 --- a/syft/formats/syftjson/test-fixtures/snapshot/TestEncodeFullJSONDocument.golden +++ b/syft/formats/syftjson/test-fixtures/snapshot/TestEncodeFullJSONDocument.golden @@ -91,7 +91,7 @@ } }, { - "id": "e7c88bd18e11b0b", + "id": "0e7c88bd18e11b0b", "location": { "path": "/a/place/a" },