-
Notifications
You must be signed in to change notification settings - Fork 748
feat: add SBOM authors flag #4378
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
Open
derbauer97
wants to merge
2
commits into
anchore:main
Choose a base branch
from
derbauer97:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,19 @@ func TestEncodeDecodeEncodeCycleComparison(t *testing.T) { | |
| // supplier is not available as part of the SBOM Config API since the flag | ||
| // is used in conjunction with the SourceConfig which is injected into generateSBOM during scan | ||
| originalSBOM.Source.Supplier = "anchore" | ||
|
|
||
| originalSBOM.Source.Authors = []source.Author{ | ||
| { | ||
| Name: "Test Author", | ||
| Email: "[email protected]", | ||
| Type: "Person", | ||
| }, | ||
| { | ||
| Name: "Test Organization", | ||
| Email: "[email protected]", | ||
| Type: "Organization", | ||
| }, | ||
| } | ||
| f := encoders.GetByString(test.name) | ||
| require.NotNil(t, f) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Sorry for the delay getting back to you with some feedback, due to holidays and time off it took a while to work out some of the details with the team.
I, personally, think this is part of a larger feature: specifying arbitrary SBOM data that Syft doesn't produce. But we've decided that we should probably kick that can down the road until Syft 2.0 if we decide to make changes to the way any of the current
--source-nameand these additional flags work, but for now adding flags for these purposeful new 2 features makes the most sense.As for this PR, there are a few things I think we should change, assuming I understand what's being implemented correctly. Am I correct in saying the author is intended to specify the author of the SBOM, rather than author of the source (the source being "thing that was scanned" -- container, directory, etc.)? I'm assuming so, in which case I think Henry's PR is closer to the end result and we should get them aligned by adding the
Authorsto theSBOM, rather than the source, and similarly use an appropriate flag:--sbom-author.For both of these PRs I think we should add exported properties directly on the SBOM for
Authorsand the arbitraryProperties. I don't see any other spot where it makes sense to put them. And because these aren't really involved in cataloging, I don't think it's useful to add cataloging configuration to set these -- it's just unnecessary and possibly confusing indirection. Instead, they should be set directly on the SBOM during decoding by the format decoders, or by the CLI scan command. If we determine it's important to have this in the configuration that gets passed to CreateSBOM, it can be added later, but we can't remove it after we add it.As far as the CLI goes, instead of piggybacking on the source config, let's introduce a new top-level
sbomConfig(similar to the sourceConfig) where the authors and properties will be set to more accurately reflect how this data is used, and it should live alongside the cataloging config here (with the json/yaml/mapstructure keysbom, so syft config makes sense undersbom:) like:By having this configuration structure, the yaml configuration will work as expected, so the last remaining bit is exactly how this gets specified for the flags. I've given a suggestion above, keeping the bespoke
name=valuethat we've adopted elsewhere and for the properties. I think we should be careful about introducing bespoke parsing, like the<type>:<name>:<value>-- the only other spot that I'm aware we use:is in a URI-like spot, where the preceding value is the scheme, whereas this is just a way to split values. Maybe think about adopting aname=valuelike we use in other spots and the properties also should probably use, e.g.--sbom-author type=person,name=TheName,email=e@mail(though using a comma is another pattern we have that is equivalent to multiple flags, e.g.--from docker,registry==--from docker --from registry, and using the Flatten function, it could also make properties easier e.g.--sbom-property name1=value1,name2=value2, so consider a different separator character. Sorry I don't have a great answer here, but we can finalize this detail fairly quickly with the whole team towards the end; I would lean towards&, but it needs to be escaped in shells, so maybe+?, definitely open to suggestions here).Again, apologies for the delay and I hope this is understandable enough!