diff --git a/cmd/scanner_cmd_test.go b/cmd/scanner_cmd_test.go index d663ba9c..d74dc9b1 100644 --- a/cmd/scanner_cmd_test.go +++ b/cmd/scanner_cmd_test.go @@ -2,6 +2,7 @@ package main import ( "os" + "talisman/detector/severity" "talisman/git_testing" "talisman/talismanrc" "testing" @@ -81,8 +82,7 @@ func TestScannerCmdDetectsSecretAndIgnoresWhileRunningNormalScanMode(t *testing. scannerCmd := NewScannerCmd(false, git.GetRoot()) scannerCmd.Run(&talismanrc.TalismanRC{ - IgnoreConfigs: []talismanrc.IgnoreConfig{ - }}) + IgnoreConfigs: []talismanrc.IgnoreConfig{}}) assert.Equal(t, 1, scannerCmd.exitStatus(), "Expected ScannerCmd.exitStatus() to return 1 since secrets file ignore is enabled") }) } diff --git a/talismanrc/talismanrc.go b/talismanrc/talismanrc.go index 90bdd588..8b8ba6bc 100644 --- a/talismanrc/talismanrc.go +++ b/talismanrc/talismanrc.go @@ -201,6 +201,7 @@ func fromPersistedRC(configFromTalismanRCFile *persistedRC, mode Mode) *Talisman tRC.ScopeConfig = configFromTalismanRCFile.ScopeConfig tRC.Experimental = configFromTalismanRCFile.Experimental tRC.CustomPatterns = configFromTalismanRCFile.CustomPatterns + tRC.CustomSeverities = configFromTalismanRCFile.CustomSeverities tRC.Experimental = configFromTalismanRCFile.Experimental tRC.AllowedPatterns = make([]*regexp.Regexp, len(configFromTalismanRCFile.AllowedPatterns)) for i, p := range configFromTalismanRCFile.AllowedPatterns { diff --git a/talismanrc/talismanrc_test.go b/talismanrc/talismanrc_test.go index 251f1fe3..96240912 100644 --- a/talismanrc/talismanrc_test.go +++ b/talismanrc/talismanrc_test.go @@ -78,6 +78,19 @@ func TestShouldConvertThresholdToValue(t *testing.T) { assert.Equal(t, newPersistedRC(talismanRCContents).Threshold, severity.High) } +func TestObeysCustomSeverityLevelsAndThreshold(t *testing.T) { + talismanRCContents := []byte(`threshold: high +custom_severities: +- detector: Base64Content + severity: low +`) + persistedRC := newPersistedRC(talismanRCContents) + talismanRC := fromPersistedRC(persistedRC, ScanMode) + assert.Equal(t, newPersistedRC(talismanRCContents).Threshold, severity.High) + assert.Equal(t, len(newPersistedRC(talismanRCContents).CustomSeverities), 1) + assert.Equal(t, persistedRC.CustomSeverities, talismanRC.CustomSeverities) +} + func TestDirectoryPatterns(t *testing.T) { assertAccepts("foo/", "", "bar", t) assertAccepts("foo/", "", "foo", t)