Make config generation utils public (#1480)

* chore(generate): make utils public

* chore(generate): change validate log messages

* chore(generate): split functions into files

* chore(config): add warning for public funcs
This commit is contained in:
Richard Gomez authored and GitHub committed 2024-08-26 13:11:18 -05:00
1 parent 3be7faa1ff
commit bd81872eee
114 files changed
+862 -713

No files matched your search

+14 -13
View File
@@ -1,6 +1,7 @@
package rules
import (
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)
@@ -11,17 +12,17 @@ func GrafanaApiKey() *config.Rule {
Description: "Identified a Grafana API key, which could compromise monitoring dashboards and sensitive data analytics.",
RuleID: "grafana-api-key",
Regex: generateUniqueTokenRegex(`eyJrIjoi[A-Za-z0-9]{70,400}={0,2}`, true),
Regex: utils.GenerateUniqueTokenRegex(`eyJrIjoi[A-Za-z0-9]{70,400}={0,2}`, true),
Keywords: []string{"eyJrIjoi"},
}
// validate
tps := []string{
generateSampleSecret("grafana-api-key",
utils.GenerateSampleSecret("grafana-api-key",
"eyJrIjoi"+
secrets.NewSecret(alphaNumeric("70"))),
secrets.NewSecret(utils.AlphaNumeric("70"))),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
func GrafanaCloudApiToken() *config.Rule {
@@ -30,17 +31,17 @@ func GrafanaCloudApiToken() *config.Rule {
Description: "Found a Grafana cloud API token, risking unauthorized access to cloud-based monitoring services and data exposure.",
RuleID: "grafana-cloud-api-token",
Regex: generateUniqueTokenRegex(`glc_[A-Za-z0-9+/]{32,400}={0,2}`, true),
Regex: utils.GenerateUniqueTokenRegex(`glc_[A-Za-z0-9+/]{32,400}={0,2}`, true),
Keywords: []string{"glc_"},
}
// validate
tps := []string{
generateSampleSecret("grafana-cloud-api-token",
utils.GenerateSampleSecret("grafana-cloud-api-token",
"glc_"+
secrets.NewSecret(alphaNumeric("32"))),
secrets.NewSecret(utils.AlphaNumeric("32"))),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
func GrafanaServiceAccountToken() *config.Rule {
@@ -49,17 +50,17 @@ func GrafanaServiceAccountToken() *config.Rule {
Description: "Discovered a Grafana service account token, posing a risk of compromised monitoring services and data integrity.",
RuleID: "grafana-service-account-token",
Regex: generateUniqueTokenRegex(`glsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8}`, true),
Regex: utils.GenerateUniqueTokenRegex(`glsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8}`, true),
Keywords: []string{"glsa_"},
}
// validate
tps := []string{
generateSampleSecret("grafana-service-account-token",
utils.GenerateSampleSecret("grafana-service-account-token",
"glsa_"+
secrets.NewSecret(alphaNumeric("32"))+
secrets.NewSecret(utils.AlphaNumeric("32"))+
"_"+
secrets.NewSecret((hex("8")))),
secrets.NewSecret((utils.Hex("8")))),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}