Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CSV format flag #1208

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

--
Error: flag error: report flags error: invalid format argument for privacy report; supported values: json, yaml html
Error: flag error: report flags error: invalid format argument for privacy report; supported values: csv, json, yaml, html
Usage:
scan [flags] <path>
Aliases:
Expand Down Expand Up @@ -44,5 +44,5 @@ General Flags
--no-color Disable color in output


flag error: report flags error: invalid format argument for privacy report; supported values: json, yaml html
flag error: report flags error: invalid format argument for privacy report; supported values: csv, json, yaml, html

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
Loading