mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
always set the package ID for java packages (#1493)
Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
parent
99f55f6a81
commit
972e4cdaeb
@ -133,12 +133,14 @@ func (j *archiveParser) parse() ([]pkg.Package, []artifact.Relationship, error)
|
|||||||
// add pURLs to all packages found
|
// add pURLs to all packages found
|
||||||
// note: since package information may change after initial creation when parsing multiple locations within the
|
// note: since package information may change after initial creation when parsing multiple locations within the
|
||||||
// jar, we wait until the conclusion of the parsing process before synthesizing pURLs.
|
// jar, we wait until the conclusion of the parsing process before synthesizing pURLs.
|
||||||
for i, p := range pkgs {
|
for i := range pkgs {
|
||||||
|
p := &pkgs[i]
|
||||||
if m, ok := p.Metadata.(pkg.JavaMetadata); ok {
|
if m, ok := p.Metadata.(pkg.JavaMetadata); ok {
|
||||||
pkgs[i].PURL = packageURL(p.Name, p.Version, m)
|
p.PURL = packageURL(p.Name, p.Version, m)
|
||||||
} else {
|
} else {
|
||||||
log.WithFields("package", p.String()).Warn("unable to extract java metadata to generate purl")
|
log.WithFields("package", p.String()).Warn("unable to extract java metadata to generate purl")
|
||||||
}
|
}
|
||||||
|
p.SetID()
|
||||||
}
|
}
|
||||||
|
|
||||||
return pkgs, relationships, nil
|
return pkgs, relationships, nil
|
||||||
|
|||||||
@ -277,6 +277,10 @@ func TestParseJar(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, a := range actual {
|
for _, a := range actual {
|
||||||
|
if a.ID() == "" {
|
||||||
|
t.Fatalf("empty package ID: %+v", a)
|
||||||
|
}
|
||||||
|
|
||||||
e, ok := test.expected[a.Name]
|
e, ok := test.expected[a.Name]
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Errorf("entry not found: %s", a.Name)
|
t.Errorf("entry not found: %s", a.Name)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user