github.com/lineaje-labs/syft@v0.98.1-0.20231227153149-9e393f60ff1b/syft/format/github/encoder.go (about) 1 package github 2 3 import ( 4 "encoding/json" 5 "io" 6 7 "github.com/anchore/syft/syft/sbom" 8 "github.com/lineaje-labs/syft/syft/format/github/internal/model" 9 ) 10 11 const ID sbom.FormatID = "github-json" 12 13 type encoder struct { 14 } 15 16 func NewFormatEncoder() sbom.FormatEncoder { 17 return encoder{} 18 } 19 20 func (e encoder) ID() sbom.FormatID { 21 return ID 22 } 23 24 func (e encoder) Aliases() []string { 25 return []string{ 26 "github", 27 } 28 } 29 30 func (e encoder) Version() string { 31 return sbom.AnyVersion 32 } 33 34 func (e encoder) Encode(writer io.Writer, s sbom.SBOM) error { 35 bom := model.ToGithubModel(&s) 36 37 enc := json.NewEncoder(writer) 38 enc.SetEscapeHTML(false) 39 enc.SetIndent("", " ") 40 41 return enc.Encode(bom) 42 }