Skip to content

Commit

Permalink
chore: clear up flag issue with multiple cyclonedx format
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
  • Loading branch information
spiffcs committed Dec 13, 2022
1 parent b747021 commit cb3116e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 46 deletions.
4 changes: 2 additions & 2 deletions grype/presenter/cyclonedx/presenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ type Presenter struct {
}

// NewPresenter is a *Presenter constructor
func NewPresenter(pb models.PresenterBundle) *Presenter {
func NewPresenter(pb models.PresenterBundle, format cyclonedx.BOMFileFormat) *Presenter {
return &Presenter{
results: pb.Matches,
packages: pb.Packages,
metadataProvider: pb.MetadataProvider,
srcMetadata: pb.Context.Source,
sbom: pb.SBOM,
format: cyclonedx.BOMFileFormatJSON,
format: format,
}
}

Expand Down
40 changes: 0 additions & 40 deletions grype/presenter/cyclonedxvex/presenter.go

This file was deleted.

4 changes: 2 additions & 2 deletions grype/presenter/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func parse(userInput string) format {
return jsonFormat
case strings.ToLower(tableFormat.String()):
return tableFormat
case strings.ToLower(cycloneDXFormat.String()):
return cycloneDXFormat
case strings.ToLower(sarifFormat.String()):
return sarifFormat
case strings.ToLower(templateFormat.String()):
return templateFormat
case strings.ToLower(cycloneDXFormat.String()):
return cycloneDXFormat
case strings.ToLower(embeddedVEXJSON.String()):
return embeddedVEXJSON
case strings.ToLower(embeddedVEXXML.String()):
Expand Down
6 changes: 4 additions & 2 deletions grype/presenter/presenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ func GetPresenter(c Config, pb models.PresenterBundle) Presenter {
return table.NewPresenter(pb)
}
return table.NewPresenter(pb)
// NOTE: cyclonedx is identical to embeddedVEXJSON
// The cyclonedx library only provides two BOM formats: JSON and XML
case cycloneDXFormat:
return cyclonedx.NewPresenter(pb)
return cyclonedx.NewPresenter(pb, cyclonedxLib.BOMFileFormatJSON)
case embeddedVEXJSON:
return cyclonedxvex.NewPresenter(pb, cyclonedxLib.BOMFileFormatJSON)
case embeddedVEXXML:
return cyclonedxvex.NewPresenter(pb, cyclonedxLib.BOMFileFormatXML)
return cyclonedx.NewPresenter(pb, cyclonedxLib.BOMFileFormatXML)
case sarifFormat:
return sarif.NewPresenter(pb)
case templateFormat:
Expand Down

0 comments on commit cb3116e

Please sign in to comment.