mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
* add new cyclonedx format object Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove cyclonedx presenter Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove cyclonedx presenter call Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove dependence on golden images for format tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * wire up new formt + rename all-presenters ref Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add CLI test to ensure that all formats can be expressed as report output Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add cyclonedx version and encoding format to package name Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * optionally preserve format snapshot images Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting + text unit tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
30 lines
585 B
Go
30 lines
585 B
Go
package cyclonedx12xml
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"io"
|
|
|
|
"github.com/anchore/syft/syft/distro"
|
|
|
|
"github.com/anchore/syft/syft/pkg"
|
|
"github.com/anchore/syft/syft/source"
|
|
)
|
|
|
|
func encoder(output io.Writer, catalog *pkg.Catalog, srcMetadata *source.Metadata, d *distro.Distro, scope source.Scope) error {
|
|
enc := xml.NewEncoder(output)
|
|
enc.Indent("", " ")
|
|
|
|
_, err := output.Write([]byte(xml.Header))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = enc.Encode(toFormatModel(catalog, srcMetadata, d, scope))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, err = output.Write([]byte("\n"))
|
|
return err
|
|
}
|