mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
SPDX file has duplicate sha256 tag in versionInfo (#2300)
* SPDX file has duplicate sha256 tag in versionInfo Signed-off-by: Colm O hEigeartaigh <coheigea@apache.org> * add tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Colm O hEigeartaigh <coheigea@apache.org> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
parent
bae5a2e741
commit
dc14dbb326
@ -108,10 +108,6 @@ func deriveIDFromFile(cfg FileConfig) (artifact.ID, string) {
|
||||
info += fmt.Sprintf(":%s@%s", cfg.Alias.Name, cfg.Alias.Version)
|
||||
}
|
||||
|
||||
if d != "" {
|
||||
d = fmt.Sprintf("sha256:%s", d)
|
||||
}
|
||||
|
||||
return artifactIDFromDigest(digest.SHA256.FromString(info).String()), d
|
||||
}
|
||||
|
||||
|
||||
@ -214,6 +214,7 @@ func Test_FileSource_ID(t *testing.T) {
|
||||
name string
|
||||
cfg FileConfig
|
||||
want artifact.ID
|
||||
wantDigest string
|
||||
wantErr require.ErrorAssertionFunc
|
||||
}{
|
||||
{
|
||||
@ -239,6 +240,7 @@ func Test_FileSource_ID(t *testing.T) {
|
||||
name: "with path",
|
||||
cfg: FileConfig{Path: "./test-fixtures/image-simple/Dockerfile"},
|
||||
want: artifact.ID("db7146472cf6d49b3ac01b42812fb60020b0b4898b97491b21bb690c808d5159"),
|
||||
wantDigest: "sha256:38601c0bb4269a10ce1d00590ea7689c1117dd9274c758653934ab4f2016f80f",
|
||||
},
|
||||
{
|
||||
name: "with path and alias",
|
||||
@ -250,6 +252,7 @@ func Test_FileSource_ID(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: artifact.ID("3c713003305ac6605255cec8bf4ea649aa44b2b9a9f3a07bd683869d1363438a"),
|
||||
wantDigest: "sha256:38601c0bb4269a10ce1d00590ea7689c1117dd9274c758653934ab4f2016f80f",
|
||||
},
|
||||
{
|
||||
name: "other fields do not affect ID",
|
||||
@ -260,6 +263,7 @@ func Test_FileSource_ID(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: artifact.ID("db7146472cf6d49b3ac01b42812fb60020b0b4898b97491b21bb690c808d5159"),
|
||||
wantDigest: "sha256:38601c0bb4269a10ce1d00590ea7689c1117dd9274c758653934ab4f2016f80f",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
@ -272,7 +276,8 @@ func Test_FileSource_ID(t *testing.T) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
assert.Equalf(t, tt.want, s.ID(), "ID()")
|
||||
assert.Equalf(t, tt.want, s.ID(), "ID() mismatch")
|
||||
assert.Equalf(t, tt.wantDigest, s.digestForVersion, "digestForVersion mismatch")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user