Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(java): add empty versions if pom.xml dependency versions can't be detected #7520

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

DmitriyLewen
Copy link
Contributor

@DmitriyLewen DmitriyLewen commented Sep 17, 2024

Description

See #7446

example:

➜  ./trivy -q fs -f json --list-all-pkgs ./pkg/dependency/parser/java/pom/testdata/dep-without-version/pom.xml | jq .Results
[
  {
    "Target": "pom.xml",
    "Class": "lang-pkgs",
    "Type": "pom",
    "Packages": [
      {
        "ID": "com.example:dep-without-version:1.0.0",
        "Name": "com.example:dep-without-version",
        "Identifier": {
          "PURL": "pkg:maven/com.example/[email protected]",
          "UID": "f45bbf801c535e36"
        },
        "Version": "1.0.0",
        "Relationship": "root",
        "Layer": {}
      },
      {
        "ID": "org.example:example-api",
        "Name": "org.example:example-api",
        "Identifier": {
          "PURL": "pkg:maven/org.example/example-api",
          "UID": "2defcd5e48da76ac"
        },
        "Relationship": "direct",
        "Layer": {},
        "Locations": [
          {
            "StartLine": 19,
            "EndLine": 22
          }
        ]
      }
    ]
  }
]

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@DmitriyLewen DmitriyLewen self-assigned this Sep 17, 2024
@DmitriyLewen DmitriyLewen marked this pull request as ready for review September 17, 2024 06:34
pkg/dependency/parser/java/pom/artifact.go Outdated Show resolved Hide resolved
return true
}
if a.Version.String() == "" {
emptyVersionWarn()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to show warnings with group id and artifact id. Can it be overwhelming?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to show the warning once to avoid spam in logs
do you think we should still show all dependencies without the version?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One warning without dependency details and other debug logs with group id and artifact id may be a good compromise.

Co-authored-by: Teppei Fukuda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(pom): add empty versions if dependency versions cannot be detected
2 participants