Skip to content

Commit 666644d

Browse files
authored
Fix issue where CustomSeverities are not respected in config (#459)
Original ability was added in: #281 When trying out the functionality, it does not respect custom_severities as documented in the README. This patch addresses it by including the porting of custom severities from the the same location where other config keys are copied I've confirmed that it works both in a new test and in manual regression testing. Fixes: #364
1 parent 9a5d30e commit 666644d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

talismanrc/talismanrc.go

+1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ func fromPersistedRC(configFromTalismanRCFile *persistedRC, mode Mode) *Talisman
201201
tRC.ScopeConfig = configFromTalismanRCFile.ScopeConfig
202202
tRC.Experimental = configFromTalismanRCFile.Experimental
203203
tRC.CustomPatterns = configFromTalismanRCFile.CustomPatterns
204+
tRC.CustomSeverities = configFromTalismanRCFile.CustomSeverities
204205
tRC.Experimental = configFromTalismanRCFile.Experimental
205206
tRC.AllowedPatterns = make([]*regexp.Regexp, len(configFromTalismanRCFile.AllowedPatterns))
206207
for i, p := range configFromTalismanRCFile.AllowedPatterns {

talismanrc/talismanrc_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ func TestShouldConvertThresholdToValue(t *testing.T) {
7878
assert.Equal(t, newPersistedRC(talismanRCContents).Threshold, severity.High)
7979
}
8080

81+
func TestObeysCustomSeverityLevelsAndThreshold(t *testing.T) {
82+
talismanRCContents := []byte(`threshold: high
83+
custom_severities:
84+
- detector: Base64Content
85+
severity: low
86+
`)
87+
persistedRC := newPersistedRC(talismanRCContents)
88+
talismanRC := fromPersistedRC(persistedRC, ScanMode)
89+
assert.Equal(t, newPersistedRC(talismanRCContents).Threshold, severity.High)
90+
assert.Equal(t, len(newPersistedRC(talismanRCContents).CustomSeverities), 1)
91+
assert.Equal(t, persistedRC.CustomSeverities, talismanRC.CustomSeverities)
92+
}
93+
8194
func TestDirectoryPatterns(t *testing.T) {
8295
assertAccepts("foo/", "", "bar", t)
8396
assertAccepts("foo/", "", "foo", t)

0 commit comments

Comments
 (0)