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

Merged

Conversation

DmitriyLewen
Copy link
Contributor

@DmitriyLewen DmitriyLewen commented Sep 17, 2024

Description

See #7446

example:

➜ ./trivy -d fs -f json --list-all-pkgs ./pkg/dependency/parser/java/pom/testdata/dep-without-version/pom.xml | jq .Results
...
2024-09-23T09:52:33+06:00       WARN    [pom] Dependency version cannot be determined. Child dependencies will not be found.    details="https://aquasecurity.github.io/trivy/dev/docs/coverage/language/java#empty-dependency-version"
2024-09-23T09:52:33+06:00       DEBUG   [pom] Dependency version cannot be determined.  GroupID="org.example" ArtifactID="example-api"
...
[
  {
    "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/dep-without-version@1.0.0",
          "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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated in 9424f13

@knqyf263 knqyf263 added this pull request to the merge queue Sep 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 30, 2024
@knqyf263 knqyf263 added this pull request to the merge queue Sep 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 30, 2024
@knqyf263 knqyf263 added this pull request to the merge queue Sep 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 30, 2024
@knqyf263 knqyf263 enabled auto-merge September 30, 2024 12:18
@knqyf263 knqyf263 added this pull request to the merge queue Sep 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 30, 2024
@knqyf263 knqyf263 added this pull request to the merge queue Sep 30, 2024
Merged via the queue into aquasecurity:main with commit b836232 Sep 30, 2024
17 checks passed
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