-
Notifications
You must be signed in to change notification settings - Fork 363
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
Add osv output lockfile + refactor #505
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
pkg/lockfile/osv-vuln-results.go
Outdated
"github.com/google/osv-scanner/pkg/models" | ||
) | ||
|
||
const OSVScannerEcosystem Ecosystem = "OSV-Scanner-Results" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required to be defined? IT doesn't seem to be used anywhere, and seems like a weird fit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, removed it now.
Pulled refactor out to a separate PR as suggested here: #505 In this PR: - Refactored models package to no longer depend on lockfile - Moved functions that required lockfile types into separate internal package under `utility/vulns` - Copied over OSV url from `osv` package to avoid dependency on `osv` from `output`/`reporter` I went through and graphed out the dependencies, - `models` no longer depends on any internal dependencies - `lockfile` doesn't depend on any internal dependencies apart from `cacheexp` - `osv` brings in both `lockfiles` and `models`. This is probably the most problematic one. Ideally `osv` should only be referencing `models`, but it'll be a breaking change to change this API. This is one of the main things we should change for V2 (related to #442) (TODO: Make separate issue for this - `reporter` depends on the internal `output`, which depends on `osv`. This dependency causes `lockfile` to be pulled into everywhere that needs to print out anything. This can be decoupled without too much trouble by copying in the OSV url. I did so in this PR. - `config` package references `reporter`, with the above change it also no longer depends on `lockfile`.
@@ -55,11 +78,12 @@ func expectPackage(t *testing.T, packages []lockfile.PackageDetails, pkg lockfil | |||
} | |||
} | |||
|
|||
func findMissingPackages(actualPackages []lockfile.PackageDetails, expectedPackages []lockfile.PackageDetails) []lockfile.PackageDetails { | |||
func findMissingPackages(t *testing.T, actualPackages []lockfile.PackageDetails, expectedPackages []lockfile.PackageDetails) []lockfile.PackageDetails { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is good by itself along with the hasPackage
one, so if you can be bothered I'd favor landing it in its own PR so that this diff is reduced rather than have it wait around for the rest of the changes to get reviewed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change itself LGTM, but I have some remaining questions about the Source
field we added.
Introduces the osv-scanner results lockfile format (feel free to suggest a better name for this),
This also refactors the models folder slightly to move some of the helper functions out to a separate internal crate. This stops the models package from pulling in the lockfile package, causing cyclic imports.
I also added another field to
PackageDetails
,Source
, a currently optional string to specify the location the dependency is actually specified. The only times it will be different from the lockfile location currently is:-r