Skip to content
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
2 changes: 1 addition & 1 deletion pkg/parser/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const DefaultSeverityThreshold = models.SeverityMedium

func NewDefaultConfig() *models.Configuration {
return &models.Configuration{
SeverityThreshold: DefaultSeverityThreshold,
SeverityThreshold: "",
IgnoreDirs: []string{},
IgnorePaths: []string{},
Code: models.Code{},
Expand Down
5 changes: 2 additions & 3 deletions pkg/parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ func ParseConfiguration(data []byte) (*models.Configuration, error) {
}

func sanitizeConfig(config *models.Configuration) {
config.SeverityThreshold = strings.ToUpper(config.SeverityThreshold)
if config.SeverityThreshold == "" {
config.SeverityThreshold = DefaultSeverityThreshold
if config.SeverityThreshold != "" {
config.SeverityThreshold = strings.ToUpper(config.SeverityThreshold)
}

for name, n := range config.Notifications {
Expand Down
12 changes: 6 additions & 6 deletions pkg/parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestParseConfiguration(t *testing.T) {
name: "default values",
data: "",
expected: &models.Configuration{
SeverityThreshold: models.SeverityMedium,
SeverityThreshold: "",
IgnoreDirs: nil,
IgnorePaths: nil,
SecretsWhitelist: nil,
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestParseConfiguration(t *testing.T) {
name: "user provided empty severity_threshold",
data: "severity_threshold: ''",
expected: &models.Configuration{
SeverityThreshold: models.SeverityMedium,
SeverityThreshold: "",
IgnoreDirs: nil,
IgnorePaths: nil,
SecretsWhitelist: nil,
Expand All @@ -83,7 +83,7 @@ func TestParseConfiguration(t *testing.T) {
name: "user provided a single secret",
data: `secrets_whitelist: ["password"]`,
expected: &models.Configuration{
SeverityThreshold: models.SeverityMedium,
SeverityThreshold: "",
IgnoreDirs: nil,
IgnorePaths: nil,
SecretsWhitelist: []string{"password"},
Expand All @@ -100,7 +100,7 @@ func TestParseConfiguration(t *testing.T) {
name: "user provided empty secret whitelist",
data: `secrets_whitelist: `,
expected: &models.Configuration{
SeverityThreshold: models.SeverityMedium,
SeverityThreshold: "",
IgnoreDirs: nil,
IgnorePaths: nil,
SecretsWhitelist: nil,
Expand All @@ -113,7 +113,7 @@ func TestParseConfiguration(t *testing.T) {
name: "user provided empty ignore patterns",
data: `ignore_paths: `,
expected: &models.Configuration{
SeverityThreshold: models.SeverityMedium,
SeverityThreshold: "",
IgnoreDirs: nil,
IgnorePaths: nil,
SecretsWhitelist: nil,
Expand All @@ -126,7 +126,7 @@ func TestParseConfiguration(t *testing.T) {
name: "user provided glob in ignore patterns",
data: `ignore_paths: ["*d"]`,
expected: &models.Configuration{
SeverityThreshold: models.SeverityMedium,
SeverityThreshold: "",
IgnoreDirs: nil,
IgnorePaths: []string{"*d"},
SecretsWhitelist: nil,
Expand Down
2 changes: 1 addition & 1 deletion pkg/validator/severity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestValidateSeverityThreshold(t *testing.T) {
{
name: "default configuration",
config: parser.NewDefaultConfig(),
expected: true,
expected: false,
},
{
name: "empty SeverityThreshold",
Expand Down