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"
)
@@ -10,7 +11,7 @@ func NewRelicUserID() *config.Rule {
r := config.Rule{
RuleID: "new-relic-user-api-key",
Description: "Discovered a New Relic user API Key, which could lead to compromised application insights and performance monitoring.",
Regex: generateSemiGenericRegex([]string{
Regex: utils.GenerateSemiGenericRegex([]string{
"new-relic",
"newrelic",
"new_relic",
@@ -23,9 +24,9 @@ func NewRelicUserID() *config.Rule {
// validate
tps := []string{
generateSampleSecret("new-relic", "NRAK-"+secrets.NewSecret(alphaNumeric("27"))),
utils.GenerateSampleSecret("new-relic", "NRAK-"+secrets.NewSecret(utils.AlphaNumeric("27"))),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
func NewRelicUserKey() *config.Rule {
@@ -33,11 +34,11 @@ func NewRelicUserKey() *config.Rule {
r := config.Rule{
RuleID: "new-relic-user-api-id",
Description: "Found a New Relic user API ID, posing a risk to application monitoring services and data integrity.",
Regex: generateSemiGenericRegex([]string{
Regex: utils.GenerateSemiGenericRegex([]string{
"new-relic",
"newrelic",
"new_relic",
}, alphaNumeric("64"), true),
}, utils.AlphaNumeric("64"), true),
Keywords: []string{
"new-relic",
@@ -48,9 +49,9 @@ func NewRelicUserKey() *config.Rule {
// validate
tps := []string{
generateSampleSecret("new-relic", secrets.NewSecret(alphaNumeric("64"))),
utils.GenerateSampleSecret("new-relic", secrets.NewSecret(utils.AlphaNumeric("64"))),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
func NewRelicBrowserAPIKey() *config.Rule {
@@ -58,7 +59,7 @@ func NewRelicBrowserAPIKey() *config.Rule {
r := config.Rule{
RuleID: "new-relic-browser-api-token",
Description: "Identified a New Relic ingest browser API token, risking unauthorized access to application performance data and analytics.",
Regex: generateSemiGenericRegex([]string{
Regex: utils.GenerateSemiGenericRegex([]string{
"new-relic",
"newrelic",
"new_relic",
@@ -71,9 +72,9 @@ func NewRelicBrowserAPIKey() *config.Rule {
// validate
tps := []string{
generateSampleSecret("new-relic", "NRJS-"+secrets.NewSecret(hex("19"))),
utils.GenerateSampleSecret("new-relic", "NRJS-"+secrets.NewSecret(utils.Hex("19"))),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
func NewRelicInsertKey() *config.Rule {
@@ -81,7 +82,7 @@ func NewRelicInsertKey() *config.Rule {
r := config.Rule{
RuleID: "new-relic-insert-key",
Description: "Discovered a New Relic insight insert key, compromising data injection into the platform.",
Regex: generateSemiGenericRegex([]string{
Regex: utils.GenerateSemiGenericRegex([]string{
"new-relic",
"newrelic",
"new_relic",
@@ -94,7 +95,7 @@ func NewRelicInsertKey() *config.Rule {
// validate
tps := []string{
generateSampleSecret("new-relic", "NRII-"+secrets.NewSecret(hex("32"))),
utils.GenerateSampleSecret("new-relic", "NRII-"+secrets.NewSecret(utils.Hex("32"))),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}