mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 20:24:22 +01:00
Adds detection support for Defined Networking tokens (https://docs.defined.net/guides/automating-host-creation/) I added a fixture in addition to the generator, I think I may be able to use the `generateUniqueToken` instead of the semi-generic option? Let me know if I should update accordingly. Remove testing fixture
33 lines
943 B
Go
33 lines
943 B
Go
package rules
|
|
|
|
import (
|
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
|
"github.com/zricethezav/gitleaks/v8/config"
|
|
)
|
|
|
|
func DefinedNetworkingAPIToken() *config.Rule {
|
|
// Define Rule
|
|
r := config.Rule{
|
|
// Human redable description of the rule
|
|
Description: "Defined Networking API token",
|
|
|
|
// Unique ID for the rule
|
|
RuleID: "defined-networking-api-token",
|
|
|
|
// Regex capture group for the actual secret
|
|
SecretGroup: 1,
|
|
|
|
// Regex used for detecting secrets. See regex section below for more details
|
|
Regex: generateSemiGenericRegex([]string{"dnkey"}, `dnkey-[a-z0-9=_\-]{26}-[a-z0-9=_\-]{52}`),
|
|
|
|
// Keywords used for string matching on fragments (think of this as a prefilter)
|
|
Keywords: []string{"dnkey"},
|
|
}
|
|
|
|
// validate
|
|
tps := []string{
|
|
generateSampleSecret("dnkey", "dnkey-"+secrets.NewSecret(alphaNumericExtended("26"))+"-"+secrets.NewSecret(alphaNumericExtended("52"))),
|
|
}
|
|
return validate(r, tps, nil)
|
|
}
|