Skip to content

Commit 60205e5

Browse files
committed
fix: error message prefix not showing in output
1 parent a3a6575 commit 60205e5

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

config/config.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,29 @@ profile: false
4949
# security options
5050
security:
5151
# override or not default security rules
52-
merge_rules: true
52+
merge_rules: false
5353
# reveal_secrets < 0 reveal full secrets
5454
# reveal_secrets = 0 hide secrets
5555
# reveal_secrets > 0 partial reveal "N" characters from secrets
5656
reveal_secrets: 4
5757
# security rules
5858
rules:
59-
- description: GOOGLE_API_KEY
60-
regexp: AIza[0-9A-Za-z\\-_]{35}
61-
tags: [key, google]
59+
- description: AWS_ACCESS_KEY
60+
regexp: (A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}
61+
severity: MAJOR
62+
tags: ["cloud", "aws"]
63+
- description: ASYMMETRIC_PRIVATE_KEY
64+
regexp: (\-){5}BEGIN[[:blank:]]*?(RSA|OPENSSH|DSA|EC|PGP)?[[:blank:]]*?PRIVATE[[:blank:]]KEY[[:blank:]]*?(BLOCK)?(\-){5}.*
65+
severity: MAJOR
66+
tags: ["key", "certificates"]
67+
- description: CONNECTION_STRING
68+
regexp: (?i)(?P<scheme>[a-z0-9+-.]{3,30}://)?[0-9a-z-]{3,30}:(?P<secret>[a-zA-Z0-9!?$)(.=<>\/%@#*&{}_^+-]{6,45})@(?P<host>[0-9a-z-.]{1,50})(?::(?P<port>[0-9]{1,5}))?]?
69+
severity: MAJOR
70+
- description: PASSWORD_XML
71+
file: (?i)(.*.xml)$
72+
regexp: (?i)<(?:(?:pass(?:w(?:or)?d)?)|(?:p(?:s)?w(?:r)?d)|secret)>(?P<secret>.{5,256})</(?:(?:pass(?:w(?:or)?d)?)|(?:p(?:s)?w(?:r)?d)|secret)>
73+
severity: MAJOR
74+
- description: SECRET_KEY
75+
regexp: (?im)(?:(?:a(?:ws|ccess|p(?:i|p(?:lication)?)))|private|se(?:nsitive|cret))?[[:space:]_-]?(?:key|token)[[:space:]]{0,20}[=:]{1,2}[[:space:]]{0,20}['\"]?(?P<secret>[a-zA-Z0-9!?$)(.=<>\/%@#*&{}_^+-]{6,45})(?:[[:space:];'\",]|$)
76+
severity: MAJOR
77+
tags: ["token"]

internal/config/config.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Options struct {
1616
Contact string `mapstructure:"contact"`
1717
Handlers map[string]hook.Rule `mapstructure:"handlers"`
1818
DocsLink string `mapstructure:"docs-link"`
19-
ErrorMessagePrefix string `mapstructure:"error-message-prefix"`
19+
ErrorMessagePrefix string `mapstructure:"error_message_prefix"`
2020
HookFile string `mapstructure:"hook-file"`
2121
HookInput string `mapstructure:"hook-input"`
2222
HookType string `mapstructure:"hook-type"`
@@ -30,7 +30,7 @@ type Options struct {
3030
Output string `mapstructure:"output"`
3131
OutputFormat string `mapstructure:"output-format"`
3232
PluginsDirectory string `mapstructure:"plugins-directory"`
33-
Security `mapstructure:"security"`
33+
*Security `mapstructure:"security"`
3434
Verbose bool `mapstructure:"verbose"`
3535
URI string `mapstructure:"uri"`
3636
}
@@ -57,6 +57,16 @@ func (options *Options) Validate() error {
5757
if options.Concurrent == 0 {
5858
options.Concurrent = runtime.NumCPU()
5959
}
60+
if options.Security != nil && len(options.Security.Rules) > 0 {
61+
for index, rule := range options.Security.Rules {
62+
if rule.Description == "" || rule.Regexp == "" {
63+
options.Security.Rules = append(options.Security.Rules[:index], options.Security.Rules[index+1:]...)
64+
}
65+
if rule.Severity == "" {
66+
rule.Severity = "INFO"
67+
}
68+
}
69+
}
6070
return nil
6171
}
6272

0 commit comments

Comments
 (0)