-
Notifications
You must be signed in to change notification settings - Fork 579
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
feat: Add support for new Copyrights and schema updates #3156
base: main
Are you sure you want to change the base?
Conversation
Generally, I think this looks pretty good @dor-hayun. A couple comments: If we're going to add this to the Syft data model and SPDX, we should also add this to CycloneDX, since it appears to support copyright of components also. That said, I don't see where this is ever populated -- are there some catalogers we could add this to with the initial implementation? |
@kzantow I'll add this to CycloneDX as well. The goal is to enable the addition of copyright text either as part of the existing catalogers or by injecting this data directly from other sources and formatting it. For instance, I can iterate over the |
6c56eb9
to
8a085a5
Compare
@kzantow added also in CycloneDX |
43aeb7a
to
1e121e8
Compare
b113b35
to
052f526
Compare
d27e313
to
abf35cc
Compare
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 had a quick look and left a bit of feedback here that would need to be addressed.
A couple other things:
- SPDX and CycloneDX should both encode and decode copyright information -- Syft should be able to read its own files
- I do not see any catalogers which are surfacing copyrights, I don't think we would want to add to the data model without using it at all
@@ -61,11 +66,31 @@ func CommonOptions(licenseCmp LicenseComparer, locationCmp LocationComparer) []c | |||
return true | |||
}, | |||
), | |||
cmp.Comparer( | |||
func(x, y pkg.CopyrightsSet) bool { |
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 should be split out to a separate function, following the same pattern as the other comparers
@@ -360,12 +362,33 @@ func AssertPackagesEqual(t *testing.T, a, b pkg.Package) { | |||
return true | |||
}, | |||
), | |||
cmp.Comparer( | |||
func(x, y pkg.CopyrightsSet) bool { |
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 should follow the existing patterns with a separate function
@@ -1,13 +1,13 @@ | |||
//nolint:dupl |
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 is this considered duplicated code? we should probably reuse existing functionality if needed
abf35cc
to
4bf0b03
Compare
- **Added**: New JSON schema version `16.0.16` with support for the new `Copyrights`. - **Modified**: Updated the `JSONSchemaVersion` parameter to use the new schema. - **Added**: New `Copyrights` field to the `Package` and `PackageBasicData` structs, similar to the existing `Licenses` field. - **Added**: New `Copyright` struct. - **Implemented**: Sorting methods for the `Copyright` struct. - **Changed**: Updated the `PackageCopyrightText` to use `helpers.GetCopyrights(p.Copyrights)`, which formats the copyright text and returns a string. Example output: "Copyright 2014-2014 Matt Zabriskie & Collaborators". - **Added**: `Copyrights` assignment to the `toSyftPackage` function. Signed-off-by: dor-hayun <[email protected]>
4bf0b03
to
b75dd28
Compare
JSON Schema
16.0.16
with support for the newCopyrights
.JSONSchemaVersion
parameter to use the new schema.Package Structs
Copyrights
field to thePackage
andPackageBasicData
structs, similar to the existingLicenses
field.Copyright
struct.Copyright
struct.toPackages Function
PackageCopyrightText
to usehelpers.GetCopyrights(p.Copyrights)
, which formats the copyright text and returns a string. Example output: "Copyright 2014-2014 Matt Zabriskie & Collaborators".toSyftPackage Function
Copyrights
assignment to thetoSyftPackage
function.also added support in CycloneDX format