mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-02 05:54:21 +01:00
feat(gcp): update api key rule (#1481)
This commit is contained in:
1 parent
75dd70e59a
commit
df126a7473
2 files changed
+14
-5
No files matched your search
@@ -30,8 +30,8 @@ func GCPAPIKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "gcp-api-key",
|
RuleID: "gcp-api-key",
|
||||||
Description: "Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches.",
|
Description: "Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches.",
|
||||||
Regex: utils.GenerateUniqueTokenRegex(`AIza[0-9A-Za-z\\-_]{35}`, true),
|
Regex: utils.GenerateUniqueTokenRegex(`AIza[\w-]{35}`, false),
|
||||||
|
Entropy: 3.0,
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"AIza",
|
"AIza",
|
||||||
},
|
},
|
||||||
@@ -39,7 +39,15 @@ func GCPAPIKey() *config.Rule {
|
|||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := []string{
|
||||||
utils.GenerateSampleSecret("gcp", secrets.NewSecret(`AIza[0-9A-Za-z\\-_]{35}`)),
|
utils.GenerateSampleSecret("gcp", secrets.NewSecret(`AIza[\w-]{35}`)),
|
||||||
|
// non-word character at end
|
||||||
|
`AIzaSyNHxIf32IQ1a1yjl3ZJIqKZqzLAK1XhDk-`, // gitleaks:allow
|
||||||
}
|
}
|
||||||
return utils.Validate(r, tps, nil)
|
fps := []string{
|
||||||
|
`GWw4hjABFzZCGiRpmlDyDdo87Jn9BN9THUA47muVRNunLxsa82tMAdvmrhOqNkRKiYMEAFbTJAIzaTesb6Tscfcni8vIpWZqNCXFDFslJtVSvFDq`, // text boundary start
|
||||||
|
`AIzaTesb6Tscfcni8vIpWZqNCXFDFslJtVSvFDqabcd123`, // text boundary end
|
||||||
|
`apiKey: "AIzaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"`, // not enough entropy
|
||||||
|
`AIZASYCO2CXRMC9ELSKLHLHRMBSWDEVEDZTLO2O`, // incorrect case
|
||||||
|
}
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
@@ -499,7 +499,8 @@ keywords = [
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
id = "gcp-api-key"
|
id = "gcp-api-key"
|
||||||
description = "Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches."
|
description = "Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches."
|
||||||
regex = '''(?i)\b(AIza[0-9A-Za-z\\-_]{35})(?:['|\"|\n|\r|\s|\x60|;]|$)'''
|
regex = '''\b(AIza[\w-]{35})(?:['|\"|\n|\r|\s|\x60|;]|$)'''
|
||||||
|
entropy = 3
|
||||||
keywords = [
|
keywords = [
|
||||||
"aiza",
|
"aiza",
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in new issue
Block a user