mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
fix: SPDX tag value version selector (#2665)
Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
parent
170ac079d4
commit
2995c3c4fd
@ -3,6 +3,7 @@ package options
|
|||||||
import (
|
import (
|
||||||
"github.com/anchore/clio"
|
"github.com/anchore/clio"
|
||||||
"github.com/anchore/syft/syft/format"
|
"github.com/anchore/syft/syft/format"
|
||||||
|
"github.com/anchore/syft/syft/format/spdxtagvalue"
|
||||||
"github.com/anchore/syft/syft/sbom"
|
"github.com/anchore/syft/syft/sbom"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ func (o Format) Encoders() ([]sbom.FormatEncoder, error) {
|
|||||||
Template: o.Template.config(),
|
Template: o.Template.config(),
|
||||||
SyftJSON: o.SyftJSON.config(),
|
SyftJSON: o.SyftJSON.config(),
|
||||||
SPDXJSON: o.SPDXJSON.config(format.AllVersions), // we support multiple versions, not just a single version
|
SPDXJSON: o.SPDXJSON.config(format.AllVersions), // we support multiple versions, not just a single version
|
||||||
|
SPDXTagValue: spdxtagvalue.EncoderConfig{Version: format.AllVersions}, // we support multiple versions, not just a single version
|
||||||
CyclonedxJSON: o.CyclonedxJSON.config(format.AllVersions), // we support multiple versions, not just a single version
|
CyclonedxJSON: o.CyclonedxJSON.config(format.AllVersions), // we support multiple versions, not just a single version
|
||||||
CyclonedxXML: o.CyclonedxXML.config(format.AllVersions), // we support multiple versions, not just a single version
|
CyclonedxXML: o.CyclonedxXML.config(format.AllVersions), // we support multiple versions, not just a single version
|
||||||
}.Encoders()
|
}.Encoders()
|
||||||
|
|||||||
@ -39,3 +39,40 @@ func TestAllFormatsExpressible(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_formatVersionsExpressible(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
format string
|
||||||
|
assertion traitAssertion
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
format: "spdx@2.1",
|
||||||
|
assertion: assertInOutput("SPDXVersion: SPDX-2.1"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
format: "spdx@2.2",
|
||||||
|
assertion: assertInOutput("SPDXVersion: SPDX-2.2"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
format: "spdx@2.3",
|
||||||
|
assertion: assertInOutput("SPDXVersion: SPDX-2.3"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
format: "spdx-json@2.2",
|
||||||
|
assertion: assertInOutput(`"spdxVersion":"SPDX-2.2"`),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
format: "spdx-json@2.3",
|
||||||
|
assertion: assertInOutput(`"spdxVersion":"SPDX-2.3"`),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.format, func(t *testing.T) {
|
||||||
|
args := []string{"dir:./test-fixtures/image-pkg-coverage", "-o", test.format}
|
||||||
|
cmd, stdout, stderr := runSyft(t, nil, args...)
|
||||||
|
test.assertion(t, stdout, stderr, cmd.ProcessState.ExitCode())
|
||||||
|
logOutputOnFailure(t, cmd, stdout, stderr)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user