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)