From e2ed89f7001b657e0c4b5190db03623bdafa95bf Mon Sep 17 00:00:00 2001 From: William Murphy Date: Fri, 16 Jun 2023 13:26:18 -0400 Subject: [PATCH] Pad artifact IDs (#1882) 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 4b87fd293c1f..c53ca7c9ad07 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 c039a2457300..daca7eb5ed62 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" },