forked from tern-tools/tern
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export specific format versions (SPDX)
This is a prototype for the ability to export in different versions of SPDX. It fixes tern-tools#1211 Signed-off-by: Marc-Etienne Vargenau <[email protected]>
- Loading branch information
Showing
6 changed files
with
35 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,12 +325,26 @@ Many compliance tools are compatible with SPDX. Tern follows the [SPDX specifica | |
``` | ||
$ tern report -f spdxtagvalue -i golang:1.12-alpine -o spdx.txt | ||
``` | ||
By default, the report will be in SPDX version 2.2 (ISO SPDX). | ||
|
||
The following syntax will output SPDX 2.3: | ||
``` | ||
$ tern report -f [email protected] -i golang:1.12-alpine -o spdx.txt | ||
``` | ||
|
||
|
||
## SPDX JSON Format<a name="report-spdxjson"> | ||
The SPDX JSON format contains the same information that an SPDX Tag-value document does. The only difference between these two formats is the way the information is represented. The 'spdxjson' format represents the container information as a collection of key-value pairs. In some cases, the SPDX JSON format may be more interoperable between cloud native compliance tools. | ||
``` | ||
$ tern report -f spdxjson -i golang:1.12-alpine -o spdx.json | ||
``` | ||
By default, the report will be in SPDX version 2.2 (ISO SPDX). | ||
|
||
The following syntax will output SPDX 2.3: | ||
``` | ||
$ tern report -f [email protected] -i golang:1.12-alpine -o spdx.json | ||
``` | ||
|
||
|
||
## CycloneDX JSON Format<a name="report-cyclonedxjson"> | ||
[OWASP CycloneDX](https://cyclonedx.org/) is a lightweight software bill of materials standard designed for use in application security contexts and supply chain component analysis. The National Telecommunications and Information Administration (NTIA) [recognizes CycloneDX](https://www.ntia.gov/files/ntia/publications/sbom_options_and_decision_points_20210427-1.pdf) as one of three valid SBOM formats that satisfies the minimum viable requirements for an SBOM in accordance with President Biden's [Executive Order on Improving the Nation's Cybersecurity](https://www.whitehouse.gov/briefing-room/presidential-actions/2021/05/12/executive-order-on-improving-the-nations-cybersecurity/). | ||
|
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 |
---|---|---|
|
@@ -37,13 +37,20 @@ def clean_image_tars(image_obj): | |
|
||
def generate_report(args, *images): | ||
'''Generate a report based on the command line options''' | ||
args.spdxv = '2.2' | ||
if args.report_format and (args.report_format == '[email protected]'): | ||
args.report_format = 'spdxtagvalue' | ||
args.spdxv = '2.3' | ||
if args.report_format and (args.report_format == '[email protected]'): | ||
args.report_format = 'spdxjson' | ||
args.spdxv = '2.3' | ||
if args.report_format: | ||
return generate_format( | ||
images, args.report_format, args.print_inclusive) | ||
return generate_format(images, 'default', args.print_inclusive) | ||
images, args.report_format, args.print_inclusive, args.spdxv) | ||
return generate_format(images, 'default', args.print_inclusive, args.spdxv) | ||
|
||
|
||
def generate_format(images, format_string, print_inclusive): | ||
def generate_format(images, format_string, print_inclusive, spdxv): | ||
'''Generate a report in the format of format_string given one or more | ||
image objects. Here we will load the required module and run the generate | ||
function to get back a report''' | ||
|
@@ -53,7 +60,7 @@ def generate_format(images, format_string, print_inclusive): | |
name=format_string, | ||
invoke_on_load=True, | ||
) | ||
return mgr.driver.generate(images, print_inclusive) | ||
return mgr.driver.generate(images, print_inclusive, spdxv) | ||
except NoMatches: | ||
return None | ||
|
||
|