feat: add identifiable field to source object#1243
Conversation
Allow source.Source struct to set reproducable id for different scheme. This ID is calcuated either as a digest from the given directory or file path. If the scheme is detected to be an ImageScheme then the ID is calculated as a ChainID: https://github.com/opencontainers/image-spec/blob/main/config.md#layer-chainid Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Benchmark Test ResultsBenchmark results from the latest changes vs base branch |
| func (s *Source) SetID() { | ||
| if s.Metadata.Scheme != ImageScheme { | ||
| // How do we generate ID for non-image sources? | ||
| s.id = digest.FromString(s.Metadata.Path).String() |
There was a problem hiding this comment.
No path digest here: I think we want what's seen here
https://github.com/anchore/syft/pull/1218/files#diff-b79b344d258161c0ca7b6347af27d5ed643fdb01f4fbe654a69a688efe6a97cf
Getting a sum from the file itself or the metadata from the dir
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
[optional footer(s)] Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
| return s.id | ||
| } | ||
|
|
||
| func (s *Source) SetID() { |
There was a problem hiding this comment.
Should this PR include a call to this function?
There was a problem hiding this comment.
^ Second PR is going to do that so we can link it into relationships - Just wanted to keep this PR small, but I can add the call so we're setting it on construction
There was a problem hiding this comment.
Looking again, there also isn't ONE great place to put the single call since we have functions like New, NewFromImage NewFromDirectory NewFromFile.
Let me see all the places it needs to be included so we have full coverage of all the source creation
There was a problem hiding this comment.
I could just have it get set on the first call to ID if s.id = ""
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
* main: (45 commits) feat: add RelationshipsBySourceOwnership to syft json output (#1248) fix: reset merged package into map; (#1258) refactor: Remove experimental Anchore Enterprise upload functionality (#1257) Update syft bootstrap tools to latest versions. (#1254) Update Stereoscope to d24c9d626b33fa720210b007a20767801827b532 (#1253) Update syft bootstrap tools to latest versions. (#1244) fix apkdb checksum representation (#1247) feat: add identifiable field to source object (#1243) feat: attest support for Singularity images (#1201) Update syft bootstrap tools to latest versions. (#1239) Update Stereoscope to 1b1b744a919964f38d14e1416fb3f25221b761ce (#1240) fix: Follow symlinks when searching for globs in all-layers scope (#1221) update requires to use list; remove field (#1234) Add Conan (C/C++) conan.lock file support (#1230) add sequence diagrams and flesh out TODO notes (#1233) Do not fail if unable to parse `.rpm` file (#1232) fix: support exclude patterns on Windows (#1228) Update syft bootstrap tools to latest versions. (#1225) Update Stereoscope to 56552770e555d764ea72b99d3c810326b27ead4a (#1224) Update syft bootstrap tools to latest versions. (#1223) ... Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Allow source.Source struct to set reproducible id for the following scheme:
This ID is calculated in the following ways:
Followups coming in separate smaller PR:
Signed-off-by: Christopher Phillips christopher.phillips@anchore.com