-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for new Copyrights and schema updates
- **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]>
- Loading branch information
dor-hayun
committed
Aug 28, 2024
1 parent
cf9bb13
commit 1e121e8
Showing
37 changed files
with
524 additions
and
105 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package cmptest | ||
|
||
import ( | ||
"github.com/anchore/syft/syft/pkg" | ||
"github.com/google/go-cmp/cmp" | ||
) | ||
|
||
type CopyrightComparer func(x, y pkg.Copyright) bool | ||
|
||
func DefaultCopyrightComparer(x, y pkg.Copyright) bool { | ||
return cmp.Equal(x, y, cmp.Comparer( | ||
func(x, y string) bool { | ||
return x == y | ||
}, | ||
)) | ||
} |
This file contains 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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
<id>MIT</id> | ||
</license> | ||
</licenses> | ||
<copyright>NOASSERTION</copyright> | ||
<cpe>cpe:2.3:*:some:package:2:*:*:*:*:*:*:*</cpe> | ||
<purl>a-purl-2</purl> | ||
<properties> | ||
|
@@ -37,6 +38,7 @@ | |
<component bom-ref="redacted" type="library"> | ||
<name>package-2</name> | ||
<version>2.0.1</version> | ||
<copyright>NOASSERTION</copyright> | ||
<cpe>cpe:2.3:*:some:package:2:*:*:*:*:*:*:*</cpe> | ||
<purl>pkg:deb/debian/[email protected]</purl> | ||
<properties> | ||
|
This file contains 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 |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
<id>MIT</id> | ||
</license> | ||
</licenses> | ||
<copyright>NOASSERTION</copyright> | ||
<cpe>cpe:2.3:*:some:package:1:*:*:*:*:*:*:*</cpe> | ||
<purl>a-purl-1</purl> | ||
<properties> | ||
|
@@ -39,6 +40,7 @@ | |
<component bom-ref="redacted" type="library"> | ||
<name>package-2</name> | ||
<version>2.0.1</version> | ||
<copyright>NOASSERTION</copyright> | ||
<cpe>cpe:2.3:*:some:package:2:*:*:*:*:*:*:*</cpe> | ||
<purl>pkg:deb/debian/[email protected]</purl> | ||
<properties> | ||
|
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package helpers | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/anchore/syft/syft/pkg" | ||
) | ||
|
||
const ( | ||
noAssertion = "NOASSERTION" | ||
copyrightPrefix = "Copyright" | ||
) | ||
|
||
func GetCopyrights(copyrights pkg.CopyrightsSet) string { | ||
result := noAssertion | ||
|
||
for _, c := range copyrights.ToSlice() { | ||
var sb strings.Builder | ||
|
||
sb.WriteString(copyrightPrefix) | ||
|
||
// Start Year | ||
if c.StartYear != "" { | ||
sb.WriteString(" ") | ||
sb.WriteString(c.StartYear) | ||
} | ||
|
||
// End Year | ||
if c.EndYear != "" { | ||
sb.WriteString("-") | ||
sb.WriteString(c.EndYear) | ||
} | ||
|
||
// Author | ||
if c.Author != "" { | ||
sb.WriteString(" ") | ||
sb.WriteString(c.Author) | ||
} | ||
|
||
// Assign the formatted string to result | ||
result = sb.String() | ||
} | ||
|
||
return result | ||
} |
This file contains 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.