🌱 Add utils for retrieving data about project dependencies #4711
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
new feature
(Is it a bug fix, feature, docs update, something else?)
What is the current behavior?
Currently, Scorecard cannot reason over dependencies in lock files.
What is the new behavior (if this is a feature change)?**
This adds utilities for reasoning over dependencies in lock files. Specifically, it adds support for the following files:
package-lock.json
package.json
pom.xml
go.mod
requirements.txt
The goal is over time to add support for more file types. osv-scalibr parses a lot more formats, however, it does not parse the dependencies of all formats that we need. I would like to work on adding this to osv-scalibr as it seems like a win for osv-scalibr and a win for Scorecard to have that there. It have started identifying missing pieces in google/osv-scalibr#907.
In addition, this PR adds a utility function for comparing the version of a dependency against the definition of another. This is important for implementing #2458 and gives a good picture of how I will solve this probe. Here is an overview:
Which issue(s) this PR fixes
This is part of ongoing work on #2458
Other PRs in this ongoing work are:
Special notes for your reviewer
Does this PR introduce a user-facing change?
NONE (yet).
Currently, the code is not exposed in any user-facing functionality and as such is dead code. The goal is to get these dependency parsing routines to cover a wide range of ecosystems (we can get a lot from using osv-scalibr: https://github.com/google/osv-scalibr/tree/main/extractor/filesystem/language) and then expose this in a probe for #2458.