Skip to content

Commit

Permalink
new updates
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAngel1196 committed Oct 25, 2023
1 parent 4d32bf9 commit 965ffdb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Execute() {
func init() {
persistent := rootCmd.PersistentFlags()
persistent.StringP("config", "c", "config.toml", "Config file path.")
persistent.StringSliceP("reporters", "r", []string{"slack"}, "Specify a list of reporters for reporting vulnerabilities.")
persistent.StringSliceP("reporters", "r", []string{"slack", "console"}, "Specify a list of reporters for reporting vulnerabilities.")
persistent.BoolP("quiet", "q", false, "Suppress all console output. (Mutually exclusive with 'verbose'.)")
persistent.CountP("verbose", "v", "More verbose output. Specifying multiple times increases verbosity. (Mutually exclusive with 'quiet'.)")

Expand Down
7 changes: 2 additions & 5 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -81,8 +80,7 @@ func TestGetUserConfigFromFile(t *testing.T) {
}

func TestGetUserConfigFromEnv(t *testing.T) {
sliceAsStrings := strings.Join([]string{"slack"}, ",")
t.Setenv("VULNBOT_REPORTERS", sliceAsStrings)
t.Setenv("VULNBOT_REPORTERS", "slack")
t.Setenv("VULNBOT_GITHUB_ORG", "hitchhikers")
// This should override the config file
t.Setenv("VULNBOT_DEFAULT_SLACK_CHANNEL", "other_slack_channel")
Expand All @@ -93,8 +91,7 @@ func TestGetUserConfigFromEnv(t *testing.T) {
cfg, err := config.GetUserConfig(testDataPath)
assert.Nil(t, err)

deserializedSlice := strings.Split(sliceAsStrings, ",")
assert.Equal(t, deserializedSlice, cfg.Reporters)
assert.Equal(t, []string{"slack"}, cfg.Reporters)
assert.Equal(t, "hitchhikers", cfg.Github_org)
assert.Equal(t, "other_slack_channel", cfg.Default_slack_channel)
}
5 changes: 4 additions & 1 deletion internal/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ func Scan(cmd *cobra.Command, args []string) {
}
}

reporters = append(reporters, &reporting.ConsoleReporter{Config: &cfg})
if slices.Contains(cfg.Reporters, "console") {
reporters = append(reporters, &reporting.ConsoleReporter{Config: &cfg})
}

Check warning on line 50 in internal/scan.go

View check run for this annotation

Codecov / codecov/patch

internal/scan.go#L48-L50

Added lines #L48 - L50 were not covered by tests

reportTime := time.Now().UTC()
wg := new(sync.WaitGroup)

Expand Down

0 comments on commit 965ffdb

Please sign in to comment.