mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 21:24:21 +01:00
fix(kubernetes): remove slow element from pat (#1848)
This commit is contained in:
1 parent
88f56d3695
commit
6f967cad68
2 files changed
+5
-5
No files matched your search
@@ -17,7 +17,7 @@ func KubernetesSecret() *config.Rule {
|
|||||||
// - valid base64 characters
|
// - valid base64 characters
|
||||||
// - longer than 10 characters (no "YmFyCg==")
|
// - longer than 10 characters (no "YmFyCg==")
|
||||||
//language=regexp
|
//language=regexp
|
||||||
dataPat := `\bdata:(?:.|\s){0,100}?\s+([\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:["']?[a-z0-9+/]{10,}={0,3}["']?|\{\{[ \t\w"|$:=,.-]+}}|""|''))`
|
dataPat := `\bdata:(?s:.){0,100}?\s+([\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:["']?[a-z0-9+/]{10,}={0,3}["']?|\{\{[ \t\w"|$:=,.-]+}}|""|''))`
|
||||||
|
|
||||||
// define rule
|
// define rule
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
@@ -25,7 +25,7 @@ func KubernetesSecret() *config.Rule {
|
|||||||
Description: "Possible Kubernetes Secret detected, posing a risk of leaking credentials/tokens from your deployments",
|
Description: "Possible Kubernetes Secret detected, posing a risk of leaking credentials/tokens from your deployments",
|
||||||
Regex: regexp.MustCompile(fmt.Sprintf(
|
Regex: regexp.MustCompile(fmt.Sprintf(
|
||||||
//language=regexp
|
//language=regexp
|
||||||
`(?i)(?:%s(?:.|\s){0,200}?%s|%s(?:.|\s){0,200}?%s)`, kindPat, dataPat, dataPat, kindPat)),
|
`(?i)(?:%s(?s:.){0,200}?%s|%s(?s:.){0,200}?%s)`, kindPat, dataPat, dataPat, kindPat)),
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"secret",
|
"secret",
|
||||||
},
|
},
|
||||||
@@ -45,7 +45,7 @@ func KubernetesSecret() *config.Rule {
|
|||||||
// Avoid overreach between directives.
|
// Avoid overreach between directives.
|
||||||
RegexTarget: "match",
|
RegexTarget: "match",
|
||||||
Regexes: []*regexp.Regexp{
|
Regexes: []*regexp.Regexp{
|
||||||
regexp.MustCompile(`(kind:(?:.|\s)+\n---\n(?:.|\s)+\bdata:|data:(?:.|\s)+\n---\n(?:.|\s)+\bkind:)`),
|
regexp.MustCompile(`(kind:(?s:.)+\n---\n(?s:.)+\bdata:|data:(?s:.)+\n---\n(?s:.)+\bkind:)`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2384,7 +2384,7 @@ keywords = ["kraken"]
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
id = "kubernetes-secret-yaml"
|
id = "kubernetes-secret-yaml"
|
||||||
description = "Possible Kubernetes Secret detected, posing a risk of leaking credentials/tokens from your deployments"
|
description = "Possible Kubernetes Secret detected, posing a risk of leaking credentials/tokens from your deployments"
|
||||||
regex = '''(?i)(?:\bkind:[ \t]*["']?\bsecret\b["']?(?:.|\s){0,200}?\bdata:(?:.|\s){0,100}?\s+([\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:["']?[a-z0-9+/]{10,}={0,3}["']?|\{\{[ \t\w"|$:=,.-]+}}|""|''))|\bdata:(?:.|\s){0,100}?\s+([\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:["']?[a-z0-9+/]{10,}={0,3}["']?|\{\{[ \t\w"|$:=,.-]+}}|""|''))(?:.|\s){0,200}?\bkind:[ \t]*["']?\bsecret\b["']?)'''
|
regex = '''(?i)(?:\bkind:[ \t]*["']?\bsecret\b["']?(?s:.){0,200}?\bdata:(?s:.){0,100}?\s+([\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:["']?[a-z0-9+/]{10,}={0,3}["']?|\{\{[ \t\w"|$:=,.-]+}}|""|''))|\bdata:(?s:.){0,100}?\s+([\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:["']?[a-z0-9+/]{10,}={0,3}["']?|\{\{[ \t\w"|$:=,.-]+}}|""|''))(?s:.){0,200}?\bkind:[ \t]*["']?\bsecret\b["']?)'''
|
||||||
path = '''(?i)\.ya?ml$'''
|
path = '''(?i)\.ya?ml$'''
|
||||||
keywords = ["secret"]
|
keywords = ["secret"]
|
||||||
[[rules.allowlists]]
|
[[rules.allowlists]]
|
||||||
@@ -2394,7 +2394,7 @@ regexes = [
|
|||||||
[[rules.allowlists]]
|
[[rules.allowlists]]
|
||||||
regexTarget = "match"
|
regexTarget = "match"
|
||||||
regexes = [
|
regexes = [
|
||||||
'''(kind:(?:.|\s)+\n---\n(?:.|\s)+\bdata:|data:(?:.|\s)+\n---\n(?:.|\s)+\bkind:)''',
|
'''(kind:(?s:.)+\n---\n(?s:.)+\bdata:|data:(?s:.)+\n---\n(?s:.)+\bkind:)''',
|
||||||
]
|
]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
|
|||||||
Reference in new issue
Block a user