Skip to content

Commit

Permalink
Revert "wip: remove ArtifactID checks for groupID"
Browse files Browse the repository at this point in the history
This reverts commit 77a6fd4.

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
  • Loading branch information
spiffcs committed Aug 22, 2023
1 parent 77a6fd4 commit c3b3e79
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions syft/pkg/cataloger/java/package_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ func groupIDFromPomProperties(properties *pkg.PomProperties) (groupID string) {
return cleanGroupID(properties.GroupID)
}

// sometimes the publisher puts the group ID in the artifact ID field unintentionally
if looksLikeGroupID(properties.ArtifactID) {
// there is a strong indication that the artifact ID is really a group ID
return cleanGroupID(properties.ArtifactID)
}

return groupID
}

Expand All @@ -101,12 +107,24 @@ func groupIDFromPomProject(project *pkg.PomProject) (groupID string) {
return cleanGroupID(project.GroupID)
}

// sometimes the publisher puts the group ID in the artifact ID field unintentionally
if looksLikeGroupID(project.GroupID) {
// there is a strong indication that the artifact ID is really a group ID
return cleanGroupID(project.ArtifactID)
}

// let's check the parent details
// if the current project does not have a group ID, but the parent does, we'll use the parent's group ID
if project.Parent != nil {
if looksLikeGroupID(project.Parent.GroupID) {
return cleanGroupID(project.Parent.GroupID)
}

// sometimes the publisher puts the group ID in the artifact ID field unintentionally
if looksLikeGroupID(project.Parent.ArtifactID) {
// there is a strong indication that the artifact ID is really a group ID
return cleanGroupID(project.Parent.ArtifactID)
}
}

return groupID
Expand Down

0 comments on commit c3b3e79

Please sign in to comment.