Skip to content

Add maven_install.json v2 support#1

Merged
efabens merged 1 commit intomainfrom
ef/add-maven-install-v2-support
Mar 18, 2024
Merged

Add maven_install.json v2 support#1
efabens merged 1 commit intomainfrom
ef/add-maven-install-v2-support

Conversation

@efabens
Copy link
Copy Markdown

@efabens efabens commented Mar 16, 2024

Fixes Issue

jeremylong/DependencyCheck#6527

Description of Change

  • Implement v2 schema support for maven_install.json.
  • Maintains backwards compatibility with v0.1.0

Have test cases been added to cover the new functionality?

yes
Added a v2 testfile from Bazel's mainline root directory. It is large (but smaller than the ones in the repos I am currently working with), I would rather not manually construct a smaller one but can if there is a strong preference.

@efabens
Copy link
Copy Markdown
Author

efabens commented Mar 16, 2024

I still need to add tests, but this is working

}
deps = installFile.getArtifacts().entrySet().stream().map(entry -> new MavenDependency() {
@Override
public String getCoord() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Introducing HasCoord is a pretty sweet solution.

if (v2Version.isMissingNode() && v010Version.isMissingNode()) {
LOGGER.warn("No pinned maven_install.json version found. Cannot Parse");
return;
} else if (!v2Version.isMissingNode()) {
Copy link
Copy Markdown

@chrisfesler chrisfesler Mar 16, 2024

Choose a reason for hiding this comment

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

🧠 ⚡ The double negative of !v.isMissingNode() is slightly tricky to read. What about isTextual()?

Or you could do:

if (!root.has("version") && !root.path("dependency_tree").has("version")) {
  // warn & return
} else if (root.has("version") {
  // etc

Not sure it's better -- but maybe.

*/
public String getVersion() {
return version;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You could implement HasCoord here instead of doing so anonymously up above. Maybe a little more obvious.

- Implement v2 schema support for `maven_install.json`.
- Maintains backwards compatibility with v0.1.0
@efabens efabens force-pushed the ef/add-maven-install-v2-support branch from 573c362 to d9ba0da Compare March 18, 2024 22:49
@efabens efabens closed this Mar 18, 2024
@efabens efabens reopened this Mar 18, 2024
@efabens efabens marked this pull request as ready for review March 18, 2024 22:57
@efabens efabens merged commit a6a8f21 into main Mar 18, 2024
@efabens efabens deleted the ef/add-maven-install-v2-support branch March 18, 2024 22:57
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