Skip to content

Commit

Permalink
feat: add CSV format flag
Browse files Browse the repository at this point in the history
  • Loading branch information
elsapet committed Aug 25, 2023
1 parent 9941cda commit 861079a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/flag/report_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var (
FormatJSON = "json"
FormatYAML = "yaml"
FormatHTML = "html"
FormatCSV = "csv"
FormatEmpty = ""

ReportPrivacy = "privacy"
Expand All @@ -26,7 +27,7 @@ var (
)

var ErrInvalidFormatSecurity = errors.New("invalid format argument for security report; supported values: json, yaml, sarif, gitlab-sast, rdjson, html")
var ErrInvalidFormatPrivacy = errors.New("invalid format argument for privacy report; supported values: json, yaml html")
var ErrInvalidFormatPrivacy = errors.New("invalid format argument for privacy report; supported values: csv, json, yaml, html")
var ErrInvalidFormatDefault = errors.New("invalid format argument; supported values: json, yaml")
var ErrInvalidReport = errors.New("invalid report argument; supported values: security, privacy")
var ErrInvalidSeverity = errors.New("invalid severity argument; supported values: critical, high, medium, low, warning")
Expand Down Expand Up @@ -134,6 +135,10 @@ func (f *ReportFlagGroup) ToOptions() (ReportOptions, error) {
if report != ReportPrivacy && report != ReportSecurity {
return ReportOptions{}, invalidFormat
}
case FormatCSV:
if report != ReportPrivacy {
return ReportOptions{}, invalidFormat
}
case FormatSarif, FormatGitLabSast, FormatReviewDog:
if report != ReportSecurity {
return ReportOptions{}, invalidFormat
Expand Down
2 changes: 1 addition & 1 deletion pkg/report/output/privacy/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewFormatter(reportData *outputtypes.ReportData, config settings.Config) *F

func (f Formatter) Format(format string) (output *string, err error) {
switch format {
case flag.FormatEmpty:
case flag.FormatEmpty, flag.FormatCSV:
stringBuilder, err := BuildCsvString(f.ReportData, f.Config)
if err != nil {
return output, err
Expand Down

0 comments on commit 861079a

Please sign in to comment.