File tree Expand file tree Collapse file tree 7 files changed +15
-3
lines changed Expand file tree Collapse file tree 7 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ import (
5
5
"crypto/sha512"
6
6
"encoding/base64"
7
7
"encoding/hex"
8
+ "strings"
9
+
10
+ "golang.org/x/text/cases"
11
+ "golang.org/x/text/language"
8
12
)
9
13
10
14
// Action represents the action to take when
@@ -102,6 +106,11 @@ func (s ScannerName) String() string {
102
106
return string (s )
103
107
}
104
108
109
+ // Normalize returns the scanner name in a normalized format (capitalized).
110
+ func (s ScannerName ) Normalize () ScannerName {
111
+ return ScannerName (cases .Title (language .English ).String (strings .ToLower (s .String ())))
112
+ }
113
+
105
114
const (
106
115
// ScannerGitleaks is the name of the ScannerGitleaks scanner.
107
116
ScannerGitleaks ScannerName = "Gitleaks"
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ type ScanPolicySpec struct {
27
27
EnableConfigMapMutation bool `json:"enableConfigMapMutation,omitempty"`
28
28
29
29
// Scanner defines which detection engine to use for identifying secrets.
30
- // +kubebuilder:validation:Enum=Gitleaks
30
+ // +kubebuilder:validation:Enum=Gitleaks;gitleaks
31
31
// +kubebuilder:default=Gitleaks
32
32
Scanner ScannerName `json:"scanner,omitempty"`
33
33
Original file line number Diff line number Diff line change 88
88
secrets.
89
89
enum :
90
90
- Gitleaks
91
+ - gitleaks
91
92
type : string
92
93
type : object
93
94
status :
Original file line number Diff line number Diff line change 88
88
secrets.
89
89
enum :
90
90
- Gitleaks
91
+ - gitleaks
91
92
type : string
92
93
type : object
93
94
status :
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ require (
13
13
github.com/stretchr/testify v1.10.0
14
14
github.com/zricethezav/gitleaks/v8 v8.27.2
15
15
go.uber.org/zap v1.27.0
16
+ golang.org/x/text v0.25.0
16
17
k8s.io/api v0.33.1
17
18
k8s.io/apimachinery v0.33.1
18
19
k8s.io/client-go v0.33.1
@@ -114,7 +115,6 @@ require (
114
115
golang.org/x/sync v0.14.0 // indirect
115
116
golang.org/x/sys v0.33.0 // indirect
116
117
golang.org/x/term v0.32.0 // indirect
117
- golang.org/x/text v0.25.0 // indirect
118
118
golang.org/x/time v0.11.0 // indirect
119
119
golang.org/x/tools v0.33.0 // indirect
120
120
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ type Gitleaks struct {
13
13
}
14
14
15
15
func NewGitleaksScanner () * Gitleaks {
16
+ // TODO: let the user configure gitleaks config via scan policies
16
17
c := config.ViperConfig {
17
18
Extend : config.Extend {
18
19
UseDefault : true ,
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ var scanners = map[v1alpha1.ScannerName]Scanner{
34
34
// Get returns the scanner for the given name.
35
35
// If the scanner is not found, it returns nil.
36
36
func Get (name v1alpha1.ScannerName ) Scanner {
37
- if scanner , ok := scanners [name ]; ok {
37
+ if scanner , ok := scanners [name . Normalize () ]; ok {
38
38
return scanner
39
39
}
40
40
return nil
You can’t perform that action at this time.
0 commit comments