-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add annotations for evidence on package locations #1723
Conversation
Benchmark Test ResultsBenchmark results from the latest changes vs base branch
|
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
7b3870b
to
bf30d08
Compare
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
JSON schema diff for reviewers: # ❯ diff schema/json/schema-7.1.1.json schema/json/schema-7.1.2.json
817,818c817,823
< "virtualPath": {
< "type": "string"
---
> "annotations": {
> "patternProperties": {
> ".*": {
> "type": "string"
> }
> },
> "type": "object"
946c951
< "$ref": "#/$defs/Coordinates"
---
> "$ref": "#/$defs/Location" |
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.
Overall 👍 just a few comments before ✅
syft/pkg/cataloger/binary/package.go
Outdated
"github.com/anchore/syft/syft/source" | ||
) | ||
|
||
func newPackage(classifier classifier, location source.Location, matchMetadata map[string]string) []pkg.Package { |
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.
I think this should continue to be named singlePackage
, as it's returning a slice, not just a package. If it was returning a pkg.Package
, definitely named newPackage
but I wanted it to be very clear it wasn't returning more than one.
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.
You're right this is a little confusing. I was trying to bring the package constructor naming and file organization in line with the other catalogers. I think having something named singlePackage
and return []pkg.Package
is confusing and seems to be more of a convenience for the caller. I think to make this more clear on all fronts changing the signature to newPackage(...) *pkg.Package
makes the most sense, and the caller would optionally return the slice result to fulfill it obligations as a parser function.
Coordinates `cyclonedx:""` // Empty string here means there is no intermediate property name, e.g. syft:locations:0:path without "coordinates" | ||
// note: it is IMPORTANT to ignore anything but the coordinates for a Location when considering the ID (hash value) | ||
// since the coordinates are the minimally correct ID for a location (symlinks should not come into play) | ||
VirtualPath string `hash:"ignore" json:"virtualPath,omitempty"` // The path to the file which may or may not have hardlinks / symlinks | ||
ref file.Reference `hash:"ignore"` // The file reference relative to the stereoscope.FileCatalog that has more information about this location. | ||
VirtualPath string `hash:"ignore" json:"-"` // The path to the file which may or may not have hardlinks / symlinks |
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.
Why are we excluding VirtualPath from JSON output?
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.
Now that the source.Location is used instead of source.Coordinates in the json model, I updated the json struct tags to reflect the same data shape that is supported by the current schema. Coordinates don't convey the virtual path https://github.com/anchore/syft/blob/v0.77.0/syft/formats/syftjson/model/package.go#L29 so to be consistent this struct tag was changed to -
.
We could change this, but I'd recommend that in a follow up PR.
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This one looks good to me - no other comments to add besides what already exists on the PR. I've started incorporating the location changes into the license evidence PR so 👍 thanks for making this clear and easy to follow |
* main: (35 commits) Fix kernel cataloger test fixtures (#1742) feat: Support scanning license files in golang packages over the network (#1630) Add package-to-file location evidence relationships (#1698) Add Linux Kernel cataloger (#1694) Add annotations for evidence on package locations (#1723) add format make target (#1733) Update tests to not fail on Mac M1's. (#1730) chore(deps): update bootstrap tools to latest versions (#1728) Add support for nar files. (#1727) add highlevel details about catalogers (#1726) chore(deps): bump golang.org/x/net from 0.8.0 to 0.9.0 (#1722) chore(deps): update stereoscope to e95d60a265e384df29b7a139f5c5402d6ad72e06 (#1721) feat: gradle lockfile support (#1719) chore(deps): bump github.com/docker/docker (#1715) chore(deps): bump golang.org/x/mod from 0.9.0 to 0.10.0 (#1713) chore(deps): bump golang.org/x/term from 0.6.0 to 0.7.0 (#1714) chore(deps): bump github.com/spf13/cobra from 1.6.1 to 1.7.0 (#1716) chore(deps): bump peter-evans/create-pull-request from 4 to 5 (#1712) chore: update tools-golang to v0.5.0 (#1717) Add Nix cataloger (#1696) ... Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
* add location annotations + deb evidence annotations Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * rename LocationData struct and Annotation helper function Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add failing integration test for evidence coverage Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add evidence to aplm cataloger locations Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * change location annotation helper to return a location copy Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add evidence to binary cataloger locations Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * updated remaining catalogers with location annotations Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix unit tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * bump json schema Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * partial addressing of review comments Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * rename location.WithAnnotation Signed-off-by: Alex Goodman <alex.goodman@anchore.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Adds the concept of location annotations, allowing arbitrary key-value pairs to be listed onto
source.Location
objects. This PR also shows the first example of this with the dpkg cataloger:Notes:
source.LocationSet
requires that the existingsource.Location
is hashable as to enable it's use as a key in a map. This isn't possible since annotations are themselves maps and are directly attached to the Location struct. For this reason I've split out position information and metadata within the Location struct and added those as embeddings.source.LocationSet
merges metadata for any two locations where the position information is the same, essentially merging the locations. This seems like the right call relative to the package struct, but this does not account nicely for duplicate keys with differing values, which will log a warning.