forked from karanmilan/talisman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
61 lines (48 loc) · 1.48 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package talismanrc
import (
"regexp"
"github.com/thoughtworks/talisman/detector/severity"
)
type PatternString string
type CustomSeverityConfig struct {
Detector string `yaml:"detector"`
Severity severity.Severity `yaml:"severity"`
}
type IgnoreConfig interface {
isEffective(string) bool
GetFileName() string
GetAllowedPatterns() []*regexp.Regexp
ChecksumMatches(checksum string) bool
}
type FileIgnoreConfig struct {
FileName string `yaml:"filename"`
Checksum string `yaml:"checksum,omitempty"`
IgnoreDetectors []string `yaml:"ignore_detectors,omitempty"`
AllowedPatterns []string `yaml:"allowed_patterns,omitempty"`
compiledPatterns []*regexp.Regexp
}
func (i *FileIgnoreConfig) isEffective(detectorName string) bool {
return !isEmptyString(i.FileName) &&
contains(i.IgnoreDetectors, detectorName)
}
func (i *FileIgnoreConfig) GetFileName() string {
return i.FileName
}
func (i *FileIgnoreConfig) ChecksumMatches(incomingChecksum string) bool {
return i.Checksum == incomingChecksum
}
func (i *FileIgnoreConfig) GetAllowedPatterns() []*regexp.Regexp {
if i.compiledPatterns == nil {
i.compiledPatterns = make([]*regexp.Regexp, len(i.AllowedPatterns))
for idx, p := range i.AllowedPatterns {
i.compiledPatterns[idx] = regexp.MustCompile(p)
}
}
return i.compiledPatterns
}
type ScopeConfig struct {
ScopeName string `yaml:"scope"`
}
type ExperimentalConfig struct {
Base64EntropyThreshold float64 `yaml:"base64EntropyThreshold,omitempty"`
}