Skip to content

Commit

Permalink
Adds a reproducibility verification check (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestEckhardt authored Aug 3, 2022
1 parent 3b843c5 commit 3d5da08
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions sbom/formatted_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func testFormattedReader(t *testing.T, context spec.G, it spec.S) {
Expect(cdxOutput.Components[3].Name).To(Equal("once"), buffer.String())
Expect(cdxOutput.Components[4].Name).To(Equal("pump"), buffer.String())
Expect(cdxOutput.Components[5].Name).To(Equal("wrappy"), buffer.String())

rerunBuffer := bytes.NewBuffer(nil)
_, err = io.Copy(rerunBuffer, sbom.NewFormattedReader(bom, sbom.CycloneDXFormat))
Expect(err).NotTo(HaveOccurred())
Expect(rerunBuffer).To(Equal(buffer))
})

it("writes the SBOM in the latest CycloneDX format (1.4)", func() {
Expand Down Expand Up @@ -82,6 +87,11 @@ func testFormattedReader(t *testing.T, context spec.G, it spec.S) {
Expect(cdxOutput.Components[3].Name).To(Equal("once"), buffer.String())
Expect(cdxOutput.Components[4].Name).To(Equal("pump"), buffer.String())
Expect(cdxOutput.Components[5].Name).To(Equal("wrappy"), buffer.String())

rerunBuffer := bytes.NewBuffer(nil)
_, err = io.Copy(rerunBuffer, sbom.NewFormattedReader(bom, sbom.Format(syft.CycloneDxJSONFormatID)))
Expect(err).NotTo(HaveOccurred())
Expect(rerunBuffer).To(Equal(buffer))
})

it("writes the SBOM in the default SPDX format", func() {
Expand Down Expand Up @@ -124,6 +134,11 @@ func testFormattedReader(t *testing.T, context spec.G, it spec.S) {
Expect(syftOutput.Artifacts[3].Name).To(Equal("once"), buffer.String())
Expect(syftOutput.Artifacts[4].Name).To(Equal("pump"), buffer.String())
Expect(syftOutput.Artifacts[5].Name).To(Equal("wrappy"), buffer.String())

rerunBuffer := bytes.NewBuffer(nil)
_, err = io.Copy(rerunBuffer, sbom.NewFormattedReader(bom, sbom.SyftFormat))
Expect(err).NotTo(HaveOccurred())
Expect(rerunBuffer).To(Equal(buffer))
})

it("writes the SBOM in Syft 2.0.2 format", func() {
Expand All @@ -146,6 +161,11 @@ func testFormattedReader(t *testing.T, context spec.G, it spec.S) {
Expect(syftOutput.Artifacts[3].Name).To(Equal("once"), buffer.String())
Expect(syftOutput.Artifacts[4].Name).To(Equal("pump"), buffer.String())
Expect(syftOutput.Artifacts[5].Name).To(Equal("wrappy"), buffer.String())

rerunBuffer := bytes.NewBuffer(nil)
_, err = io.Copy(rerunBuffer, sbom.NewFormattedReader(bom, sbom.Format(syft2.ID)))
Expect(err).NotTo(HaveOccurred())
Expect(rerunBuffer).To(Equal(buffer))
})

it("writes the SBOM in the latest Syft format (3.*)", func() {
Expand All @@ -168,6 +188,11 @@ func testFormattedReader(t *testing.T, context spec.G, it spec.S) {
Expect(syftOutput.Artifacts[3].Name).To(Equal("once"), buffer.String())
Expect(syftOutput.Artifacts[4].Name).To(Equal("pump"), buffer.String())
Expect(syftOutput.Artifacts[5].Name).To(Equal("wrappy"), buffer.String())

rerunBuffer := bytes.NewBuffer(nil)
_, err = io.Copy(rerunBuffer, sbom.NewFormattedReader(bom, sbom.Format(syft.JSONFormatID)))
Expect(err).NotTo(HaveOccurred())
Expect(rerunBuffer).To(Equal(buffer))
})

context("Read", func() {
Expand Down

0 comments on commit 3d5da08

Please sign in to comment.