Skip to content

Commit

Permalink
fix: pom properties not setting artifact id (anchore#1870)
Browse files Browse the repository at this point in the history
Signed-off-by: James Neate <jamesmneate@gmail.com>
  • Loading branch information
jneate authored Jun 12, 2023
1 parent eb8be0d commit 2edcb6b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
5 changes: 3 additions & 2 deletions syft/pkg/cataloger/java/parse_pom_xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ func newPomProject(path string, p gopom.Project) *pkg.PomProject {
func newPackageFromPom(pom gopom.Project, dep gopom.Dependency, locations ...file.Location) pkg.Package {
m := pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{
GroupID: resolveProperty(pom, dep.GroupID),
Scope: resolveProperty(pom, dep.Scope),
GroupID: resolveProperty(pom, dep.GroupID),
ArtifactID: resolveProperty(pom, dep.ArtifactID),
Scope: resolveProperty(pom, dep.Scope),
},
}

Expand Down
60 changes: 38 additions & 22 deletions syft/pkg/cataloger/java/parse_pom_xml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ func Test_parserPomXML(t *testing.T) {
Type: pkg.JavaPkg,
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{GroupID: "com.joda"},
PomProperties: &pkg.PomProperties{
GroupID: "com.joda",
ArtifactID: "joda-time",
},
},
},
{
Expand All @@ -40,8 +43,9 @@ func Test_parserPomXML(t *testing.T) {
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{
GroupID: "junit",
Scope: "test",
GroupID: "junit",
ArtifactID: "junit",
Scope: "test",
},
},
},
Expand Down Expand Up @@ -75,7 +79,10 @@ func Test_parseCommonsTextPomXMLProject(t *testing.T) {
Type: pkg.JavaPkg,
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{GroupID: "org.apache.commons"},
PomProperties: &pkg.PomProperties{
GroupID: "org.apache.commons",
ArtifactID: "commons-lang3",
},
},
},
{
Expand All @@ -87,8 +94,9 @@ func Test_parseCommonsTextPomXMLProject(t *testing.T) {
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{
GroupID: "org.junit.jupiter",
Scope: "test",
GroupID: "org.junit.jupiter",
ArtifactID: "junit-jupiter",
Scope: "test",
},
},
},
Expand All @@ -101,8 +109,9 @@ func Test_parseCommonsTextPomXMLProject(t *testing.T) {
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{
GroupID: "org.assertj",
Scope: "test",
GroupID: "org.assertj",
ArtifactID: "assertj-core",
Scope: "test",
},
},
},
Expand All @@ -115,8 +124,9 @@ func Test_parseCommonsTextPomXMLProject(t *testing.T) {
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{
GroupID: "commons-io",
Scope: "test",
GroupID: "commons-io",
ArtifactID: "commons-io",
Scope: "test",
},
},
},
Expand All @@ -129,8 +139,9 @@ func Test_parseCommonsTextPomXMLProject(t *testing.T) {
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{
GroupID: "org.mockito",
Scope: "test",
GroupID: "org.mockito",
ArtifactID: "mockito-inline",
Scope: "test",
},
},
},
Expand All @@ -143,8 +154,9 @@ func Test_parseCommonsTextPomXMLProject(t *testing.T) {
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{
GroupID: "org.graalvm.js",
Scope: "test",
GroupID: "org.graalvm.js",
ArtifactID: "js",
Scope: "test",
},
},
},
Expand All @@ -157,8 +169,9 @@ func Test_parseCommonsTextPomXMLProject(t *testing.T) {
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{
GroupID: "org.graalvm.js",
Scope: "test",
GroupID: "org.graalvm.js",
ArtifactID: "js-scriptengine",
Scope: "test",
},
},
},
Expand All @@ -171,8 +184,9 @@ func Test_parseCommonsTextPomXMLProject(t *testing.T) {
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{
GroupID: "org.apache.commons",
Scope: "test",
GroupID: "org.apache.commons",
ArtifactID: "commons-rng-simple",
Scope: "test",
},
},
},
Expand All @@ -185,8 +199,9 @@ func Test_parseCommonsTextPomXMLProject(t *testing.T) {
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{
GroupID: "org.openjdk.jmh",
Scope: "test",
GroupID: "org.openjdk.jmh",
ArtifactID: "jmh-core",
Scope: "test",
},
},
},
Expand All @@ -199,8 +214,9 @@ func Test_parseCommonsTextPomXMLProject(t *testing.T) {
MetadataType: pkg.JavaMetadataType,
Metadata: pkg.JavaMetadata{
PomProperties: &pkg.PomProperties{
GroupID: "org.openjdk.jmh",
Scope: "test",
GroupID: "org.openjdk.jmh",
ArtifactID: "jmh-generator-annprocess",
Scope: "test",
},
},
},
Expand Down

0 comments on commit 2edcb6b

Please sign in to comment.