diff --git a/internal/formats/spdx22json/to_format_model.go b/internal/formats/spdx22json/to_format_model.go index 6d8e47ea61e..d1f3d3d4678 100644 --- a/internal/formats/spdx22json/to_format_model.go +++ b/internal/formats/spdx22json/to_format_model.go @@ -112,8 +112,10 @@ func fileIDsForPackage(packageSpdxID string, relationships []artifact.Relationsh continue } - if string(relationship.From.ID()) == packageSpdxID { - fileIDs = append(fileIDs, string(relationship.To.ID())) + from := model.ElementID(relationship.From.ID()).String() + to := model.ElementID(relationship.To.ID()).String() + if from == packageSpdxID { + fileIDs = append(fileIDs, to) } } return fileIDs diff --git a/internal/formats/spdx22json/to_format_model_test.go b/internal/formats/spdx22json/to_format_model_test.go index d1f5da9a860..ee4c1ed1144 100644 --- a/internal/formats/spdx22json/to_format_model_test.go +++ b/internal/formats/spdx22json/to_format_model_test.go @@ -188,7 +188,7 @@ func Test_fileIDsForPackage(t *testing.T) { }{ { name: "find file IDs for packages with package-file relationships", - id: string(p.ID()), + id: model.ElementID(p.ID()).String(), relationships: []artifact.Relationship{ { From: p, @@ -197,12 +197,12 @@ func Test_fileIDsForPackage(t *testing.T) { }, }, expected: []string{ - string(c.ID()), + model.ElementID(c.ID()).String(), }, }, { name: "ignore package-to-package", - id: string(p.ID()), + id: model.ElementID(p.ID()).String(), relationships: []artifact.Relationship{ { From: p, @@ -214,7 +214,7 @@ func Test_fileIDsForPackage(t *testing.T) { }, { name: "ignore file-to-file", - id: string(p.ID()), + id: model.ElementID(p.ID()).String(), relationships: []artifact.Relationship{ { From: c, @@ -226,7 +226,7 @@ func Test_fileIDsForPackage(t *testing.T) { }, { name: "ignore file-to-package", - id: string(p.ID()), + id: model.ElementID(p.ID()).String(), relationships: []artifact.Relationship{ { From: c, @@ -238,7 +238,7 @@ func Test_fileIDsForPackage(t *testing.T) { }, { name: "filter by relationship type", - id: string(p.ID()), + id: model.ElementID(p.ID()).String(), relationships: []artifact.Relationship{ { From: p,