From f74c121388b6ebb4bc6428d8f16d6b8d06a4c003 Mon Sep 17 00:00:00 2001 From: Artemii Fedotov Date: Fri, 1 Nov 2024 12:14:34 +0100 Subject: [PATCH 1/2] chore: fixed format conversion docs link (#3143) Signed-off-by: Artemii Fedotov --- README.md | 25 +++++++++++++++++++++++++ cmd/syft/internal/commands/convert.go | 4 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5170cde2b1c..55aa8603522 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,31 @@ Where the `formats` available are: Note that flags using the @ can be used for earlier versions of each specification as well. +## Format conversion (experimental) + +The ability to convert existing SBOMs means you can create SBOMs in different formats quickly, without the need to regenerate the SBOM from scratch, which may take significantly more time. + +```sh +syft convert [SOURCE-SBOM] -o [FORMAT] [flags] +``` + +This feature is experimental and data might be lost when converting formats. Packages are the main SBOM component easily transferable across formats, whereas files and relationships, as well as other information Syft doesn't support, are more likely to be lost. +We support formats with wide community usage AND good encode/decode support by Syft. The supported formats are: + +- Syft JSON (```-o syft-json```) +- SPDX 2.2 JSON (```-o spdx-json```) +- SPDX 2.2 tag-value (```-o spdx-tag-value```) +- CycloneDX 1.4 JSON (```-o cyclonedx-json```) +- CycloneDX 1.4 XML (```-o cyclonedx-xml```) + +Conversion example: + +```sh +syft convert img.syft.json -o spdx-json # convert a syft SBOM to spdx-json, output goes to stdout +syft convert img.syft.json -o cyclonedx-json=img.cdx.json # convert a syft SBOM to CycloneDX, output is written to the file img.cdx.json +syft convert - -o spdx-json # convert an SBOM from STDIN to spdx-json +``` + ### Supported Ecosystems - Alpine (apk) diff --git a/cmd/syft/internal/commands/convert.go b/cmd/syft/internal/commands/convert.go index 510027ce7f5..fbf9435acd6 100644 --- a/cmd/syft/internal/commands/convert.go +++ b/cmd/syft/internal/commands/convert.go @@ -17,7 +17,7 @@ import ( const ( convertExample = ` {{.appName}} {{.command}} img.syft.json -o spdx-json convert a syft SBOM to spdx-json, output goes to stdout - {{.appName}} {{.command}} img.syft.json -o cyclonedx-json=img.cdx.json convert a syft SBOM to CycloneDX, output is written to the file "img.cdx.json"" + {{.appName}} {{.command}} img.syft.json -o cyclonedx-json=img.cdx.json convert a syft SBOM to CycloneDX, output is written to the file "img.cdx.json" {{.appName}} {{.command}} - -o spdx-json convert an SBOM from STDIN to spdx-json ` ) @@ -39,7 +39,7 @@ func Convert(app clio.Application) *cobra.Command { return app.SetupCommand(&cobra.Command{ Use: "convert [SOURCE-SBOM] -o [FORMAT]", Short: "Convert between SBOM formats", - Long: "[Experimental] Convert SBOM files to, and from, SPDX, CycloneDX and Syft's format. For more info about data loss between formats see https://github.com/anchore/syft#format-conversion-experimental", + Long: "[Experimental] Convert SBOM files to, and from, SPDX, CycloneDX and Syft's format. For more info about data loss between formats see https://github.com/anchore/syft/tree/main?tab=readme-ov-file#format-conversion-experimental", Example: internal.Tprintf(convertExample, map[string]interface{}{ "appName": id.Name, "command": "convert", From 81b3a26407640d43f05b91a1bd2221ee9a09a633 Mon Sep 17 00:00:00 2001 From: Artemii Fedotov Date: Fri, 1 Nov 2024 15:54:43 +0100 Subject: [PATCH 2/2] changed link to wiki docs Signed-off-by: Artemii Fedotov --- README.md | 25 ------------------------- cmd/syft/internal/commands/convert.go | 2 +- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/README.md b/README.md index 55aa8603522..5170cde2b1c 100644 --- a/README.md +++ b/README.md @@ -120,31 +120,6 @@ Where the `formats` available are: Note that flags using the @ can be used for earlier versions of each specification as well. -## Format conversion (experimental) - -The ability to convert existing SBOMs means you can create SBOMs in different formats quickly, without the need to regenerate the SBOM from scratch, which may take significantly more time. - -```sh -syft convert [SOURCE-SBOM] -o [FORMAT] [flags] -``` - -This feature is experimental and data might be lost when converting formats. Packages are the main SBOM component easily transferable across formats, whereas files and relationships, as well as other information Syft doesn't support, are more likely to be lost. -We support formats with wide community usage AND good encode/decode support by Syft. The supported formats are: - -- Syft JSON (```-o syft-json```) -- SPDX 2.2 JSON (```-o spdx-json```) -- SPDX 2.2 tag-value (```-o spdx-tag-value```) -- CycloneDX 1.4 JSON (```-o cyclonedx-json```) -- CycloneDX 1.4 XML (```-o cyclonedx-xml```) - -Conversion example: - -```sh -syft convert img.syft.json -o spdx-json # convert a syft SBOM to spdx-json, output goes to stdout -syft convert img.syft.json -o cyclonedx-json=img.cdx.json # convert a syft SBOM to CycloneDX, output is written to the file img.cdx.json -syft convert - -o spdx-json # convert an SBOM from STDIN to spdx-json -``` - ### Supported Ecosystems - Alpine (apk) diff --git a/cmd/syft/internal/commands/convert.go b/cmd/syft/internal/commands/convert.go index fbf9435acd6..d10791969cf 100644 --- a/cmd/syft/internal/commands/convert.go +++ b/cmd/syft/internal/commands/convert.go @@ -39,7 +39,7 @@ func Convert(app clio.Application) *cobra.Command { return app.SetupCommand(&cobra.Command{ Use: "convert [SOURCE-SBOM] -o [FORMAT]", Short: "Convert between SBOM formats", - Long: "[Experimental] Convert SBOM files to, and from, SPDX, CycloneDX and Syft's format. For more info about data loss between formats see https://github.com/anchore/syft/tree/main?tab=readme-ov-file#format-conversion-experimental", + Long: "[Experimental] Convert SBOM files to, and from, SPDX, CycloneDX and Syft's format. For more info about data loss between formats see https://github.com/anchore/syft/wiki/format-conversion", Example: internal.Tprintf(convertExample, map[string]interface{}{ "appName": id.Name, "command": "convert",