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(pom): add support of line numbers for deps from base pom.xml #287

Merged
merged 15 commits into from
Jan 24, 2024

Conversation

DmitriyLewen
Copy link
Collaborator

@DmitriyLewen DmitriyLewen commented Jan 23, 2024

Description

Add support of line numbers for deps from base pom.xml.

This PR doesn't add line numbers for:

  • dependencies from parents
  • dependencies for modules

Related issues

@DmitriyLewen DmitriyLewen self-assigned this Jan 23, 2024
@@ -409,7 +433,7 @@ func (p *parser) mergeDependencies(parent, child []artifact, exclusions map[stri
var deps []artifact
unique := map[string]struct{}{}

for _, d := range append(parent, child...) {
for _, d := range append(child, parent...) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

// Merge dependencies. Child dependencies must be preferred than parent dependencies.
// Parents don't have to resolve dependencies.
deps := p.parseDependencies(pom.content.Dependencies.Dependency, props, depManagement, opts.depManagement, opts.exclusions)
deps = p.mergeDependencies(parent.dependencies, deps, opts.exclusions)

Looks like it was a mistake.
I've updated test to show this:
https://github.com/aquasecurity/go-dep-parser/pull/287/files#diff-54393967b4dbd54d8dab7c5bf81ff4297c6fb825ff2bbf1805a4fdabec231146R44

@DmitriyLewen DmitriyLewen marked this pull request as ready for review January 23, 2024 12:22
Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

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

How about this approach?
https://go.dev/play/p/YYQZyFgD9Vt?v=

@DmitriyLewen
Copy link
Collaborator Author

It works!
Thanks for help!

pkg/java/pom/pom.go Outdated Show resolved Hide resolved
@knqyf263
Copy link
Collaborator

@DmitriyLewen I refactored a bit so that we don't need to set nil to Locations in multiple places. Please review the change.
ca6bbaa

pkg/java/pom/parse.go Outdated Show resolved Hide resolved
@DmitriyLewen
Copy link
Collaborator Author

It looks good to me now.

@knqyf263 knqyf263 merged commit 7be7d21 into aquasecurity:main Jan 24, 2024
2 checks passed
@DmitriyLewen DmitriyLewen deleted the feat/line-numbers-pom branch January 24, 2024 10:29
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.

2 participants