mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +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>
41 lines
767 B
Go
41 lines
767 B
Go
package formats
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/anchore/syft/internal/formats/cyclonedx12xml"
|
|
|
|
"github.com/anchore/syft/internal/formats/table"
|
|
|
|
"github.com/anchore/syft/internal/formats/syftjson"
|
|
"github.com/anchore/syft/syft/format"
|
|
)
|
|
|
|
// TODO: eventually this is the source of truth for all formatters
|
|
func All() []format.Format {
|
|
return []format.Format{
|
|
syftjson.Format(),
|
|
table.Format(),
|
|
cyclonedx12xml.Format(),
|
|
}
|
|
}
|
|
|
|
func Identify(by []byte) (*format.Format, error) {
|
|
for _, f := range All() {
|
|
if err := f.Validate(bytes.NewReader(by)); err != nil {
|
|
continue
|
|
}
|
|
return &f, nil
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func ByOption(option format.Option) *format.Format {
|
|
for _, f := range All() {
|
|
if f.Option == option {
|
|
return &f
|
|
}
|
|
}
|
|
return nil
|
|
}
|