diff --git a/analyzer.go b/analyzer.go index 02e6d037e..9de3efca0 100644 --- a/analyzer.go +++ b/analyzer.go @@ -50,7 +50,7 @@ func (a *Analyzer) Analyze() (platform.AnalyzedMetadata, error) { if api.MustParse(a.Platform.API()).AtLeast("0.8") { if appMeta.BOM != nil && appMeta.BOM.SHA != "" { if err := a.restorePreviousLayer(appMeta.BOM.SHA); err != nil { - return platform.AnalyzedMetadata{}, errors.Wrap(err, "retrieving launch BOM layer") + return platform.AnalyzedMetadata{}, errors.Wrap(err, "retrieving launch sBOM layer") } } } @@ -80,7 +80,7 @@ func (a *Analyzer) Analyze() (platform.AnalyzedMetadata, error) { if api.MustParse(a.Platform.API()).AtLeast("0.8") { if cacheMeta.BOM.SHA != "" { if err := a.restoreCacheLayer(cacheMeta.BOM.SHA); err != nil { - return platform.AnalyzedMetadata{}, errors.Wrap(err, "retrieving cache BOM layer") + return platform.AnalyzedMetadata{}, errors.Wrap(err, "retrieving cache sBOM layer") } } } diff --git a/analyzer_test.go b/analyzer_test.go index a756b791b..e6d78482b 100644 --- a/analyzer_test.go +++ b/analyzer_test.go @@ -153,7 +153,7 @@ func testAnalyzerBuilder(platformAPI string) func(t *testing.T, when spec.G, it layer, err := factory.DirLayer("launch.sbom", filepath.Join(layersDir, "sbom", "launch")) h.AssertNil(t, err) h.AssertNil(t, image.AddLayerWithDiffID(layer.TarPath, layer.Digest)) - h.AssertNil(t, image.SetLabel("io.buildpacks.lifecycle.metadata", fmt.Sprintf(`{"bom": {"sha":"%s"}}`, layer.Digest))) + h.AssertNil(t, image.SetLabel("io.buildpacks.lifecycle.metadata", fmt.Sprintf(`{"sbom": {"sha":"%s"}}`, layer.Digest))) h.AssertNil(t, os.RemoveAll(filepath.Join(layersDir, "sbom"))) }) diff --git a/builder.go b/builder.go index a3003006b..b9833a539 100644 --- a/builder.go +++ b/builder.go @@ -106,7 +106,7 @@ func (b *Builder) Build() (*platform.BuildMetadata, error) { } if b.PlatformAPI.AtLeast("0.8") { - b.Logger.Debug("Copying BOM files") + b.Logger.Debug("Copying sBOM files") err = b.copyBOMFiles(config.LayersDir, bomFiles) if err != nil { return nil, err diff --git a/builder_test.go b/builder_test.go index a8c4bdfe9..9c1a07d8a 100644 --- a/builder_test.go +++ b/builder_test.go @@ -277,7 +277,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) { }, nil) _, err := builder.Build() - h.AssertError(t, err, fmt.Sprintf("unsupported bom format: '%s'", bomFilePath2)) + h.AssertError(t, err, fmt.Sprintf("unsupported sbom format: '%s'", bomFilePath2)) }) when("build metadata", func() { diff --git a/buildpack/bomfile.go b/buildpack/bomfile.go index a8ec87f56..5590de264 100644 --- a/buildpack/bomfile.go +++ b/buildpack/bomfile.go @@ -32,9 +32,9 @@ type BOMFile struct { } // Name() returns the destination filename for a given BOM file -// cdx files should be renamed to "bom.cdx.json" -// spdx files should be renamed to "bom.spdx.json" -// syft files should be renamed to "bom.syft.json" +// cdx files should be renamed to "sbom.cdx.json" +// spdx files should be renamed to "sbom.spdx.json" +// syft files should be renamed to "sbom.syft.json" // If the BOM is neither cdx, spdx, nor syft, the 2nd return argument // will return an error to indicate an unsupported format func (b *BOMFile) Name() (string, error) { @@ -46,7 +46,7 @@ func (b *BOMFile) Name() (string, error) { case mediaTypeSyft: return "sbom.syft.json", nil default: - return "", errors.Errorf("unsupported bom format: '%s'", b.Path) + return "", errors.Errorf("unsupported sbom format: '%s'", b.Path) } } @@ -79,7 +79,7 @@ func validateMediaTypes(bp GroupBuildpack, bomfiles []BOMFile, sbomMediaTypes [] mediaType := bomFile.mediaType() switch mediaType { case mediaTypeUnsupported: - return errors.Errorf("unsupported bom format: '%s'", bomFile.Path) + return errors.Errorf("unsupported sbom format: '%s'", bomFile.Path) default: if !contains(sbomMediaTypes, mediaType) { return errors.Errorf("sbom type '%s' not declared for buildpack: '%s'", mediaType, bp.String()) diff --git a/buildpack/build_test.go b/buildpack/build_test.go index df83b29ae..446d8f19e 100644 --- a/buildpack/build_test.go +++ b/buildpack/build_test.go @@ -298,7 +298,7 @@ func testBuild(t *testing.T, when spec.G, it spec.S) { filepath.Join(layersDir, buildpackID, fmt.Sprintf("%s.sbom.some-unknown-format.json", layerName))) _, err := bpTOML.Build(buildpack.Plan{}, config, mockEnv) - h.AssertError(t, err, fmt.Sprintf("unsupported bom format: '%s'", filepath.Join(layersDir, buildpackID, fmt.Sprintf("%s.sbom.some-unknown-format.json", layerName)))) + h.AssertError(t, err, fmt.Sprintf("unsupported sbom format: '%s'", filepath.Join(layersDir, buildpackID, fmt.Sprintf("%s.sbom.some-unknown-format.json", layerName)))) }) it("returns an error for any undeclared BOM media type", func() { diff --git a/exporter_test.go b/exporter_test.go index 0d29672d0..91525a74f 100644 --- a/exporter_test.go +++ b/exporter_test.go @@ -163,7 +163,7 @@ func testExporter(t *testing.T, when spec.G, it spec.S) { fakeAppImage.AddPreviousLayer("launch.sbom-digest", "") h.AssertNil(t, json.Unmarshal([]byte(` { - "bom": { + "sbom": { "sha": "launch.sbom-digest" }, "buildpacks": [ @@ -821,7 +821,7 @@ version = "4.5.6" var result struct { BOM struct { SHA string `json:"sha"` - } `json:"bom"` + } `json:"sbom"` } data, err := fakeAppImage.Label("io.buildpacks.lifecycle.metadata") diff --git a/platform/cache.go b/platform/cache.go index c5e340fde..452af264e 100644 --- a/platform/cache.go +++ b/platform/cache.go @@ -1,7 +1,7 @@ package platform type CacheMetadata struct { - BOM LayerMetadata `json:"bom"` + BOM LayerMetadata `json:"sbom"` Buildpacks []BuildpackLayersMetadata `json:"buildpacks"` } diff --git a/platform/files.go b/platform/files.go index 46e41d9a1..ff6c4c991 100644 --- a/platform/files.go +++ b/platform/files.go @@ -28,7 +28,7 @@ type ImageIdentifier struct { // NOTE: This struct MUST be kept in sync with `LayersMetadataCompat` type LayersMetadata struct { App []LayerMetadata `json:"app" toml:"app"` - BOM *LayerMetadata `json:"bom,omitempty" toml:"bom,omitempty"` + BOM *LayerMetadata `json:"sbom,omitempty" toml:"sbom,omitempty"` Buildpacks []BuildpackLayersMetadata `json:"buildpacks" toml:"buildpacks"` Config LayerMetadata `json:"config" toml:"config"` Launcher LayerMetadata `json:"launcher" toml:"launcher"` @@ -42,7 +42,7 @@ type LayersMetadata struct { // guaranteed, yet the original struct data must be maintained. type LayersMetadataCompat struct { App interface{} `json:"app" toml:"app"` - BOM *LayerMetadata `json:"bom,omitempty" toml:"bom,omitempty"` + BOM *LayerMetadata `json:"sbom,omitempty" toml:"sbom,omitempty"` Buildpacks []BuildpackLayersMetadata `json:"buildpacks" toml:"buildpacks"` Config LayerMetadata `json:"config" toml:"config"` Launcher LayerMetadata `json:"launcher" toml:"launcher"` diff --git a/restorer.go b/restorer.go index 2bc647198..13ab953e3 100644 --- a/restorer.go +++ b/restorer.go @@ -155,9 +155,9 @@ func (r *Restorer) restoreSBOMFunc(bomType string) func(path string, info fs.Fil var bomRegex *regexp.Regexp if runtime.GOOS == "windows" { - bomRegex = regexp.MustCompile(fmt.Sprintf(`%s\\(.+)\\(.+)\\(bom.+json)`, bomType)) + bomRegex = regexp.MustCompile(fmt.Sprintf(`%s\\(.+)\\(.+)\\(sbom.+json)`, bomType)) } else { - bomRegex = regexp.MustCompile(fmt.Sprintf(`%s/(.+)/(.+)/(bom.+json)`, bomType)) + bomRegex = regexp.MustCompile(fmt.Sprintf(`%s/(.+)/(.+)/(sbom.+json)`, bomType)) } return func(path string, info fs.FileInfo, err error) error { diff --git a/restorer_test.go b/restorer_test.go index 4a8cdbb62..de80f2ba3 100644 --- a/restorer_test.go +++ b/restorer_test.go @@ -697,19 +697,19 @@ func testRestorerBuilder(buildpackAPI, platformAPI string) func(t *testing.T, wh it("restores the previous image SBOM layer", func() { h.AssertNil(t, restorer.Restore(testCache)) - got := h.MustReadFile(t, filepath.Join(layersDir, "buildpack.id", "cache-true.bom.cdx.json")) + got := h.MustReadFile(t, filepath.Join(layersDir, "buildpack.id", "cache-true.sbom.cdx.json")) want := `{"key": "some-cache-bom-content"}` h.AssertEq(t, string(got), want) - got = h.MustReadFile(t, filepath.Join(layersDir, "buildpack.id", "launch-true.bom.cdx.json")) + got = h.MustReadFile(t, filepath.Join(layersDir, "buildpack.id", "launch-true.sbom.cdx.json")) want = `{"key": "some-launch-bom-content"}` h.AssertEq(t, string(got), want) - got = h.MustReadFile(t, filepath.Join(layersDir, "escaped_buildpack_id", "launch-true.bom.cdx.json")) + got = h.MustReadFile(t, filepath.Join(layersDir, "escaped_buildpack_id", "launch-true.sbom.cdx.json")) want = `{"key": "some-escaped-launch-bom-content"}` h.AssertEq(t, string(got), want) - h.AssertPathDoesNotExist(t, filepath.Join(layersDir, "undetected-buildpack.id", "launch-true.bom.cdx.json")) + h.AssertPathDoesNotExist(t, filepath.Join(layersDir, "undetected-buildpack.id", "launch-true.sbom.cdx.json")) h.AssertPathDoesNotExist(t, filepath.Join(layersDir, "sbom")) }) }) diff --git a/testdata/restorer/sbom/cache/buildpack.id/cache-true/bom.cdx.json b/testdata/restorer/sbom/cache/buildpack.id/cache-true/sbom.cdx.json similarity index 100% rename from testdata/restorer/sbom/cache/buildpack.id/cache-true/bom.cdx.json rename to testdata/restorer/sbom/cache/buildpack.id/cache-true/sbom.cdx.json diff --git a/testdata/restorer/sbom/cache/buildpack.id/launch-true/bom.cdx.json b/testdata/restorer/sbom/cache/buildpack.id/launch-true/sbom.cdx.json similarity index 100% rename from testdata/restorer/sbom/cache/buildpack.id/launch-true/bom.cdx.json rename to testdata/restorer/sbom/cache/buildpack.id/launch-true/sbom.cdx.json diff --git a/testdata/restorer/sbom/launch/buildpack.id/launch-true/bom.cdx.json b/testdata/restorer/sbom/launch/buildpack.id/launch-true/sbom.cdx.json similarity index 100% rename from testdata/restorer/sbom/launch/buildpack.id/launch-true/bom.cdx.json rename to testdata/restorer/sbom/launch/buildpack.id/launch-true/sbom.cdx.json diff --git a/testdata/restorer/sbom/launch/escaped_buildpack_id/launch-true/bom.cdx.json b/testdata/restorer/sbom/launch/escaped_buildpack_id/launch-true/sbom.cdx.json similarity index 100% rename from testdata/restorer/sbom/launch/escaped_buildpack_id/launch-true/bom.cdx.json rename to testdata/restorer/sbom/launch/escaped_buildpack_id/launch-true/sbom.cdx.json diff --git a/testdata/restorer/sbom/launch/undetected-buildpack.id/launch-true/bom.cdx.json b/testdata/restorer/sbom/launch/undetected-buildpack.id/launch-true/sbom.cdx.json similarity index 100% rename from testdata/restorer/sbom/launch/undetected-buildpack.id/launch-true/bom.cdx.json rename to testdata/restorer/sbom/launch/undetected-buildpack.id/launch-true/sbom.cdx.json