mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 20:54:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dab7d0292a | ||
|
|
e63b657bcf | ||
|
|
20fcf5009f | ||
|
|
b49667786e | ||
|
|
a3ab4e8ac5 | ||
|
|
bd9a25a379 | ||
|
|
6d0d8b5068 | ||
|
|
2959fc072c | ||
|
|
d37b38f2ee | ||
|
|
14b1ca9fd9 | ||
|
|
d9f86d6123 | ||
|
|
ed34259e9c | ||
|
|
0d5e46fecb | ||
|
|
a82ac29976 | ||
|
|
0b84afa0fa | ||
|
|
8976539177 | ||
|
|
30c6117aaa | ||
|
|
e9135cf0b5 | ||
|
|
f65f9157ff | ||
|
|
abfd0f3fdc | ||
|
|
18283bb48e | ||
|
|
9fb36b242d | ||
|
|
db4bc0fe76 | ||
|
|
3cbcda20d2 | ||
|
|
46c627212c | ||
|
|
963a6976d1 | ||
|
|
163ec21120 | ||
|
|
45266551ba | ||
|
|
b1a2ce7296 | ||
|
|
34e67229e6 | ||
|
|
61513d6772 | ||
|
|
f0dcd4d9cf | ||
|
|
06db3b91d7 |
No files matched your search
+6
-6
@@ -35,11 +35,11 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi
|
|||||||
RuleID: "beamer-api-token",
|
RuleID: "beamer-api-token",
|
||||||
|
|
||||||
// Regex capture group for the actual secret
|
// Regex capture group for the actual secret
|
||||||
SecretGroup: 1,
|
|
||||||
|
|
||||||
|
|
||||||
// Regex used for detecting secrets. See regex section below for more details
|
// Regex used for detecting secrets. See regex section below for more details
|
||||||
Regex: generateSemiGenericRegex([]string{"beamer"}, `b_[a-z0-9=_\-]{44}`),
|
Regex: generateSemiGenericRegex([]string{"beamer"}, `b_[a-z0-9=_\-]{44}`, true)
|
||||||
|
|
||||||
// Keywords used for string matching on fragments (think of this as a prefilter)
|
// Keywords used for string matching on fragments (think of this as a prefilter)
|
||||||
Keywords: []string{"beamer"},
|
Keywords: []string{"beamer"},
|
||||||
@@ -63,18 +63,18 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi
|
|||||||
The function signatures look like this:
|
The function signatures look like this:
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
func generateSemiGenericRegex(identifiers []string, secretRegex string) *regexp.Regexp
|
func generateSemiGenericRegex(identifiers []string, secretRegex string, isCaseInsensitive bool) *regexp.Regexp
|
||||||
|
|
||||||
func generateUniqueTokenRegex(secretRegex string) *regexp.Regexp
|
func generateUniqueTokenRegex(secretRegex string, isCaseInsensitive bool) *regexp.Regexp
|
||||||
```
|
```
|
||||||
|
|
||||||
`generateSemiGenericRegex` accepts a list of identifiers and a regex.
|
`generateSemiGenericRegex` accepts a list of identifiers, a regex, and a boolean indicating whether the pattern should be case-insensitive.
|
||||||
The list of identifiers _should_ match the list of `Keywords` in the rule
|
The list of identifiers _should_ match the list of `Keywords` in the rule
|
||||||
definition above. Both `identifiers` in the `generateSemiGenericRegex`
|
definition above. Both `identifiers` in the `generateSemiGenericRegex`
|
||||||
function _and_ `Keywords` act as filters for Gitleaks telling the program
|
function _and_ `Keywords` act as filters for Gitleaks telling the program
|
||||||
"_at least one of these strings must be present to be considered a leak_"
|
"_at least one of these strings must be present to be considered a leak_"
|
||||||
|
|
||||||
`generateUniqueToken` just accepts a regex. If you are writing a rule for a
|
`generateUniqueToken` just accepts a regex and a boolean indicating whether the pattern should be case-insensitive. If you are writing a rule for a
|
||||||
token that is unique enough not to require an identifier then you can use
|
token that is unique enough not to require an identifier then you can use
|
||||||
this function. For example, Pulumi's API Token has the prefix `pul-` which is
|
this function. For example, Pulumi's API Token has the prefix `pul-` which is
|
||||||
unique enough to use `generateUniqueToken`. But something like Beamer's API
|
unique enough to use `generateUniqueToken`. But something like Beamer's API
|
||||||
|
|||||||
@@ -13,11 +13,9 @@ format:
|
|||||||
go fmt ./...
|
go fmt ./...
|
||||||
|
|
||||||
test: format
|
test: format
|
||||||
go vet ./...
|
|
||||||
go test -v ./... --race $(PKG)
|
go test -v ./... --race $(PKG)
|
||||||
|
|
||||||
build: format
|
build: format
|
||||||
go vet ./...
|
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go build $(LDFLAGS)
|
go build $(LDFLAGS)
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
### Join our Discord! [](https://discord.gg/sydS6AHTUP)
|
### Join our Discord! [](https://discord.gg/8Hzbrnkr7E)
|
||||||
|
|
||||||
Gitleaks is a SAST tool for **detecting** and **preventing** hardcoded secrets like passwords, api keys, and tokens in git repos. Gitleaks is an **easy-to-use, all-in-one solution** for detecting secrets, past or present, in your code.
|
Gitleaks is a SAST tool for **detecting** and **preventing** hardcoded secrets like passwords, api keys, and tokens in git repos. Gitleaks is an **easy-to-use, all-in-one solution** for detecting secrets, past or present, in your code.
|
||||||
|
|
||||||
@@ -182,6 +182,8 @@ See the `git log` [documentation](https://git-scm.com/docs/git-log) for more inf
|
|||||||
|
|
||||||
You can scan files and directories by using the `--no-git` option.
|
You can scan files and directories by using the `--no-git` option.
|
||||||
|
|
||||||
|
If you want to run only specific rules you can do so by using the `--enable-rule` option (with a rule ID as a parameter), this flag can be used multiple times. For example: `--enable-rule=atlassian-api-token` will only apply that rule. You can find a list of rules [here](config/gitleaks.toml).
|
||||||
|
|
||||||
#### Protect
|
#### Protect
|
||||||
|
|
||||||
The `protect` command is used to scan uncommitted changes in a git repo. This command should be used on developer machines in accordance with
|
The `protect` command is used to scan uncommitted changes in a git repo. This command should be used on developer machines in accordance with
|
||||||
|
|||||||
+32
-3
@@ -3,8 +3,10 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
@@ -20,6 +22,7 @@ func init() {
|
|||||||
detectCmd.Flags().Bool("no-git", false, "treat git repo as a regular directory and scan those files, --log-opts has no effect on the scan when --no-git is set")
|
detectCmd.Flags().Bool("no-git", false, "treat git repo as a regular directory and scan those files, --log-opts has no effect on the scan when --no-git is set")
|
||||||
detectCmd.Flags().Bool("pipe", false, "scan input from stdin, ex: `cat some_file | gitleaks detect --pipe`")
|
detectCmd.Flags().Bool("pipe", false, "scan input from stdin, ex: `cat some_file | gitleaks detect --pipe`")
|
||||||
detectCmd.Flags().Bool("follow-symlinks", false, "scan files that are symlinks to other files")
|
detectCmd.Flags().Bool("follow-symlinks", false, "scan files that are symlinks to other files")
|
||||||
|
detectCmd.Flags().StringSlice("enable-rule", []string{}, "only enable specific rules by id, ex: `gitleaks detect --enable-rule=atlassian-api-token --enable-rule=slack-access-token`")
|
||||||
detectCmd.Flags().StringP("gitleaks-ignore-path", "i", ".", "path to .gitleaksignore file or folder containing one")
|
detectCmd.Flags().StringP("gitleaks-ignore-path", "i", ".", "path to .gitleaksignore file or folder containing one")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +55,17 @@ func runDetect(cmd *cobra.Command, args []string) {
|
|||||||
|
|
||||||
// Setup detector
|
// Setup detector
|
||||||
detector := detect.NewDetector(cfg)
|
detector := detect.NewDetector(cfg)
|
||||||
|
// set color flag at first
|
||||||
|
if detector.NoColor, err = cmd.Flags().GetBool("no-color"); err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("")
|
||||||
|
}
|
||||||
|
// also init logger again without color
|
||||||
|
if detector.NoColor {
|
||||||
|
log.Logger = log.Output(zerolog.ConsoleWriter{
|
||||||
|
Out: os.Stderr,
|
||||||
|
NoColor: detector.NoColor,
|
||||||
|
})
|
||||||
|
}
|
||||||
detector.Config.Path, err = cmd.Flags().GetString("config")
|
detector.Config.Path, err = cmd.Flags().GetString("config")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("")
|
log.Fatal().Err(err).Msg("")
|
||||||
@@ -70,14 +84,14 @@ func runDetect(cmd *cobra.Command, args []string) {
|
|||||||
log.Fatal().Err(err).Msg("")
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
// set redact flag
|
// set redact flag
|
||||||
if detector.Redact, err = cmd.Flags().GetBool("redact"); err != nil {
|
if detector.Redact, err = cmd.Flags().GetUint("redact"); err != nil {
|
||||||
log.Fatal().Err(err).Msg("")
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
if detector.MaxTargetMegaBytes, err = cmd.Flags().GetInt("max-target-megabytes"); err != nil {
|
if detector.MaxTargetMegaBytes, err = cmd.Flags().GetInt("max-target-megabytes"); err != nil {
|
||||||
log.Fatal().Err(err).Msg("")
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
// set color flag
|
// set ignore gitleaks:allow flag
|
||||||
if detector.NoColor, err = cmd.Flags().GetBool("no-color"); err != nil {
|
if detector.IgnoreGitleaksAllow, err = cmd.Flags().GetBool("ignore-gitleaks-allow"); err != nil {
|
||||||
log.Fatal().Err(err).Msg("")
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +127,21 @@ func runDetect(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If set, only apply rules that are defined in the flag
|
||||||
|
rules, _ := cmd.Flags().GetStringSlice("enable-rule")
|
||||||
|
if len(rules) > 0 {
|
||||||
|
log.Info().Msg("Overriding enabled rules: " + strings.Join(rules, ", "))
|
||||||
|
ruleOverride := make(map[string]config.Rule)
|
||||||
|
for _, ruleName := range rules {
|
||||||
|
if rule, ok := cfg.Rules[ruleName]; ok {
|
||||||
|
ruleOverride[ruleName] = rule
|
||||||
|
} else {
|
||||||
|
log.Fatal().Msgf("Requested rule %s not found in rules", ruleName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
detector.Config.Rules = ruleOverride
|
||||||
|
}
|
||||||
|
|
||||||
// set follow symlinks flag
|
// set follow symlinks flag
|
||||||
if detector.FollowSymlinks, err = cmd.Flags().GetBool("follow-symlinks"); err != nil {
|
if detector.FollowSymlinks, err = cmd.Flags().GetBool("follow-symlinks"); err != nil {
|
||||||
log.Fatal().Err(err).Msg("")
|
log.Fatal().Err(err).Msg("")
|
||||||
|
|||||||
@@ -87,10 +87,16 @@ func main() {
|
|||||||
configRules = append(configRules, rules.GrafanaCloudApiToken())
|
configRules = append(configRules, rules.GrafanaCloudApiToken())
|
||||||
configRules = append(configRules, rules.GrafanaServiceAccountToken())
|
configRules = append(configRules, rules.GrafanaServiceAccountToken())
|
||||||
configRules = append(configRules, rules.Hashicorp())
|
configRules = append(configRules, rules.Hashicorp())
|
||||||
|
configRules = append(configRules, rules.HashicorpField())
|
||||||
configRules = append(configRules, rules.Heroku())
|
configRules = append(configRules, rules.Heroku())
|
||||||
configRules = append(configRules, rules.HubSpot())
|
configRules = append(configRules, rules.HubSpot())
|
||||||
|
configRules = append(configRules, rules.HuggingFaceAccessToken())
|
||||||
|
configRules = append(configRules, rules.HuggingFaceOrganizationApiToken())
|
||||||
configRules = append(configRules, rules.Intercom())
|
configRules = append(configRules, rules.Intercom())
|
||||||
|
configRules = append(configRules, rules.JFrogAPIKey())
|
||||||
|
configRules = append(configRules, rules.JFrogIdentityToken())
|
||||||
configRules = append(configRules, rules.JWT())
|
configRules = append(configRules, rules.JWT())
|
||||||
|
configRules = append(configRules, rules.JWTBase64())
|
||||||
configRules = append(configRules, rules.KrakenAccessToken())
|
configRules = append(configRules, rules.KrakenAccessToken())
|
||||||
configRules = append(configRules, rules.KucoinAccessToken())
|
configRules = append(configRules, rules.KucoinAccessToken())
|
||||||
configRules = append(configRules, rules.KucoinSecretKey())
|
configRules = append(configRules, rules.KucoinSecretKey())
|
||||||
@@ -131,6 +137,7 @@ func main() {
|
|||||||
configRules = append(configRules, rules.RapidAPIAccessToken())
|
configRules = append(configRules, rules.RapidAPIAccessToken())
|
||||||
configRules = append(configRules, rules.ReadMe())
|
configRules = append(configRules, rules.ReadMe())
|
||||||
configRules = append(configRules, rules.RubyGemsAPIToken())
|
configRules = append(configRules, rules.RubyGemsAPIToken())
|
||||||
|
configRules = append(configRules, rules.ScalingoAPIToken())
|
||||||
configRules = append(configRules, rules.SendbirdAccessID())
|
configRules = append(configRules, rules.SendbirdAccessID())
|
||||||
configRules = append(configRules, rules.SendbirdAccessToken())
|
configRules = append(configRules, rules.SendbirdAccessToken())
|
||||||
configRules = append(configRules, rules.SendGridAPIToken())
|
configRules = append(configRules, rules.SendGridAPIToken())
|
||||||
@@ -176,6 +183,7 @@ func main() {
|
|||||||
configRules = append(configRules, rules.YandexAccessToken())
|
configRules = append(configRules, rules.YandexAccessToken())
|
||||||
configRules = append(configRules, rules.ZendeskSecretKey())
|
configRules = append(configRules, rules.ZendeskSecretKey())
|
||||||
configRules = append(configRules, rules.GenericCredential())
|
configRules = append(configRules, rules.GenericCredential())
|
||||||
|
configRules = append(configRules, rules.InfracostAPIToken())
|
||||||
|
|
||||||
// ensure rules have unique ids
|
// ensure rules have unique ids
|
||||||
ruleLookUp := make(map[string]config.Rule)
|
ruleLookUp := make(map[string]config.Rule)
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ func AdafruitAPIKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Adafruit API Key",
|
Description: "Adafruit API Key",
|
||||||
RuleID: "adafruit-api-key",
|
RuleID: "adafruit-api-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"adafruit"}, alphaNumericExtendedShort("32")),
|
Regex: generateSemiGenericRegex([]string{"adafruit"}, alphaNumericExtendedShort("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"adafruit"},
|
Keywords: []string{"adafruit"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ func AdobeClientID() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Adobe Client ID (OAuth Web)",
|
Description: "Adobe Client ID (OAuth Web)",
|
||||||
RuleID: "adobe-client-id",
|
RuleID: "adobe-client-id",
|
||||||
Regex: generateSemiGenericRegex([]string{"adobe"}, hex("32")),
|
Regex: generateSemiGenericRegex([]string{"adobe"}, hex("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"adobe"},
|
Keywords: []string{"adobe"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@ func AdobeClientSecret() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Adobe Client Secret",
|
Description: "Adobe Client Secret",
|
||||||
RuleID: "adobe-client-secret",
|
RuleID: "adobe-client-secret",
|
||||||
Regex: generateUniqueTokenRegex(`(p8e-)(?i)[a-z0-9]{32}`),
|
Regex: generateUniqueTokenRegex(`(p8e-)(?i)[a-z0-9]{32}`, true),
|
||||||
Keywords: []string{"p8e-"},
|
Keywords: []string{"p8e-"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ func Airtable() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Airtable API Key",
|
Description: "Airtable API Key",
|
||||||
RuleID: "airtable-api-key",
|
RuleID: "airtable-api-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"airtable"}, alphaNumeric("17")),
|
Regex: generateSemiGenericRegex([]string{"airtable"}, alphaNumeric("17"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"airtable"},
|
Keywords: []string{"airtable"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ func AlgoliaApiKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Algolia API Key",
|
Description: "Algolia API Key",
|
||||||
RuleID: "algolia-api-key",
|
RuleID: "algolia-api-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"algolia"}, `[a-z0-9]{32}`),
|
Regex: generateSemiGenericRegex([]string{"algolia"}, `[a-z0-9]{32}`, true),
|
||||||
Keywords: []string{"algolia"},
|
Keywords: []string{"algolia"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ func AlibabaAccessKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Alibaba AccessKey ID",
|
Description: "Alibaba AccessKey ID",
|
||||||
RuleID: "alibaba-access-key-id",
|
RuleID: "alibaba-access-key-id",
|
||||||
Regex: generateUniqueTokenRegex(`(LTAI)(?i)[a-z0-9]{20}`),
|
Regex: generateUniqueTokenRegex(`(LTAI)(?i)[a-z0-9]{20}`, true),
|
||||||
Keywords: []string{"LTAI"},
|
Keywords: []string{"LTAI"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,9 +28,9 @@ func AlibabaSecretKey() *config.Rule {
|
|||||||
Description: "Alibaba Secret Key",
|
Description: "Alibaba Secret Key",
|
||||||
RuleID: "alibaba-secret-key",
|
RuleID: "alibaba-secret-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"alibaba"},
|
Regex: generateSemiGenericRegex([]string{"alibaba"},
|
||||||
alphaNumeric("30")),
|
alphaNumeric("30"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"alibaba"},
|
Keywords: []string{"alibaba"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ func AsanaClientID() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Asana Client ID",
|
Description: "Asana Client ID",
|
||||||
RuleID: "asana-client-id",
|
RuleID: "asana-client-id",
|
||||||
Regex: generateSemiGenericRegex([]string{"asana"}, numeric("16")),
|
Regex: generateSemiGenericRegex([]string{"asana"}, numeric("16"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"asana"},
|
Keywords: []string{"asana"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,9 +26,9 @@ func AsanaClientSecret() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Asana Client Secret",
|
Description: "Asana Client Secret",
|
||||||
RuleID: "asana-client-secret",
|
RuleID: "asana-client-secret",
|
||||||
Regex: generateSemiGenericRegex([]string{"asana"}, alphaNumeric("32")),
|
Regex: generateSemiGenericRegex([]string{"asana"}, alphaNumeric("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"asana"},
|
Keywords: []string{"asana"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ func Atlassian() *config.Rule {
|
|||||||
Description: "Atlassian API token",
|
Description: "Atlassian API token",
|
||||||
RuleID: "atlassian-api-token",
|
RuleID: "atlassian-api-token",
|
||||||
Regex: generateSemiGenericRegex([]string{
|
Regex: generateSemiGenericRegex([]string{
|
||||||
"atlassian", "confluence", "jira"}, alphaNumeric("24")),
|
"atlassian", "confluence", "jira"}, alphaNumeric("24"), true),
|
||||||
SecretGroup: 1,
|
Keywords: []string{"atlassian", "confluence", "jira"},
|
||||||
Keywords: []string{"atlassian", "confluence", "jira"},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Authress() *config.Rule {
|
func Authress() *config.Rule {
|
||||||
// define rule
|
// Rule Definition
|
||||||
|
// (Note: When changes are made to this, rerun `cd cmd/generate/config && go run main.go` and commit the config/gitleaks.toml file
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Authress Service Client Access Key",
|
Description: "Authress Service Client Access Key",
|
||||||
RuleID: "authress-service-client-access-key",
|
RuleID: "authress-service-client-access-key",
|
||||||
SecretGroup: 1,
|
Regex: generateUniqueTokenRegex(`(?:sc|ext|scauth|authress)_[a-z0-9]{5,30}\.[a-z0-9]{4,6}\.acc[_-][a-z0-9-]{10,32}\.[a-z0-9+/_=-]{30,120}`, true),
|
||||||
Regex: generateUniqueTokenRegex(`(?:sc|ext|scauth|authress)_[a-z0-9]{5,30}\.[a-z0-9]{4,6}\.acc_[a-z0-9-]{10,32}\.[a-z0-9+/_=-]{30,120}`),
|
|
||||||
Keywords: []string{"sc_", "ext_", "scauth_", "authress_"},
|
Keywords: []string{"sc_", "ext_", "scauth_", "authress_"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func AWS() *config.Rule {
|
|||||||
Description: "AWS",
|
Description: "AWS",
|
||||||
RuleID: "aws-access-token",
|
RuleID: "aws-access-token",
|
||||||
Regex: regexp.MustCompile(
|
Regex: regexp.MustCompile(
|
||||||
"(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
|
"(?:A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"AKIA",
|
"AKIA",
|
||||||
"AGPA",
|
"AGPA",
|
||||||
|
|||||||
@@ -10,9 +10,8 @@ func Beamer() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Beamer API token",
|
Description: "Beamer API token",
|
||||||
RuleID: "beamer-api-token",
|
RuleID: "beamer-api-token",
|
||||||
SecretGroup: 1,
|
|
||||||
Regex: generateSemiGenericRegex([]string{"beamer"},
|
Regex: generateSemiGenericRegex([]string{"beamer"},
|
||||||
`b_[a-z0-9=_\-]{44}`),
|
`b_[a-z0-9=_\-]{44}`, true),
|
||||||
Keywords: []string{"beamer"},
|
Keywords: []string{"beamer"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ func BitBucketClientID() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Bitbucket Client ID",
|
Description: "Bitbucket Client ID",
|
||||||
RuleID: "bitbucket-client-id",
|
RuleID: "bitbucket-client-id",
|
||||||
Regex: generateSemiGenericRegex([]string{"bitbucket"}, alphaNumeric("32")),
|
Regex: generateSemiGenericRegex([]string{"bitbucket"}, alphaNumeric("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"bitbucket"},
|
Keywords: []string{"bitbucket"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,9 +26,9 @@ func BitBucketClientSecret() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Bitbucket Client Secret",
|
Description: "Bitbucket Client Secret",
|
||||||
RuleID: "bitbucket-client-secret",
|
RuleID: "bitbucket-client-secret",
|
||||||
Regex: generateSemiGenericRegex([]string{"bitbucket"}, alphaNumericExtended("64")),
|
Regex: generateSemiGenericRegex([]string{"bitbucket"}, alphaNumericExtended("64"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"bitbucket"},
|
Keywords: []string{"bitbucket"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ func BittrexAccessKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Bittrex Access Key",
|
Description: "Bittrex Access Key",
|
||||||
RuleID: "bittrex-access-key",
|
RuleID: "bittrex-access-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"bittrex"}, alphaNumeric("32")),
|
Regex: generateSemiGenericRegex([]string{"bittrex"}, alphaNumeric("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"bittrex"},
|
Keywords: []string{"bittrex"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,9 +26,9 @@ func BittrexSecretKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Bittrex Secret Key",
|
Description: "Bittrex Secret Key",
|
||||||
RuleID: "bittrex-secret-key",
|
RuleID: "bittrex-secret-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"bittrex"}, alphaNumeric("32")),
|
Regex: generateSemiGenericRegex([]string{"bittrex"}, alphaNumeric("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"bittrex"},
|
Keywords: []string{"bittrex"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ func CodecovAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "codecov-access-token",
|
RuleID: "codecov-access-token",
|
||||||
Description: "Codecov Access Token",
|
Description: "Codecov Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"codecov"}, alphaNumeric("32")),
|
Regex: generateSemiGenericRegex([]string{"codecov"}, alphaNumeric("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"codecov",
|
"codecov",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ func CoinbaseAccessToken() *config.Rule {
|
|||||||
RuleID: "coinbase-access-token",
|
RuleID: "coinbase-access-token",
|
||||||
Description: "Coinbase Access Token",
|
Description: "Coinbase Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"coinbase"},
|
Regex: generateSemiGenericRegex([]string{"coinbase"},
|
||||||
alphaNumericExtendedShort("64")),
|
alphaNumericExtendedShort("64"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"coinbase",
|
"coinbase",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,51 +14,51 @@ title = "gitleaks config"
|
|||||||
description = "global allow lists"
|
description = "global allow lists"
|
||||||
paths = [
|
paths = [
|
||||||
'''gitleaks.toml''',
|
'''gitleaks.toml''',
|
||||||
'''(.*?)(jpg|gif|doc|docx|zip|xls|pdf|bin|svg|socket)$''',
|
'''(.*?)(jpg|gif|doc|docx|zip|xls|pdf|bin|svg|socket|vsidx|v2|suo|wsuo|.dll|pdb|exe)$''',
|
||||||
'''(go.mod|go.sum)$''',
|
'''(go.mod|go.sum)$''',
|
||||||
'''gradle.lockfile''',
|
'''gradle.lockfile''',
|
||||||
'''node_modules''',
|
'''node_modules''',
|
||||||
'''package-lock.json''',
|
'''package-lock.json''',
|
||||||
|
'''yarn.lock''',
|
||||||
'''pnpm-lock.yaml''',
|
'''pnpm-lock.yaml''',
|
||||||
'''Database.refactorlog''',
|
'''Database.refactorlog''',
|
||||||
'''vendor''',
|
'''vendor''',
|
||||||
]
|
]
|
||||||
|
|
||||||
{{ range $i, $rule := .Rules }}[[rules]]
|
{{ range $i, $rule := .Rules }}[[rules]]
|
||||||
{{ if and $rule.SecretGroup $rule.Entropy $rule.Allowlist.StopWords }}description = "{{$rule.Description}}"
|
|
||||||
id = "{{$rule.RuleID}}"
|
id = "{{$rule.RuleID}}"
|
||||||
|
description = "{{$rule.Description}}"
|
||||||
regex = '''{{$rule.Regex}}'''
|
regex = '''{{$rule.Regex}}'''
|
||||||
secretGroup = {{ $rule.SecretGroup }}
|
{{- with $rule.Path }}
|
||||||
entropy = {{ $rule.Entropy}}
|
path = '''{{ . }}'''{{ end -}}
|
||||||
|
{{- with $rule.SecretGroup }}
|
||||||
|
secretGroup = {{ . }}{{ end -}}
|
||||||
|
{{- with $rule.Entropy }}
|
||||||
|
entropy = {{ . }}{{ end -}}
|
||||||
|
{{- with $rule.Keywords }}
|
||||||
keywords = [
|
keywords = [
|
||||||
{{ range $j, $keyword := $rule.Keywords }}"{{$keyword}}",{{end}}
|
{{ range $j, $keyword := . }}"{{ $keyword }}",{{ end }}
|
||||||
]
|
]{{ end }}
|
||||||
|
{{- with $rule.Tags }}
|
||||||
|
tags = [
|
||||||
|
{{ range $j, $tag := . }}"{{ $tag }}",{{ end }}
|
||||||
|
]{{ end }}
|
||||||
|
{{ if or $rule.Allowlist.Regexes $rule.Allowlist.Paths $rule.Allowlist.Commits $rule.Allowlist.StopWords }}
|
||||||
[rules.allowlist]
|
[rules.allowlist]
|
||||||
stopwords= [{{ range $j, $stopword := $rule.Allowlist.StopWords }}
|
{{ with $rule.Allowlist.RegexTarget }}
|
||||||
"{{$stopword}}",{{end}}
|
regexTarget = "{{ . }}"{{ end -}}
|
||||||
]
|
{{- with $rule.Allowlist.Regexes }}
|
||||||
{{ else if and $rule.SecretGroup $rule.Entropy }}description = "{{$rule.Description}}"
|
regexes = [
|
||||||
id = "{{$rule.RuleID}}"
|
{{ range $j, $regex := . }}"{{ $regex }}",{{ end }}
|
||||||
regex = '''{{$rule.Regex}}'''
|
]{{ end }}
|
||||||
secretGroup = {{ $rule.SecretGroup }}
|
{{- with $rule.Allowlist.Paths }}paths = [
|
||||||
entropy = {{ $rule.Entropy}}
|
{{ range $j, $path := . }}"{{ $path }}",{{ end }}
|
||||||
keywords = [
|
]{{ end }}
|
||||||
{{ range $j, $keyword := $rule.Keywords }}"{{$keyword}}",{{end}}
|
{{- with $rule.Allowlist.Commits }}commits = [
|
||||||
]
|
{{ range $j, $commit := . }}"{{ $commit }}",{{ end }}
|
||||||
|
]{{ end }}
|
||||||
{{ else if $rule.SecretGroup }}description = "{{$rule.Description}}"
|
{{- with $rule.Allowlist.StopWords }}stopwords = [{{ range $j, $stopword := . }}
|
||||||
id = "{{$rule.RuleID}}"
|
"{{ $stopword }}",{{ end }}
|
||||||
regex = '''{{$rule.Regex}}'''
|
]{{ end }}
|
||||||
secretGroup = {{ $rule.SecretGroup }}
|
{{ end }}
|
||||||
keywords = [
|
{{ end }}
|
||||||
{{ range $j, $keyword := $rule.Keywords }}"{{$keyword}}",{{end}}
|
|
||||||
]
|
|
||||||
|
|
||||||
{{ else }}description = "{{$rule.Description}}"
|
|
||||||
id = "{{$rule.RuleID}}"
|
|
||||||
regex = '''{{$rule.Regex}}'''
|
|
||||||
keywords = [
|
|
||||||
{{ range $j, $keyword := $rule.Keywords }}"{{$keyword}}",{{end}}
|
|
||||||
]
|
|
||||||
|
|
||||||
{{end}}{{end}}
|
|
||||||
@@ -10,8 +10,7 @@ func ConfluentSecretKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "confluent-secret-key",
|
RuleID: "confluent-secret-key",
|
||||||
Description: "Confluent Secret Key",
|
Description: "Confluent Secret Key",
|
||||||
Regex: generateSemiGenericRegex([]string{"confluent"}, alphaNumeric("64")),
|
Regex: generateSemiGenericRegex([]string{"confluent"}, alphaNumeric("64"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"confluent",
|
"confluent",
|
||||||
},
|
},
|
||||||
@@ -29,8 +28,8 @@ func ConfluentAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "confluent-access-token",
|
RuleID: "confluent-access-token",
|
||||||
Description: "Confluent Access Token",
|
Description: "Confluent Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"confluent"}, alphaNumeric("16")),
|
Regex: generateSemiGenericRegex([]string{"confluent"}, alphaNumeric("16"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"confluent",
|
"confluent",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ func Contentful() *config.Rule {
|
|||||||
Description: "Contentful delivery API token",
|
Description: "Contentful delivery API token",
|
||||||
RuleID: "contentful-delivery-api-token",
|
RuleID: "contentful-delivery-api-token",
|
||||||
Regex: generateSemiGenericRegex([]string{"contentful"},
|
Regex: generateSemiGenericRegex([]string{"contentful"},
|
||||||
alphaNumericExtended("43")),
|
alphaNumericExtended("43"), true),
|
||||||
SecretGroup: 1,
|
Keywords: []string{"contentful"},
|
||||||
Keywords: []string{"contentful"},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ func Databricks() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Databricks API token",
|
Description: "Databricks API token",
|
||||||
RuleID: "databricks-api-token",
|
RuleID: "databricks-api-token",
|
||||||
Regex: generateUniqueTokenRegex(`dapi[a-h0-9]{32}`),
|
Regex: generateUniqueTokenRegex(`dapi[a-h0-9]{32}`, true),
|
||||||
Keywords: []string{"dapi"},
|
Keywords: []string{"dapi"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ func DatadogtokenAccessToken() *config.Rule {
|
|||||||
RuleID: "datadog-access-token",
|
RuleID: "datadog-access-token",
|
||||||
Description: "Datadog Access Token",
|
Description: "Datadog Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"datadog"},
|
Regex: generateSemiGenericRegex([]string{"datadog"},
|
||||||
alphaNumeric("40")),
|
alphaNumeric("40"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"datadog",
|
"datadog",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,11 +14,8 @@ func DefinedNetworkingAPIToken() *config.Rule {
|
|||||||
// Unique ID for the rule
|
// Unique ID for the rule
|
||||||
RuleID: "defined-networking-api-token",
|
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 used for detecting secrets. See regex section below for more details
|
||||||
Regex: generateSemiGenericRegex([]string{"dnkey"}, `dnkey-[a-z0-9=_\-]{26}-[a-z0-9=_\-]{52}`),
|
Regex: generateSemiGenericRegex([]string{"dnkey"}, `dnkey-[a-z0-9=_\-]{26}-[a-z0-9=_\-]{52}`, true),
|
||||||
|
|
||||||
// Keywords used for string matching on fragments (think of this as a prefilter)
|
// Keywords used for string matching on fragments (think of this as a prefilter)
|
||||||
Keywords: []string{"dnkey"},
|
Keywords: []string{"dnkey"},
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ func DigitalOceanPAT() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "DigitalOcean Personal Access Token",
|
Description: "DigitalOcean Personal Access Token",
|
||||||
RuleID: "digitalocean-pat",
|
RuleID: "digitalocean-pat",
|
||||||
SecretGroup: 1,
|
Regex: generateUniqueTokenRegex(`dop_v1_[a-f0-9]{64}`, true),
|
||||||
Regex: generateUniqueTokenRegex(`dop_v1_[a-f0-9]{64}`),
|
|
||||||
Keywords: []string{"dop_v1_"},
|
Keywords: []string{"dop_v1_"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,9 +23,9 @@ func DigitalOceanOAuthToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "DigitalOcean OAuth Access Token",
|
Description: "DigitalOcean OAuth Access Token",
|
||||||
RuleID: "digitalocean-access-token",
|
RuleID: "digitalocean-access-token",
|
||||||
SecretGroup: 1,
|
|
||||||
Regex: generateUniqueTokenRegex(`doo_v1_[a-f0-9]{64}`),
|
Regex: generateUniqueTokenRegex(`doo_v1_[a-f0-9]{64}`, true),
|
||||||
Keywords: []string{"doo_v1_"},
|
Keywords: []string{"doo_v1_"},
|
||||||
}
|
}
|
||||||
|
|
||||||
tps := []string{
|
tps := []string{
|
||||||
@@ -39,9 +38,9 @@ func DigitalOceanRefreshToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "DigitalOcean OAuth Refresh Token",
|
Description: "DigitalOcean OAuth Refresh Token",
|
||||||
RuleID: "digitalocean-refresh-token",
|
RuleID: "digitalocean-refresh-token",
|
||||||
SecretGroup: 1,
|
|
||||||
Regex: generateUniqueTokenRegex(`dor_v1_[a-f0-9]{64}`),
|
Regex: generateUniqueTokenRegex(`dor_v1_[a-f0-9]{64}`, true),
|
||||||
Keywords: []string{"dor_v1_"},
|
Keywords: []string{"dor_v1_"},
|
||||||
}
|
}
|
||||||
|
|
||||||
tps := []string{
|
tps := []string{
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ func DiscordAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Discord API key",
|
Description: "Discord API key",
|
||||||
RuleID: "discord-api-token",
|
RuleID: "discord-api-token",
|
||||||
Regex: generateSemiGenericRegex([]string{"discord"}, hex("64")),
|
Regex: generateSemiGenericRegex([]string{"discord"}, hex("64"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"discord"},
|
Keywords: []string{"discord"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,8 +26,7 @@ func DiscordClientID() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Discord client ID",
|
Description: "Discord client ID",
|
||||||
RuleID: "discord-client-id",
|
RuleID: "discord-client-id",
|
||||||
Regex: generateSemiGenericRegex([]string{"discord"}, numeric("18")),
|
Regex: generateSemiGenericRegex([]string{"discord"}, numeric("18"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"discord"},
|
Keywords: []string{"discord"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +42,7 @@ func DiscordClientSecret() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Discord client secret",
|
Description: "Discord client secret",
|
||||||
RuleID: "discord-client-secret",
|
RuleID: "discord-client-secret",
|
||||||
Regex: generateSemiGenericRegex([]string{"discord"}, alphaNumericExtended("32")),
|
Regex: generateSemiGenericRegex([]string{"discord"}, alphaNumericExtended("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"discord"},
|
Keywords: []string{"discord"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func DroneciAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "droneci-access-token",
|
RuleID: "droneci-access-token",
|
||||||
Description: "Droneci Access Token",
|
Description: "Droneci Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"droneci"}, alphaNumeric("32")),
|
Regex: generateSemiGenericRegex([]string{"droneci"}, alphaNumeric("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"droneci",
|
"droneci",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ func DropBoxAPISecret() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Dropbox API secret",
|
Description: "Dropbox API secret",
|
||||||
RuleID: "dropbox-api-token",
|
RuleID: "dropbox-api-token",
|
||||||
Regex: generateSemiGenericRegex([]string{"dropbox"}, alphaNumeric("15")),
|
Regex: generateSemiGenericRegex([]string{"dropbox"}, alphaNumeric("15"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"dropbox"},
|
Keywords: []string{"dropbox"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
@@ -27,7 +27,7 @@ func DropBoxShortLivedAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "dropbox-short-lived-api-token",
|
RuleID: "dropbox-short-lived-api-token",
|
||||||
Description: "Dropbox short lived API token",
|
Description: "Dropbox short lived API token",
|
||||||
Regex: generateSemiGenericRegex([]string{"dropbox"}, `sl\.[a-z0-9\-=_]{135}`),
|
Regex: generateSemiGenericRegex([]string{"dropbox"}, `sl\.[a-z0-9\-=_]{135}`, true),
|
||||||
Keywords: []string{"dropbox"},
|
Keywords: []string{"dropbox"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ func DropBoxLongLivedAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "dropbox-long-lived-api-token",
|
RuleID: "dropbox-long-lived-api-token",
|
||||||
Description: "Dropbox long lived API token",
|
Description: "Dropbox long lived API token",
|
||||||
Regex: generateSemiGenericRegex([]string{"dropbox"}, `[a-z0-9]{11}(AAAAAAAAAA)[a-z0-9\-_=]{43}`),
|
Regex: generateSemiGenericRegex([]string{"dropbox"}, `[a-z0-9]{11}(AAAAAAAAAA)[a-z0-9\-_=]{43}`, true),
|
||||||
Keywords: []string{"dropbox"},
|
Keywords: []string{"dropbox"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func EtsyAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "etsy-access-token",
|
RuleID: "etsy-access-token",
|
||||||
Description: "Etsy Access Token",
|
Description: "Etsy Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"etsy"}, alphaNumeric("24")),
|
Regex: generateSemiGenericRegex([]string{"etsy"}, alphaNumeric("24"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"etsy",
|
"etsy",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ func Facebook() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Facebook Access Token",
|
Description: "Facebook Access Token",
|
||||||
RuleID: "facebook",
|
RuleID: "facebook",
|
||||||
Regex: generateSemiGenericRegex([]string{"facebook"}, hex("32")),
|
Regex: generateSemiGenericRegex([]string{"facebook"}, hex("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"facebook"},
|
Keywords: []string{"facebook"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ func FastlyAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Fastly API key",
|
Description: "Fastly API key",
|
||||||
RuleID: "fastly-api-token",
|
RuleID: "fastly-api-token",
|
||||||
Regex: generateSemiGenericRegex([]string{"fastly"}, alphaNumericExtended("32")),
|
Regex: generateSemiGenericRegex([]string{"fastly"}, alphaNumericExtended("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"fastly"},
|
Keywords: []string{"fastly"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ func FinicityClientSecret() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Finicity Client Secret",
|
Description: "Finicity Client Secret",
|
||||||
RuleID: "finicity-client-secret",
|
RuleID: "finicity-client-secret",
|
||||||
Regex: generateSemiGenericRegex([]string{"finicity"}, alphaNumeric("20")),
|
Regex: generateSemiGenericRegex([]string{"finicity"}, alphaNumeric("20"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"finicity"},
|
Keywords: []string{"finicity"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
@@ -27,9 +27,9 @@ func FinicityAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Finicity API token",
|
Description: "Finicity API token",
|
||||||
RuleID: "finicity-api-token",
|
RuleID: "finicity-api-token",
|
||||||
Regex: generateSemiGenericRegex([]string{"finicity"}, hex("32")),
|
Regex: generateSemiGenericRegex([]string{"finicity"}, hex("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"finicity"},
|
Keywords: []string{"finicity"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func FinnhubAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "finnhub-access-token",
|
RuleID: "finnhub-access-token",
|
||||||
Description: "Finnhub Access Token",
|
Description: "Finnhub Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"finnhub"}, alphaNumeric("20")),
|
Regex: generateSemiGenericRegex([]string{"finnhub"}, alphaNumeric("20"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"finnhub",
|
"finnhub",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func FlickrAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "flickr-access-token",
|
RuleID: "flickr-access-token",
|
||||||
Description: "Flickr Access Token",
|
Description: "Flickr Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"flickr"}, alphaNumeric("32")),
|
Regex: generateSemiGenericRegex([]string{"flickr"}, alphaNumeric("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"flickr",
|
"flickr",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func FreshbooksAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "freshbooks-access-token",
|
RuleID: "freshbooks-access-token",
|
||||||
Description: "Freshbooks Access Token",
|
Description: "Freshbooks Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"freshbooks"}, alphaNumeric("64")),
|
Regex: generateSemiGenericRegex([]string{"freshbooks"}, alphaNumeric("64"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"freshbooks",
|
"freshbooks",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ func GCPAPIKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "gcp-api-key",
|
RuleID: "gcp-api-key",
|
||||||
Description: "GCP API key",
|
Description: "GCP API key",
|
||||||
Regex: generateUniqueTokenRegex(`AIza[0-9A-Za-z\\-_]{35}`),
|
Regex: generateUniqueTokenRegex(`AIza[0-9A-Za-z\\-_]{35}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"AIza",
|
"AIza",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ func GenericCredential() *config.Rule {
|
|||||||
"password",
|
"password",
|
||||||
"auth",
|
"auth",
|
||||||
"access",
|
"access",
|
||||||
}, `[0-9a-z\-_.=]{10,150}`),
|
}, `[0-9a-z\-_.=]{10,150}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"key",
|
"key",
|
||||||
"api",
|
"api",
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ func GitterAccessToken() *config.Rule {
|
|||||||
RuleID: "gitter-access-token",
|
RuleID: "gitter-access-token",
|
||||||
Description: "Gitter Access Token",
|
Description: "Gitter Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"gitter"},
|
Regex: generateSemiGenericRegex([]string{"gitter"},
|
||||||
alphaNumericExtendedShort("40")),
|
alphaNumericExtendedShort("40"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"gitter",
|
"gitter",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func GoCardless() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "gocardless-api-token",
|
RuleID: "gocardless-api-token",
|
||||||
Description: "GoCardless API token",
|
Description: "GoCardless API token",
|
||||||
Regex: generateSemiGenericRegex([]string{"gocardless"}, `live_(?i)[a-z0-9\-_=]{40}`),
|
Regex: generateSemiGenericRegex([]string{"gocardless"}, `live_(?i)[a-z0-9\-_=]{40}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"live_",
|
"live_",
|
||||||
"gocardless",
|
"gocardless",
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ func GrafanaApiKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Grafana api key (or Grafana cloud api key)",
|
Description: "Grafana api key (or Grafana cloud api key)",
|
||||||
RuleID: "grafana-api-key",
|
RuleID: "grafana-api-key",
|
||||||
SecretGroup: 1,
|
|
||||||
Regex: generateUniqueTokenRegex(`eyJrIjoi[A-Za-z0-9]{70,400}={0,2}`),
|
Regex: generateUniqueTokenRegex(`eyJrIjoi[A-Za-z0-9]{70,400}={0,2}`, true),
|
||||||
Keywords: []string{"eyJrIjoi"},
|
Keywords: []string{"eyJrIjoi"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
@@ -29,9 +29,9 @@ func GrafanaCloudApiToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Grafana cloud api token",
|
Description: "Grafana cloud api token",
|
||||||
RuleID: "grafana-cloud-api-token",
|
RuleID: "grafana-cloud-api-token",
|
||||||
SecretGroup: 1,
|
|
||||||
Regex: generateUniqueTokenRegex(`glc_[A-Za-z0-9+/]{32,400}={0,2}`),
|
Regex: generateUniqueTokenRegex(`glc_[A-Za-z0-9+/]{32,400}={0,2}`, true),
|
||||||
Keywords: []string{"glc_"},
|
Keywords: []string{"glc_"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
@@ -48,9 +48,9 @@ func GrafanaServiceAccountToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Grafana service account token",
|
Description: "Grafana service account token",
|
||||||
RuleID: "grafana-service-account-token",
|
RuleID: "grafana-service-account-token",
|
||||||
SecretGroup: 1,
|
|
||||||
Regex: generateUniqueTokenRegex(`glsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8}`),
|
Regex: generateUniqueTokenRegex(`glsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8}`, true),
|
||||||
Keywords: []string{"glsa_"},
|
Keywords: []string{"glsa_"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
@@ -22,3 +23,26 @@ func Hashicorp() *config.Rule {
|
|||||||
}
|
}
|
||||||
return validate(r, tps, nil)
|
return validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HashicorpField() *config.Rule {
|
||||||
|
keywords := []string{"administrator_login_password", "password"}
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "HashiCorp Terraform password field",
|
||||||
|
RuleID: "hashicorp-tf-password",
|
||||||
|
Regex: generateSemiGenericRegex(keywords, fmt.Sprintf(`"%s"`, alphaNumericExtended("8,20")), true),
|
||||||
|
Keywords: keywords,
|
||||||
|
}
|
||||||
|
|
||||||
|
tps := []string{
|
||||||
|
// Example from: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/sql_server.html
|
||||||
|
"administrator_login_password = " + `"thisIsDog11"`,
|
||||||
|
// https://registry.terraform.io/providers/petoju/mysql/latest/docs
|
||||||
|
"password = " + `"rootpasswd"`,
|
||||||
|
}
|
||||||
|
fps := []string{
|
||||||
|
"administrator_login_password = var.db_password",
|
||||||
|
`password = "${aws_db_instance.default.password}"`,
|
||||||
|
}
|
||||||
|
return validate(r, tps, fps)
|
||||||
|
}
|
||||||
@@ -9,9 +9,9 @@ func Heroku() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Heroku API Key",
|
Description: "Heroku API Key",
|
||||||
RuleID: "heroku-api-key",
|
RuleID: "heroku-api-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"heroku"}, hex8_4_4_4_12()),
|
Regex: generateSemiGenericRegex([]string{"heroku"}, hex8_4_4_4_12(), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"heroku"},
|
Keywords: []string{"heroku"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ func HubSpot() *config.Rule {
|
|||||||
Description: "HubSpot API Token",
|
Description: "HubSpot API Token",
|
||||||
RuleID: "hubspot-api-key",
|
RuleID: "hubspot-api-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"hubspot"},
|
Regex: generateSemiGenericRegex([]string{"hubspot"},
|
||||||
`[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}`),
|
`[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"hubspot"},
|
Keywords: []string{"hubspot"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference: https://huggingface.co/docs/hub/security-tokens
|
||||||
|
//
|
||||||
|
// Old tokens have the prefix `api_`, however, I am not sure it's worth detecting them as that would be high noise.
|
||||||
|
// https://huggingface.co/docs/api-inference/quicktour
|
||||||
|
func HuggingFaceAccessToken() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "huggingface-access-token",
|
||||||
|
Description: "Hugging Face Access token",
|
||||||
|
Regex: regexp.MustCompile(`(?:^|[\\'"` + "`" + ` >=:])(hf_[a-zA-Z]{34})(?:$|[\\'"` + "`" + ` <])`),
|
||||||
|
|
||||||
|
Entropy: 1,
|
||||||
|
Keywords: []string{
|
||||||
|
"hf_",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
`huggingface-cli login --token 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`,
|
||||||
|
`huggingface-cli login --token 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`,
|
||||||
|
`huggingface-cli login --token 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`,
|
||||||
|
`huggingface-cli login --token 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`,
|
||||||
|
`huggingface-cli login --token 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`,
|
||||||
|
`huggingface-cli login --token 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`,
|
||||||
|
`huggingface-cli login --token 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`,
|
||||||
|
`huggingface-cli login --token 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`,
|
||||||
|
`-H "Authorization: Bearer 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"`,
|
||||||
|
`DEV=1 HF_TOKEN=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 poetry run python app.py`,
|
||||||
|
`use_auth_token='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')`,
|
||||||
|
`CI_HUB_USER_TOKEN = "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"`,
|
||||||
|
`- Change line 5 and add your Hugging Face token, that is, instead of 'hf_token = "ADD_YOUR_HUGGING_FACE_TOKEN_HERE"', you will need to change it to something like'hf_token = "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"'`,
|
||||||
|
` " hf_token = \"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\"\n",`,
|
||||||
|
`# Not critical, only usable on the sandboxed CI instance.
|
||||||
|
TOKEN = "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"`,
|
||||||
|
` parser.add_argument("--hf_token", type=str, default='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', help="Hugging Face Access Token to access PyAnnote gated models")`,
|
||||||
|
}
|
||||||
|
fps := []string{
|
||||||
|
`- (id)hf_requiredCharacteristicTypesForDisplayMetadata;`,
|
||||||
|
`amazon.de#@#div[data-cel-widget="desktop-rhf_SponsoredProductsRemoteRHFSearchEXPSubsK2ClickPagination"]`,
|
||||||
|
` _kHMSymptomhf_generatedByHomeAppForDebuggingPurposesKey,`,
|
||||||
|
` #define OSCHF_DebugGetExpectedAverageCrystalAmplitude NOROM_OSCHF_DebugGetExpectedAverageCrystalAmplitude`,
|
||||||
|
` M_UINT (ServingCellPriorityParametersDescription_t, H_PRIO, 2, &hf_servingcellpriorityparametersdescription_h_prio),`,
|
||||||
|
`+HWI-ST565_0092:4:1101:5508:5860#ACTTGA/1
|
||||||
|
bb_eeeeegfgffhiiiiiiiiiiihiiiiicgafhf_eefghihhiiiifhifhhdhifhiiiihifdgdhggf\bbceceedbcd
|
||||||
|
@HWI-ST565_0092:4:1101:7621:5770#ACTTGA/1`,
|
||||||
|
`y{}x|~|}{~}}~|~}||�~|�{��|{}{|~z{}{{|{||{|}|{}{~|y}vjoePbUBJ7&;"; <; :;?!!;<7%$IACa_ecghbfbaebejhahfbhf_ddbficghbgfbhhcghdghfhigiifhhehhdggcgfchf_fgcei^[[.40&54"5666 6`,
|
||||||
|
` change_dir(cwd)
|
||||||
|
subdirs = glob.glob('HF_CAASIMULIAComputeServicesBuildTime.HF*.Linux64')
|
||||||
|
if len(subdirs) == 1:`,
|
||||||
|
` os.environ.get("HF_AUTH_TOKEN",
|
||||||
|
"hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),`,
|
||||||
|
`# HuggingFace API Token https://huggingface.co/settings/tokens
|
||||||
|
HUGGINGFACE_API_TOKEN=hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,`,
|
||||||
|
}
|
||||||
|
return validate(r, tps, fps)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Will be deprecated Aug 1st, 2023.
|
||||||
|
func HuggingFaceOrganizationApiToken() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "huggingface-organization-api-token",
|
||||||
|
Description: "Hugging Face Organization API token",
|
||||||
|
Regex: regexp.MustCompile(`(?:^|[\\'"` + "`" + ` >=:\(,)])(api_org_[a-zA-Z]{34})(?:$|[\\'"` + "`" + ` <\),])`),
|
||||||
|
|
||||||
|
Entropy: 2,
|
||||||
|
Keywords: []string{
|
||||||
|
"api_org_",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
`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`,
|
||||||
|
"`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`",
|
||||||
|
`\'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'\`,
|
||||||
|
`\"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\"`,
|
||||||
|
`,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,`,
|
||||||
|
`(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)`,
|
||||||
|
`<foo>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</foo>`,
|
||||||
|
`def test_private_space(self):
|
||||||
|
hf_token = "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" # Intentionally revealing this key for testing purposes
|
||||||
|
io = gr.load(`,
|
||||||
|
`hf_token = "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" # Intentionally revealing this key for testing purposes`,
|
||||||
|
`"news_train_dataset = datasets.load_dataset('nlpHakdang/aihub-news30k', data_files = \"train_news_text.csv\", use_auth_token='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')\n",`,
|
||||||
|
`os.environ['HUGGINGFACEHUB_API_TOKEN'] = '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'`,
|
||||||
|
fmt.Sprintf("api_org_%s", secrets.NewSecret(`[a-zA-Z]{34}`)),
|
||||||
|
}
|
||||||
|
fps := []string{
|
||||||
|
`public static final String API_ORG_EXIST = "APIOrganizationExist";`,
|
||||||
|
`const api_org_controller = require('../../controllers/api/index').organizations;`,
|
||||||
|
`API_ORG_CREATE("https://qyapi.weixin.qq.com/cgi-bin/department/create?access_token=ACCESS_TOKEN"),`,
|
||||||
|
`def test_internal_api_org_inclusion_with_href(api_name, href, expected, monkeypatch, called_with):
|
||||||
|
monkeypatch.setattr("requests.sessions.Session.request", called_with)`,
|
||||||
|
` def _api_org_96726c78_4ae3_402f_b08b_7a78c6903d2a(self, method, url, body, headers):
|
||||||
|
body = self.fixtures.load("api_org_96726c78_4ae3_402f_b08b_7a78c6903d2a.xml")
|
||||||
|
return httplib.OK, body, headers, httplib.responses[httplib.OK]`,
|
||||||
|
`<p>You should see a token <code>hf_xxxxx</code> (old tokens are <code>api_XXXXXXXX</code> or <code>api_org_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</code>).</p>`,
|
||||||
|
` From Hugging Face docs:
|
||||||
|
You should see a token hf_xxxxx (old tokens are api_XXXXXXXX or api_org_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).
|
||||||
|
If you do not submit your API token when sending requests to the API, you will not be able to run inference on your private models.`,
|
||||||
|
}
|
||||||
|
return validate(r, tps, fps)
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func InfracostAPIToken() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
// Human readable description of the rule
|
||||||
|
Description: "Infracost API Token",
|
||||||
|
|
||||||
|
// Unique ID for the rule
|
||||||
|
RuleID: "infracost-api-token",
|
||||||
|
|
||||||
|
// Regex capture group for the actual secret
|
||||||
|
|
||||||
|
// Regex used for detecting secrets. See regex section below for more details
|
||||||
|
Regex: generateUniqueTokenRegex(`ico-[a-zA-Z0-9]{32}`, true),
|
||||||
|
|
||||||
|
// Keywords used for string matching on fragments (think of this as a prefilter)
|
||||||
|
Keywords: []string{"ico-"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
generateSampleSecret("ico", "ico-"+secrets.NewSecret("[A-Za-z0-9]{32}")),
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
@@ -10,9 +10,9 @@ func Intercom() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Intercom API Token",
|
Description: "Intercom API Token",
|
||||||
RuleID: "intercom-api-key",
|
RuleID: "intercom-api-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"intercom"}, alphaNumericExtended("60")),
|
Regex: generateSemiGenericRegex([]string{"intercom"}, alphaNumericExtended("60"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"intercom"},
|
Keywords: []string{"intercom"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func JFrogAPIKey() *config.Rule {
|
||||||
|
keywords := []string{"jfrog", "artifactory", "bintray", "xray"}
|
||||||
|
|
||||||
|
// Define Rule
|
||||||
|
r := config.Rule{
|
||||||
|
// Human readable description of the rule
|
||||||
|
Description: "JFrog API Key",
|
||||||
|
|
||||||
|
// Unique ID for the rule
|
||||||
|
RuleID: "jfrog-api-key",
|
||||||
|
|
||||||
|
// Regex capture group for the actual secret
|
||||||
|
|
||||||
|
// Regex used for detecting secrets. See regex section below for more details
|
||||||
|
Regex: generateSemiGenericRegex(keywords, alphaNumeric("73"), true),
|
||||||
|
|
||||||
|
// Keywords used for string matching on fragments (think of this as a prefilter)
|
||||||
|
Keywords: keywords,
|
||||||
|
}
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
fmt.Sprintf("--set imagePullSecretJfrog.password=%s", secrets.NewSecret(alphaNumeric("73"))),
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func JFrogIdentityToken() *config.Rule {
|
||||||
|
keywords := []string{"jfrog", "artifactory", "bintray", "xray"}
|
||||||
|
|
||||||
|
// Define Rule
|
||||||
|
r := config.Rule{
|
||||||
|
// Human readable description of the rule
|
||||||
|
Description: "JFrog Identity Token",
|
||||||
|
|
||||||
|
// Unique ID for the rule
|
||||||
|
RuleID: "jfrog-identity-token",
|
||||||
|
|
||||||
|
// Regex capture group for the actual secret
|
||||||
|
|
||||||
|
// Regex used for detecting secrets. See regex section below for more details
|
||||||
|
Regex: generateSemiGenericRegex(keywords, alphaNumeric("64"), true),
|
||||||
|
|
||||||
|
// Keywords used for string matching on fragments (think of this as a prefilter)
|
||||||
|
Keywords: keywords,
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
generateSampleSecret("jfrog", secrets.NewSecret(alphaNumeric("64"))),
|
||||||
|
generateSampleSecret("artifactory", secrets.NewSecret(alphaNumeric("64"))),
|
||||||
|
generateSampleSecret("bintray", secrets.NewSecret(alphaNumeric("64"))),
|
||||||
|
generateSampleSecret("xray", secrets.NewSecret(alphaNumeric("64"))),
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
b64 "encoding/base64"
|
||||||
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,13 +13,176 @@ func JWT() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "JSON Web Token",
|
Description: "JSON Web Token",
|
||||||
RuleID: "jwt",
|
RuleID: "jwt",
|
||||||
Regex: generateUniqueTokenRegex(`ey[0-9a-z]{30,34}\.ey[0-9a-z-\/_]{30,500}\.[0-9a-zA-Z-\/_]{10,200}={0,2}`),
|
Regex: generateUniqueTokenRegex(`ey[a-zA-Z0-9]{17,}\.ey[a-zA-Z0-9\/\\_-]{17,}\.(?:[a-zA-Z0-9\/\\_-]{10,}={0,2})?`, false),
|
||||||
Keywords: []string{"ey"},
|
Keywords: []string{"ey"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{`eyJhbGciOieeeiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwic3ViZSI6IjEyMzQ1Njc4OTAiLCJuYW1lZWEiOiJKb2huIERvZSIsInN1ZmV3YWZiIjoiMTIzNDU2Nzg5MCIsIm5hbWVmZWF3ZnciOiJKb2huIERvZSIsIm5hbWVhZmV3ZmEiOiJKb2huIERvZSIsInN1ZndhZndlYWIiOiIxMjM0NTY3ODkwIiwibmFtZWZ3YWYiOiJKb2huIERvZSIsInN1YmZ3YWYiOiIxMjM0NTY3ODkwIiwibmFtZndhZSI6IkpvaG4gRG9lIiwiaWZ3YWZhYXQiOjE1MTYyMzkwMjJ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ViZSI6IjEyMzQ1Njc4OTAiLCJuYW1lZWEiOiJKb2huIERvZSIsInN1ZmV3YWZiIjoiMTIzNDU2Nzg5MCIsIm5hbWVmZWF3ZnciOiJKb2huIERvZSIsIm5hbWVhZmV3ZmEiOiJKb2huIERvZSIsInN1ZndhZndlYWIiOiIxMjM0NTY3ODkwIiwibmFtZWZ3YWYiOiJKb2huIERvZSIsInN1YmZ3YWYiOiIxMjM0NTY3ODkwIiwibmFtZndhZSI6IkpvaG4gRG9lIiwiaWZ3YWZhYXQiOjE1MTYyMzkwMjJ9.a_5icKBDo-8EjUlrfvz2k2k-FYaindQ0DEYNrlsnRG0`, // gitleaks:allow
|
||||||
|
`"access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJRMzFDVlMxUFNDSjRPVEsyWVZFTSIsImF0X2hhc2giOiI4amItZFE2OXRtZEVueUZaMUttNWhnIiwiYXVkIjoiZXhhbXBsZS1hcHAiLCJlbWFpbCI6ImFkbWluQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImV4cCI6IjE1OTQ2MDAxODIiLCJpYXQiOjE1OTQ1ODkzODQsImlzcyI6Imh0dHA6Ly8xMjcuMC4wLjE6NTU1Ni9kZXgiLCJuYW1lIjoiYWRtaW4iLCJzdWIiOiJDaVF3T0dFNE5qZzBZaTFrWWpnNExUUmlOek10T1RCaE9TMHpZMlF4TmpZeFpqVTBOallTQld4dlkyRnMifQ.nrbzIJz99Om7TvJ04jnSTmhvlM7aR9hMM1Aqjp2ONJ1UKYCvegBLrTu6cYR968_OpmnAGJ8vkd7sIjUjtR4zbw"`, // gitleaks:allow
|
||||||
|
`https://dai2-playlistserver.aws.syncbak.com/cpl/20980038/dai2v5/1.0/7b2264657669636554797065223a387d/master.m3u8?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkdyYXkyMDE2MDgyOSJ9.eyJtaWQiOiIy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lY3VyZS5pc3Rpby5pbyJ9.EdJnEZSH6X8hcyEii7c8H5lnhgjB5dwo07M5oheC8Xz8mOllyg--AHCFWHybM48reunF--oGaG6IXVngCEpVF0_P5DwsUoBgpPmK1JOaKN6_pe9sh0ZwTtdgK_RP01PuI7kUdbOTlkuUi2AO-qUyOm7Art2POzo36DLQlUXv8Ad7NBOqfQaKjE9ndaPWT7aexUsBHxmgiGbz1SyLH879f7uHYPbPKlpHU6P9S-DaKnGLaEchnoKnov7ajhrEhGXAQRukhDPKUHO9L30oPIr5IJllEQfHYtt6IZvlNUGeLUcif3wpry1R5tBXRicx2sXMQ7LyuDremDbcNy_iE76Upg`, // gitleaks:allow
|
||||||
|
`python examples/cli.py eyJhbGciOiJIUzI1NiJ9.eyJJc3N1ZXIiOiJJc3N1ZXIiLCJVc2VybmFtZSI6IkJhZFNlY3JldHMiLCJleHAiOjE1OTMxMzM0ODMsImlhdCI6MTQ2NjkwMzA4M30.ovqRikAo_0kKJ0GVrAwQlezymxrLGjcEiW_s3UJMMCo`, // gitleaks:allow
|
||||||
|
`"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VybmFtZTpib2IifQ.HcfCW67Uda-0gz54ZWTqmtgJnZeNem0Q757eTa9EZuw"`, // gitleaks:allow
|
||||||
|
`"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODk1ODU1NjN9.PtfDS1niGoZ7pV6kplI-_q1fVKLnknQ3IwcrLZhoVCU",`, // gitleaks:allow
|
||||||
|
`// authorization: 'eyJhbGciOiJIUzUxMiIsImlhdCI6MTU3Njk5Njc5OSwiZXhwIjoxNTg0ODU5MTk5fQ.eyJ1aWQiOjQ1NzQyN30.0ei5UE6OgLBzN2_IS7xUIbIfW_S1Wzl42q2UeusbboxuzvctO_4Mz6YRr6f0PBLUVZMETxt8F0_4-yqIJ3_kUQ',`, // gitleaks:allow
|
||||||
|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W9Tmfn-Kt_6Jwq8HQ9GOCwAicEz0JVireHA7EWhATzuT56eO6MTe-2j5bpGnPQRJJtQ8AbtAN3nVK7RPjSzmc8Ppqx1z5i4oCGwiyRlGwqT-FkCtQLbQaQ4XmrASQoN4pJ_OBy5slztUhk32HdGP6pQx5c-nfei-of_4ij_fHrP0xEEfmVVvXqi9WKv1PLkQ3qTiSFDzv8M2sE4T6XmCGBbw7gyHzEGSpOAPZr00bX_YMCUvEF0lyP4YK696xWCBA`, // gitleaks:allow
|
||||||
|
`$ curl "http://admin:password@127.0.0.1:8080/api/v2/token"
|
||||||
|
{"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiQVBJIl0sImV4cCI6MTYxMzMzNTI2MSwianRpIjoiYzBrb2gxZmNkcnBjaHNzMGZwZmciLCJuYmYiOjE2MTMzMzQ2MzEsInBlcm1pc3Npb25zIjpbIioiXSwic3ViIjoiYUJ0SHUwMHNBUmxzZ29yeEtLQ1pZZWVqSTRKVTlXbThHSGNiVWtWVmc1TT0iLCJ1c2VybmFtZSI6ImFkbWluIn0.WiyqvUF-92zCr--y4Q_sxn-tPnISFzGZd_exsG-K7ME","expires_at":"2021-02-14T20:41:01Z"}`, // gitleaks:allow
|
||||||
|
`curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiQVBJIl0sImV4cCI6MTYxMzMzNTI2MSwianRpIjoiYzBrb2gxZmNkcnBjaHNzMGZwZmciLCJuYmYiOjE2MTMzMzQ2MzEsInBlcm1pc3Npb25zIjpbIioiXSwic3ViIjoiYUJ0SHUwMHNBUmxzZ29yeEtLQ1pZZWVqSTRKVTlXbThHSGNiVWtWVmc1TT0iLCJ1c2VybmFtZSI6ImFkbWluIn0.WiyqvUF-92zCr--y4Q_sxn-tPnISFzGZd_exsG-K7ME" "http://127.0.0.1:8080/api/v2/dumpdata?output-data=1"`, // gitleaks:allow
|
||||||
|
`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C9sb2NhbGhvc3Q6OTQ0M1wvb2F1dGgyXC90b2tlbiIsImV4cCI6MTUzNDg5MTc3OCwiaWF0IjoxNTM0ODg4MTc4LCJqdGkiOiIxODQ0MzI5Yy1kNjVhLTQ4YTMtODIyOC05ZGY3M2ZlODNkNTYifQ.ELZ8ujk2Xp9xTGgMqnCa5ehuimaAPXWlSCW5QeBbTJIT4M5OB_2XEVIV6p89kftjUdKu50oiYe4SbfrxmLm6NGSGd2qxkjzJK3SRKqsrmVWEn19juj8fz1neKtUdXVHuSZu6ws_bMDy4f_9hN2Jv9dFnkoyeNT54r4jSTJ4A2FzN2rkiURheVVsc8qlm8O7g64Az-5h4UGryyXU4zsnjDCBKYk9jdbEpcUskrFMYhuUlj1RWSASiGhHHHDU5dTRqHkVLIItfG48k_fb-ehU60T7EFWH1JBdNjOxM9oN_yb0hGwOjLUyCUJO_Y7xcd5F4dZzrBg8LffFmvJ09wzHNtQ",`, // gitleaks:allow
|
||||||
|
` # The following default key is generated by the local Supabase start and doesn't change
|
||||||
|
- SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0`, // gitleaks:allow
|
||||||
|
`Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoxLCJiIjoyLCJjIjozfQ.hxhGCCCmGV9nT1slief1WgEsOsfdnlVizNrODxfh1M8`, // gitleaks:allow
|
||||||
|
`--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJhY3RvclR5cGUiOiJVU0VSIiwiYWN0b3JJZCI6ImRhdGFodWIiLCJ0eXBlIjoiUEVSU09OQUwiLCJ2ZXJzaW9uIjoiMSIsImV4cCI6MTY1MDY2MDY1NSwianRpIjoiM2E4ZDY3ZTItOTM5Yi00NTY3LWE0MjYtZDdlMDA1ZGU3NjJjIiwic3ViIjoiZGF0YWh1YiIsImlzcyI6ImRhdGFodWItbWV0YWRhdGEtc2VydmljZSJ9.pp_vW2u1tiiTT7U0nDF2EQdcayOMB8jatiOA8Je4JJA' \`, // gitleaks:allow
|
||||||
|
`"Cookie": "auth-token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NDIxMTEsImlzQWRtaW4iOmZhbHNlLCJnaXRodWJJZCI6ImR5ZXhwbG9kZSIsImFwcFJvbGVzIjpbInVzZXIiXSwicm9sZXMiOnsiNDciOiJzdHVkZW50IiwiNTYiOiJzdHVkZW50In0sImNvdXJzZXNSb2xlcyI6eyI0NyI6WyJzdHVkZW50Il0sIjU2IjpbInN0dWRlbnQiXX0sImNvdXJzZXMiOnsiNDciOnsibWVudG9ySWQiOm51bGwsInN0dWRlbnRJZCI6NjY3OTMsInJvbGVzIjpbInN0dWRlbnQiXX0sIjU2Ijp7Im1lbnRvcklkIjpudWxsLCJzdHVkZW50SWQiOjYzMzk4LCJyb2xlcyI6WyJzdHVkZW50Il19fSwiaWF0IjoxNjQ1MjA5NzI2LCJleHAiOjE2NDUzODI1MjZ9.btpYeSioEDUNMI6bAPqgu5zndA8XR5DT8P9U9kotOEA",`, // gitleaks:allow
|
||||||
|
`<li> <a class="cbtn btn-grad-s btn-shadow btn-width"
|
||||||
|
target="_blank"
|
||||||
|
href="https://demo.kuboard.cn/dashboard?k8sToken=eyJhbGciOiJSUzI1NiIsImtpZCI6InZ6SzVqZFNJOXZFMmxQSkhXamNBcFY4RU9FR0RvSUR5bzJIY0NwVG1zODQifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5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JpdmF0ZSIsIkEubm9ybWFsX3VzZXJfY29tbWVyY2lhbCIsIkEubm9ybWFsX3VzZXJfcGMiXSwibmFtZSI6WyJUZXN0Il0sIm1haWwiOlsiVGVzdEBleGFtcGxlLmNvbSJdLCJvcmdhbml6YXRpb24iOlsiWC1YeHh4eHguMTIzNCJdLCJsb2NhdGlvbiI6WyIxMjMyMSJdLCJ1bml0IjpbIjEwMyJdLCJjb3VudHJ5IjpbIkNOIl0sInVzZXJUeXBlIjoiZW1wbG95ZWUifSwiaWRlbnRpdHktaWQiOiJNb2NrIn0.EK5TbwsIgde3mT3n7NK2W7TCvpgQQLzshvPPANRQeUmKOv2AWbo_7vNEDTSkwUlaHRN3-dknv8F95p5MsGTzH6Uva8aOPJG6JdBIoYX_ud3aBN-hY1i2Xpf8pqjeINfY3_gDNAB9gdMznEej2uqhPwUXmZtcuWPdUCCeNqPJbRUAJeVXxLr_JtQzO2jmuwNY_YYp7KaEIANZwG1spvLuIGZ0HA03u8ye9c2lfqYcjgfIkjMrwgWPamR7joZOZPdQSO2EHrF7bUWMjRNY-FF5V7tOjEijkknE_nDq5THcEvx1seHYFdFNwy9LSSGGPVmZMKTKQ3UUlZZyBMXcOpOA9w`, // gitleaks:allow
|
||||||
|
// TODO: Detect newlines or escapes (\)?
|
||||||
|
// https://github.com/mongodb/mongo/blob/1960b792ade4e179ddc6113a3cd400e9492ca11d/src/mongo/crypto/README.JWT.md?plain=1#L115-L117
|
||||||
|
// TODO: Detect empty claims section?
|
||||||
|
// `eyJhbGciOiJFQ0RILUVTIiwiZW5jIjoiQTI1NkdDTSIsImVwayI6eyJrdHkiOiJFQyIsImNydiI6IlAtMzg0Iiwia2V5X29wcyI6W10sImV4dCI6dHJ1ZSwieCI6IllUcEY3bGtTc3JvZVVUVFdCb21LNzBTN0FhVTJyc0ptMURpZ1ZzbjRMY2F5eUxFNFBabldkYmFVcE9jQVV5a1ciLCJ5IjoiLU5pS3loUktjSk52Nm02Z0ZJUWc4cy1Xd1VXUW9uT3A5dkQ4cHpoa2tUU3U2RzFlU2FUTVlhZGltQ2Q4V0ExMSJ9LCJhcHUiOiIiLCJhcHYiOiIifQ`,
|
||||||
|
`String tokenWithNoneAlg = "eyJhbGciOiJub25lIn0.eyJzdWIiOiJ0ZXN0LXVzZXIifQ.";`, // gitleaks:allow
|
||||||
|
`# Req: Invoke-RestMethod -Uri 'http://localhost:8085/users' -Headers @{ 'X-API-KEY' = 'eyJhbGciOiJub25lIn0.eyJ1c2VybmFtZSI6Im1vcnR5Iiwic3ViIjoiMTIzIn0.' }`, // gitleaks:allow
|
||||||
}
|
}
|
||||||
return validate(r, tps, nil)
|
fps := []string{}
|
||||||
|
return validate(r, tps, fps)
|
||||||
|
}
|
||||||
|
|
||||||
|
func JWTBase64() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "jwt-base64",
|
||||||
|
Description: "Base64-encoded JSON Web Token",
|
||||||
|
Regex: regexp.MustCompile(
|
||||||
|
`\bZXlK(?:(?P<alg>aGJHY2lPaU)|(?P<apu>aGNIVWlPaU)|(?P<apv>aGNIWWlPaU)|(?P<aud>aGRXUWlPaU)|(?P<b64>aU5qUWlP)|(?P<crit>amNtbDBJanBi)|(?P<cty>amRIa2lPaU)|(?P<epk>bGNHc2lPbn)|(?P<enc>bGJtTWlPaU)|(?P<jku>cWEzVWlPaU)|(?P<jwk>cWQyc2lPb)|(?P<iss>cGMzTWlPaU)|(?P<iv>cGRpSTZJ)|(?P<kid>cmFXUWlP)|(?P<key_ops>clpYbGZiM0J6SWpwY)|(?P<kty>cmRIa2lPaUp)|(?P<nonce>dWIyNWpaU0k2)|(?P<p2c>d01tTWlP)|(?P<p2s>d01uTWlPaU)|(?P<ppt>d2NIUWlPaU)|(?P<sub>emRXSWlPaU)|(?P<svt>emRuUWlP)|(?P<tag>MFlXY2lPaU)|(?P<typ>MGVYQWlPaUp)|(?P<url>MWNtd2l)|(?P<use>MWMyVWlPaUp)|(?P<ver>MlpYSWlPaU)|(?P<version>MlpYSnphVzl1SWpv)|(?P<x>NElqb2)|(?P<x5c>NE5XTWlP)|(?P<x5t>NE5YUWlPaU)|(?P<x5ts256>NE5YUWpVekkxTmlJNkl)|(?P<x5u>NE5YVWlPaU)|(?P<zip>NmFYQWlPaU))[a-zA-Z0-9\/\\_+\-\r\n]{40,}={0,2}`),
|
||||||
|
Keywords: []string{"zxlk"},
|
||||||
|
}
|
||||||
|
|
||||||
|
tps := generateTestValues()
|
||||||
|
fps := []string{
|
||||||
|
`-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
Version: GnuPG/MacGPG2 v2
|
||||||
|
Comment: GPGTools - https://gpgtools.org
|
||||||
|
|
||||||
|
mQENBFOrMNcBCAC+gLI4s3bUkobS5NpOQbWfjWXbqC0Ixpc5bZYDOvsmfstmswna
|
||||||
|
UWUXkRH9RONabzrAu4TGvW0f5DkC2fuWWHJhZWEccn+VE83+avMZN4/mzldSXPNX
|
||||||
|
A6F7+wHb1DjG+FCDcxMghkwDjGc16LOtZGufUo5iRQaC5pmNBOgDWdiObGPKOTEL
|
||||||
|
/uU8zLtKi2cibbkhRm22IGOzGyZMZN6zvEtPzlCp3eZEGMW0Ig+kbl6SaSDrSJNK
|
||||||
|
wElYcr/kJ9QF6CQ2iwZCGeL2jH5QaOi5uj1LXONpCd9nPeyDXc+Z20gXZiqkwRLc
|
||||||
|
IBPKza6hq/+4nwHBq8DNLv0W4xNC59jLbIhpABEBAAG0LEZyYW5rIE5vdGhhZnQg
|
||||||
|
PGZub3RoYWZ0QGFsdW1uaS5zdGFuZm9yZC5lZHU+iQE9BBMBCgAnBQJTqzDXAhsD
|
||||||
|
BQkHhh+ABQsJCAcDBRUKCQgLBRYCAwEAAh4BAheAAAoJECqYOYG1w7FJOr4IAK8x
|
||||||
|
ec4jbjd6jkKe0YJGdPzg6TM73ISV5VrUlJX7O3jgxHB4M8KIHN/8A/+ZxLk7WM96
|
||||||
|
iq0C8atWHkCkQ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eWAy6xMGfdSynbEExQ4z8
|
||||||
|
AIfKWMro74nRFbAnv/BzrF2R8uHmdE7T6q9ZZsAydlaxQbdmyhCeGAdw93CwAypb
|
||||||
|
vHVobJ8A
|
||||||
|
=mIC1
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----`,
|
||||||
|
}
|
||||||
|
return validate(r, tps, fps)
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateTestValues() []string {
|
||||||
|
// Sample JWT from RFC-7519
|
||||||
|
jwtSuffix := ".eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
|
||||||
|
// Validate known header parameters
|
||||||
|
// https://www.iana.org/assignments/jose/jose.xhtml
|
||||||
|
headers := map[string][]string{
|
||||||
|
"alg": {
|
||||||
|
`"ES256"`,
|
||||||
|
`"ES384"`,
|
||||||
|
`"ES512"`,
|
||||||
|
`"ECDH-ES"`,
|
||||||
|
`"HS256"`,
|
||||||
|
`"HS384"`,
|
||||||
|
`"HS512"`,
|
||||||
|
`"RS256"`,
|
||||||
|
`"RS384"`,
|
||||||
|
`"RS512"`,
|
||||||
|
`"PS256"`,
|
||||||
|
`"PS384"`, `"PS512"`,
|
||||||
|
`"none"`,
|
||||||
|
// Nonstandard
|
||||||
|
`"A128KW"`,
|
||||||
|
`"ECDH-ES+A256KW"`,
|
||||||
|
`"RSA-OAEP"`,
|
||||||
|
},
|
||||||
|
"apu": {`"Tx9qG69ZfodhRos-8qfhTPc6ZFnNUcgNDVdHqX1UR3s"`, `"RfXdxTfIzilWBzWWX3ovHBDzgDcLNy0BFJWSxa0dqnw"`},
|
||||||
|
"apv": {`"ZGlkOmVsZW06cm9wc3RlbjpFa"`, `"ZGlkOmtleTp6Nk1rak1TWWF1dU1neDlhekV5VW5UVzVvNWpGUmtiQnU1VDgzZjM5dU53bnNHbW0jejZMU29HdFpTclVNWnVkQWFnekVmWWY3azhqSFpjR0Q3OVNveDd2NHdDa0RLTlN3"`},
|
||||||
|
"aud": {`"https://vault.example.com"`, `"http://example.com"`},
|
||||||
|
"b64": {`true`, `false`},
|
||||||
|
"crit": {`["exp"]`},
|
||||||
|
"cty": {`"example"`, `"json"`},
|
||||||
|
"epk": {`{"crv":"X25519","kty":"OKP","x":"Tx9qG69ZfodhRos-8qfhTPc6ZFnNUcgNDVdHqX1UR3s"}`, `{"kty":"OKP","crv":"X25519","x":"RfXdxTfIzilWBzWWX3ovHBDzgDcLNy0BFJWSxa0dqnw"}`},
|
||||||
|
"enc": {`"A256GCM"`, `"A256CBC-HS512"`, `"A128CBC-HS256"`},
|
||||||
|
"jku": {`"https://c2id.com/jwks.json"`},
|
||||||
|
"jwk": {`{"crv":"P-256","kid":"DB2X:GSG2:72H3:AE3R:KCMI:Y77E:W7TF:ERHK:V5HR:JJ2Y:YMS6:HFGJ","kty":"EC","x":"jyr9-xZBorSC9fhqNsmfU_Ud31wbaZ-bVGz0HmySvbQ","y":"vkE6qZCCvYRWjSUwgAOvibQx_s8FipYkAiHS0VnAFNs"}`, `{"kty":"RSA","n":"jyTwiSJACtW_SW-aiihQS5Y5QR704zUwjhlevY0oK-y5wP7SlIc2hq2OPVRarCzjhOxZl2AQFzM5VCR7xRDcnIn9t_pl7Mgsnx9hKDS9yQ24YXzhQ4cMEVVuqwcHvXqPdWDSoCZ1ccMqiiPyBSNGQTXMPY5PBxMOR47XwOb4eNMOPqnzVio3MEtL2wphtEonP3MY6pxJJzzel04wSCRZ4n06reqwER3KwRFPnRpRxAgmSEot5IBLIT3jj-amT5sD7YoUDbPmLk23zgDBIhX88fkClilg1W-fUi1XxYZomEPGvV7OrE1yszt4YDPqKgjJT8t2JPy__1ri-8rZgSxn5Q","e":"AQAB"`},
|
||||||
|
"iss": {`"http://localhost:8087/realms/grafana"`, `"kubernetes/serviceaccount"`},
|
||||||
|
"iv": {`"zjJPRrj0TGez9JYkChTrB3iqKoDkiBhn"`, `"10PlAIteHLVABtt"`},
|
||||||
|
"kid": {`"my_key_id"`, `"did:example:123#zC1Rnuvw9rVa6E5TKF4uQVRuQuaCpVgB81Um2u17Fu7UK"`},
|
||||||
|
"key_ops": {`["sign"]`, `["decrypt"]`, `["encrypt"]`},
|
||||||
|
"kty": {`"EC"`, `"RSA"`},
|
||||||
|
"nonce": {`"Os_sBjfWzVZenwwjvLrwXA"`, `"LDDZAGcBuKYpuNlFTCxPYw"`},
|
||||||
|
"p2c": {`4096`, `1000`},
|
||||||
|
"p2s": {`"c_ORk4HSsqZD2LvVeCUHqg"`},
|
||||||
|
"ppt": {`"foo"`},
|
||||||
|
"sub": {`"project_path:my-group/my-project:ref_type:branch:ref:feature-branch-1"`, `"1234567890"`},
|
||||||
|
// I cannot find any real-world examples of the svt header
|
||||||
|
// and the RFC doesn't seem to explicitly state the content.
|
||||||
|
"svt": {``},
|
||||||
|
"tag": {`"h6mJqHn33oCsDd5X57MI-g"`},
|
||||||
|
"typ": {`"JWT"`, `"JWK"`, `"JSOE"`, `"JSON"`, `"plain"`},
|
||||||
|
"url": {`"https://example.com"`},
|
||||||
|
"use": {`"enc"`, `"sig"`},
|
||||||
|
"ver": {`"2"`, `"3"`},
|
||||||
|
"version": {`"2"`, `"3"`},
|
||||||
|
"x5c": {`["MIICmzCCAYMCBgF4HR7HNDANBgkqhkiG9w0BAQsFADARMQ8wDQYDVQQDDAZtYXN0ZXIwHhcNMjEwMzEwMTcwOTE5WhcNMzEwMzEwMTcxMDU5WjARMQ8wDQYDVQQDDAZtYXN0ZXIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDCpLzXHp8i09R2HU5YJPyncC4tiAWWmaDrVZenqynWlWKOjIXb0Y5JoP3ET68u16Bf7mHQGc/u9rRvCw4A92HpJ15WyUSJ80YcK0gPTE0Woc1ZxdK3h4t9AoA8VSrROwQ77w/VAdGrrJ4bwkAVrFqSRpqAsW5XxV3/bU8YkVaG8mh0kuFf/5ib0vxdSkg+mz+ZCuIxQ5YN77kNaMecO19XuaBo7FsG9WjfCPxXYuajkuLgdptPgwTN4np70h0WjaSP/jhjL2ixf48w+27wFDP+ic+B/TCOtVa3fj1GPo6RLxHGU0Zh64jFhmvRM6E/kX7IQ+FJcOwp1VPA9/vMABopAgMBAAEwDQYJKoZIhvcNAQELBQADggEBALILq1Z4oQNJZEUt24VZcvknsWtQtvPxl3JNcBQgDR5/IMgl5VndRZ9OT56KUqrR5xRsWiCvh5Lgv4fUEzAAo9ToiPLub1SKP063zWrvfgi3YZ19bty0iXFm7l2cpQ3ejFV7WpcdLJE0lapFdPLo6QaRdgNu/1p4vbYg7zSK1fQ0OY5b3ajhAx/bhWlrN685owRbO5/r4rUOa6oo9l4Qn7jUxKUx4rcoe7zUM7qrpOPqKvn0DBp3n1/+9pOZXCjIfZGvYwP5NhzBDCkRzaXcJHlOqWzMBzyovVrzVmUilBcj+EsTYJs0gVXKzduX5zO6YWhFs23lu7AijdkxTY65YM0="]`},
|
||||||
|
"x5t": {`"IYIeevIT57t8ppUejM42Bqx6f3I"`},
|
||||||
|
"x5t#S256": {`"TuOrBy2NcTlFSWuZ8Kh8W8AjQagb4fnfP1SlKMO8-So"`},
|
||||||
|
"x5u": {`"https://tel.example.org/passport.cer"`},
|
||||||
|
"zip": {`"DEF"`},
|
||||||
|
}
|
||||||
|
|
||||||
|
var examples []string
|
||||||
|
for key, values := range headers {
|
||||||
|
for _, value := range values {
|
||||||
|
header := fmt.Sprintf(`{"%s":%s}`, key, value)
|
||||||
|
jwt := []byte(b64.RawURLEncoding.EncodeToString([]byte(header)) + jwtSuffix)
|
||||||
|
examples = append(examples, b64.StdEncoding.EncodeToString(jwt))
|
||||||
|
examples = append(examples, b64.RawStdEncoding.EncodeToString(jwt))
|
||||||
|
examples = append(examples, b64.URLEncoding.EncodeToString(jwt))
|
||||||
|
examples = append(examples, b64.RawURLEncoding.EncodeToString(jwt))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return examples
|
||||||
}
|
}
|
||||||
@@ -11,8 +11,8 @@ func KrakenAccessToken() *config.Rule {
|
|||||||
RuleID: "kraken-access-token",
|
RuleID: "kraken-access-token",
|
||||||
Description: "Kraken Access Token",
|
Description: "Kraken Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"kraken"},
|
Regex: generateSemiGenericRegex([]string{"kraken"},
|
||||||
alphaNumericExtendedLong("80,90")),
|
alphaNumericExtendedLong("80,90"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"kraken",
|
"kraken",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func KucoinAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "kucoin-access-token",
|
RuleID: "kucoin-access-token",
|
||||||
Description: "Kucoin Access Token",
|
Description: "Kucoin Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"kucoin"}, hex("24")),
|
Regex: generateSemiGenericRegex([]string{"kucoin"}, hex("24"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"kucoin",
|
"kucoin",
|
||||||
},
|
},
|
||||||
@@ -29,8 +29,8 @@ func KucoinSecretKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "kucoin-secret-key",
|
RuleID: "kucoin-secret-key",
|
||||||
Description: "Kucoin Secret Key",
|
Description: "Kucoin Secret Key",
|
||||||
Regex: generateSemiGenericRegex([]string{"kucoin"}, hex8_4_4_4_12()),
|
Regex: generateSemiGenericRegex([]string{"kucoin"}, hex8_4_4_4_12(), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"kucoin",
|
"kucoin",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func LaunchDarklyAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "launchdarkly-access-token",
|
RuleID: "launchdarkly-access-token",
|
||||||
Description: "Launchdarkly Access Token",
|
Description: "Launchdarkly Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"launchdarkly"}, alphaNumericExtended("40")),
|
Regex: generateSemiGenericRegex([]string{"launchdarkly"}, alphaNumericExtended("40"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"launchdarkly",
|
"launchdarkly",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,9 +28,8 @@ func LinearClientSecret() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Linear Client Secret",
|
Description: "Linear Client Secret",
|
||||||
RuleID: "linear-client-secret",
|
RuleID: "linear-client-secret",
|
||||||
Regex: generateSemiGenericRegex([]string{"linear"}, hex("32")),
|
Regex: generateSemiGenericRegex([]string{"linear"}, hex("32"), true),
|
||||||
Keywords: []string{"linear"},
|
Keywords: []string{"linear"},
|
||||||
SecretGroup: 1,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ func LinkedinClientSecret() *config.Rule {
|
|||||||
Regex: generateSemiGenericRegex([]string{
|
Regex: generateSemiGenericRegex([]string{
|
||||||
"linkedin",
|
"linkedin",
|
||||||
"linked-in",
|
"linked-in",
|
||||||
}, alphaNumeric("16")),
|
}, alphaNumeric("16"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"linkedin",
|
"linkedin",
|
||||||
"linked-in",
|
"linked-in",
|
||||||
@@ -36,8 +36,8 @@ func LinkedinClientID() *config.Rule {
|
|||||||
Regex: generateSemiGenericRegex([]string{
|
Regex: generateSemiGenericRegex([]string{
|
||||||
"linkedin",
|
"linkedin",
|
||||||
"linked-in",
|
"linked-in",
|
||||||
}, alphaNumeric("14")),
|
}, alphaNumeric("14"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"linkedin",
|
"linkedin",
|
||||||
"linked-in",
|
"linked-in",
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func LobPubAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Lob Publishable API Key",
|
Description: "Lob Publishable API Key",
|
||||||
RuleID: "lob-pub-api-key",
|
RuleID: "lob-pub-api-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"lob"}, `(test|live)_pub_[a-f0-9]{31}`),
|
Regex: generateSemiGenericRegex([]string{"lob"}, `(test|live)_pub_[a-f0-9]{31}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"test_pub",
|
"test_pub",
|
||||||
"live_pub",
|
"live_pub",
|
||||||
@@ -31,12 +31,11 @@ func LobAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Lob API Key",
|
Description: "Lob API Key",
|
||||||
RuleID: "lob-api-key",
|
RuleID: "lob-api-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"lob"}, `(live|test)_[a-f0-9]{35}`),
|
Regex: generateSemiGenericRegex([]string{"lob"}, `(live|test)_[a-f0-9]{35}`, true),
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"test_",
|
"test_",
|
||||||
"live_",
|
"live_",
|
||||||
},
|
},
|
||||||
SecretGroup: 1,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func MailChimp() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "mailchimp-api-key",
|
RuleID: "mailchimp-api-key",
|
||||||
Description: "Mailchimp API key",
|
Description: "Mailchimp API key",
|
||||||
Regex: generateSemiGenericRegex([]string{"mailchimp"}, `[a-f0-9]{32}-us20`),
|
Regex: generateSemiGenericRegex([]string{"mailchimp"}, `[a-f0-9]{32}-us20`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"mailchimp",
|
"mailchimp",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func MailGunPrivateAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "mailgun-private-api-token",
|
RuleID: "mailgun-private-api-token",
|
||||||
Description: "Mailgun private API token",
|
Description: "Mailgun private API token",
|
||||||
Regex: generateSemiGenericRegex([]string{"mailgun"}, `key-[a-f0-9]{32}`),
|
Regex: generateSemiGenericRegex([]string{"mailgun"}, `key-[a-f0-9]{32}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"mailgun",
|
"mailgun",
|
||||||
},
|
},
|
||||||
@@ -29,8 +29,8 @@ func MailGunPubAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "mailgun-pub-key",
|
RuleID: "mailgun-pub-key",
|
||||||
Description: "Mailgun public validation key",
|
Description: "Mailgun public validation key",
|
||||||
Regex: generateSemiGenericRegex([]string{"mailgun"}, `pubkey-[a-f0-9]{32}`),
|
Regex: generateSemiGenericRegex([]string{"mailgun"}, `pubkey-[a-f0-9]{32}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"mailgun",
|
"mailgun",
|
||||||
},
|
},
|
||||||
@@ -48,8 +48,8 @@ func MailGunSigningKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "mailgun-signing-key",
|
RuleID: "mailgun-signing-key",
|
||||||
Description: "Mailgun webhook signing key",
|
Description: "Mailgun webhook signing key",
|
||||||
Regex: generateSemiGenericRegex([]string{"mailgun"}, `[a-h0-9]{32}-[a-h0-9]{8}-[a-h0-9]{8}`),
|
Regex: generateSemiGenericRegex([]string{"mailgun"}, `[a-h0-9]{32}-[a-h0-9]{8}-[a-h0-9]{8}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"mailgun",
|
"mailgun",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ func MapBox() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "MapBox API token",
|
Description: "MapBox API token",
|
||||||
RuleID: "mapbox-api-token",
|
RuleID: "mapbox-api-token",
|
||||||
Regex: generateSemiGenericRegex([]string{"mapbox"}, `pk\.[a-z0-9]{60}\.[a-z0-9]{22}`),
|
Regex: generateSemiGenericRegex([]string{"mapbox"}, `pk\.[a-z0-9]{60}\.[a-z0-9]{22}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"mapbox"},
|
Keywords: []string{"mapbox"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func MattermostAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "mattermost-access-token",
|
RuleID: "mattermost-access-token",
|
||||||
Description: "Mattermost Access Token",
|
Description: "Mattermost Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"mattermost"}, alphaNumeric("26")),
|
Regex: generateSemiGenericRegex([]string{"mattermost"}, alphaNumeric("26"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"mattermost",
|
"mattermost",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ func MessageBirdAPIToken() *config.Rule {
|
|||||||
"messagebird",
|
"messagebird",
|
||||||
"message-bird",
|
"message-bird",
|
||||||
"message_bird",
|
"message_bird",
|
||||||
}, alphaNumeric("25")),
|
}, alphaNumeric("25"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"messagebird",
|
"messagebird",
|
||||||
"message-bird",
|
"message-bird",
|
||||||
@@ -41,8 +41,8 @@ func MessageBirdClientID() *config.Rule {
|
|||||||
"messagebird",
|
"messagebird",
|
||||||
"message-bird",
|
"message-bird",
|
||||||
"message_bird",
|
"message_bird",
|
||||||
}, hex8_4_4_4_12()),
|
}, hex8_4_4_4_12(), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"messagebird",
|
"messagebird",
|
||||||
"message-bird",
|
"message-bird",
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ func NetlifyAccessToken() *config.Rule {
|
|||||||
RuleID: "netlify-access-token",
|
RuleID: "netlify-access-token",
|
||||||
Description: "Netlify Access Token",
|
Description: "Netlify Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"netlify"},
|
Regex: generateSemiGenericRegex([]string{"netlify"},
|
||||||
alphaNumericExtended("40,46")),
|
alphaNumericExtended("40,46"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"netlify",
|
"netlify",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ func NewRelicUserID() *config.Rule {
|
|||||||
"new-relic",
|
"new-relic",
|
||||||
"newrelic",
|
"newrelic",
|
||||||
"new_relic",
|
"new_relic",
|
||||||
}, `NRAK-[a-z0-9]{27}`),
|
}, `NRAK-[a-z0-9]{27}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"NRAK",
|
"NRAK",
|
||||||
},
|
},
|
||||||
@@ -37,8 +37,8 @@ func NewRelicUserKey() *config.Rule {
|
|||||||
"new-relic",
|
"new-relic",
|
||||||
"newrelic",
|
"newrelic",
|
||||||
"new_relic",
|
"new_relic",
|
||||||
}, alphaNumeric("64")),
|
}, alphaNumeric("64"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"new-relic",
|
"new-relic",
|
||||||
"newrelic",
|
"newrelic",
|
||||||
@@ -62,8 +62,8 @@ func NewRelicBrowserAPIKey() *config.Rule {
|
|||||||
"new-relic",
|
"new-relic",
|
||||||
"newrelic",
|
"newrelic",
|
||||||
"new_relic",
|
"new_relic",
|
||||||
}, `NRJS-[a-f0-9]{19}`),
|
}, `NRJS-[a-f0-9]{19}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"NRJS-",
|
"NRJS-",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func NPM() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "npm-access-token",
|
RuleID: "npm-access-token",
|
||||||
Description: "npm access token",
|
Description: "npm access token",
|
||||||
Regex: generateUniqueTokenRegex(`npm_[a-z0-9]{36}`),
|
Regex: generateUniqueTokenRegex(`npm_[a-z0-9]{36}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"npm_",
|
"npm_",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ func NytimesAccessToken() *config.Rule {
|
|||||||
Description: "Nytimes Access Token",
|
Description: "Nytimes Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{
|
Regex: generateSemiGenericRegex([]string{
|
||||||
"nytimes", "new-york-times,", "newyorktimes"},
|
"nytimes", "new-york-times,", "newyorktimes"},
|
||||||
alphaNumericExtended("32")),
|
alphaNumericExtended("32"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"nytimes",
|
"nytimes",
|
||||||
"new-york-times",
|
"new-york-times",
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ func OktaAccessToken() *config.Rule {
|
|||||||
RuleID: "okta-access-token",
|
RuleID: "okta-access-token",
|
||||||
Description: "Okta Access Token",
|
Description: "Okta Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"okta"},
|
Regex: generateSemiGenericRegex([]string{"okta"},
|
||||||
alphaNumericExtended("42")),
|
alphaNumericExtended("42"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"okta",
|
"okta",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func OpenAI() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "openai-api-key",
|
RuleID: "openai-api-key",
|
||||||
Description: "OpenAI API Key",
|
Description: "OpenAI API Key",
|
||||||
Regex: generateUniqueTokenRegex(`sk-[a-zA-Z0-9]{20}T3BlbkFJ[a-zA-Z0-9]{20}`),
|
Regex: generateUniqueTokenRegex(`sk-[a-zA-Z0-9]{20}T3BlbkFJ[a-zA-Z0-9]{20}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"T3BlbkFJ",
|
"T3BlbkFJ",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,8 +12,9 @@ func PlaidAccessID() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "plaid-client-id",
|
RuleID: "plaid-client-id",
|
||||||
Description: "Plaid Client ID",
|
Description: "Plaid Client ID",
|
||||||
Regex: generateSemiGenericRegex([]string{"plaid"}, alphaNumeric("24")),
|
Regex: generateSemiGenericRegex([]string{"plaid"}, alphaNumeric("24"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
|
Entropy: 3.5,
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"plaid",
|
"plaid",
|
||||||
},
|
},
|
||||||
@@ -31,8 +32,9 @@ func PlaidSecretKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "plaid-secret-key",
|
RuleID: "plaid-secret-key",
|
||||||
Description: "Plaid Secret key",
|
Description: "Plaid Secret key",
|
||||||
Regex: generateSemiGenericRegex([]string{"plaid"}, alphaNumeric("30")),
|
Regex: generateSemiGenericRegex([]string{"plaid"}, alphaNumeric("30"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
|
Entropy: 3.5,
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"plaid",
|
"plaid",
|
||||||
},
|
},
|
||||||
@@ -51,8 +53,8 @@ func PlaidAccessToken() *config.Rule {
|
|||||||
RuleID: "plaid-api-token",
|
RuleID: "plaid-api-token",
|
||||||
Description: "Plaid API Token",
|
Description: "Plaid API Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"plaid"},
|
Regex: generateSemiGenericRegex([]string{"plaid"},
|
||||||
fmt.Sprintf("access-(?:sandbox|development|production)-%s", hex8_4_4_4_12())),
|
fmt.Sprintf("access-(?:sandbox|development|production)-%s", hex8_4_4_4_12()), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"plaid",
|
"plaid",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func PlanetScalePassword() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "planetscale-password",
|
RuleID: "planetscale-password",
|
||||||
Description: "PlanetScale password",
|
Description: "PlanetScale password",
|
||||||
Regex: generateUniqueTokenRegex(`pscale_pw_(?i)[a-z0-9=\-_\.]{32,64}`),
|
Regex: generateUniqueTokenRegex(`pscale_pw_(?i)[a-z0-9=\-_\.]{32,64}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"pscale_pw_",
|
"pscale_pw_",
|
||||||
},
|
},
|
||||||
@@ -31,8 +31,8 @@ func PlanetScaleAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "planetscale-api-token",
|
RuleID: "planetscale-api-token",
|
||||||
Description: "PlanetScale API token",
|
Description: "PlanetScale API token",
|
||||||
Regex: generateUniqueTokenRegex(`pscale_tkn_(?i)[a-z0-9=\-_\.]{32,64}`),
|
Regex: generateUniqueTokenRegex(`pscale_tkn_(?i)[a-z0-9=\-_\.]{32,64}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"pscale_tkn_",
|
"pscale_tkn_",
|
||||||
},
|
},
|
||||||
@@ -52,8 +52,8 @@ func PlanetScaleOAuthToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "planetscale-oauth-token",
|
RuleID: "planetscale-oauth-token",
|
||||||
Description: "PlanetScale OAuth token",
|
Description: "PlanetScale OAuth token",
|
||||||
Regex: generateUniqueTokenRegex(`pscale_oauth_(?i)[a-z0-9=\-_\.]{32,64}`),
|
Regex: generateUniqueTokenRegex(`pscale_oauth_(?i)[a-z0-9=\-_\.]{32,64}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"pscale_oauth_",
|
"pscale_oauth_",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func PostManAPI() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "postman-api-token",
|
RuleID: "postman-api-token",
|
||||||
Description: "Postman API token",
|
Description: "Postman API token",
|
||||||
Regex: generateUniqueTokenRegex(`PMAK-(?i)[a-f0-9]{24}\-[a-f0-9]{34}`),
|
Regex: generateUniqueTokenRegex(`PMAK-(?i)[a-f0-9]{24}\-[a-f0-9]{34}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"PMAK-",
|
"PMAK-",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func Prefect() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "prefect-api-token",
|
RuleID: "prefect-api-token",
|
||||||
Description: "Prefect API token",
|
Description: "Prefect API token",
|
||||||
Regex: generateUniqueTokenRegex(`pnu_[a-z0-9]{36}`),
|
Regex: generateUniqueTokenRegex(`pnu_[a-z0-9]{36}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"pnu_",
|
"pnu_",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func PulumiAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "pulumi-api-token",
|
RuleID: "pulumi-api-token",
|
||||||
Description: "Pulumi API token",
|
Description: "Pulumi API token",
|
||||||
Regex: generateUniqueTokenRegex(`pul-[a-f0-9]{40}`),
|
Regex: generateUniqueTokenRegex(`pul-[a-f0-9]{40}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"pul-",
|
"pul-",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ func RapidAPIAccessToken() *config.Rule {
|
|||||||
RuleID: "rapidapi-access-token",
|
RuleID: "rapidapi-access-token",
|
||||||
Description: "RapidAPI Access Token",
|
Description: "RapidAPI Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"rapidapi"},
|
Regex: generateSemiGenericRegex([]string{"rapidapi"},
|
||||||
alphaNumericExtendedShort("50")),
|
alphaNumericExtendedShort("50"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"rapidapi",
|
"rapidapi",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func ReadMe() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "readme-api-token",
|
RuleID: "readme-api-token",
|
||||||
Description: "Readme API token",
|
Description: "Readme API token",
|
||||||
Regex: generateUniqueTokenRegex(`rdme_[a-z0-9]{70}`),
|
Regex: generateUniqueTokenRegex(`rdme_[a-z0-9]{70}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"rdme_",
|
"rdme_",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func RubyGemsAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "rubygems-api-token",
|
RuleID: "rubygems-api-token",
|
||||||
Description: "Rubygem API token",
|
Description: "Rubygem API token",
|
||||||
Regex: generateUniqueTokenRegex(`rubygems_[a-f0-9]{48}`),
|
Regex: generateUniqueTokenRegex(`rubygems_[a-f0-9]{48}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"rubygems_",
|
"rubygems_",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ const (
|
|||||||
caseInsensitive = `(?i)`
|
caseInsensitive = `(?i)`
|
||||||
|
|
||||||
// identifier prefix (just an ignore group)
|
// identifier prefix (just an ignore group)
|
||||||
identifierPrefix = `(?:`
|
identifierCaseInsensitivePrefix = `(?i:`
|
||||||
identifierSuffix = `)(?:[0-9a-z\-_\t .]{0,20})(?:[\s|']|[\s|"]){0,3}`
|
identifierCaseInsensitiveSuffix = `)`
|
||||||
|
identifierPrefix = `(?:`
|
||||||
|
identifierSuffix = `)(?:[0-9a-z\-_\t .]{0,20})(?:[\s|']|[\s|"]){0,3}`
|
||||||
|
|
||||||
// commonly used assignment operators or function call
|
// commonly used assignment operators or function call
|
||||||
operator = `(?:=|>|:{1,3}=|\|\|:|<=|=>|:|\?=)`
|
operator = `(?:=|>|:{1,3}=|\|\|:|<=|=>|:|\?=)`
|
||||||
@@ -28,12 +30,18 @@ const (
|
|||||||
secretSuffix = `)(?:['|\"|\n|\r|\s|\x60|;]|$)`
|
secretSuffix = `)(?:['|\"|\n|\r|\s|\x60|;]|$)`
|
||||||
)
|
)
|
||||||
|
|
||||||
func generateSemiGenericRegex(identifiers []string, secretRegex string) *regexp.Regexp {
|
func generateSemiGenericRegex(identifiers []string, secretRegex string, isCaseInsensitive bool) *regexp.Regexp {
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
sb.WriteString(caseInsensitive)
|
// The identifiers should always be case-insensitive.
|
||||||
sb.WriteString(identifierPrefix)
|
// This is inelegant but prevents an extraneous `(?i:)` from being added to the pattern; it could be removed.
|
||||||
sb.WriteString(strings.Join(identifiers, "|"))
|
if isCaseInsensitive {
|
||||||
sb.WriteString(identifierSuffix)
|
sb.WriteString(caseInsensitive)
|
||||||
|
writeIdentifiers(&sb, identifiers)
|
||||||
|
} else {
|
||||||
|
sb.WriteString(identifierCaseInsensitivePrefix)
|
||||||
|
writeIdentifiers(&sb, identifiers)
|
||||||
|
sb.WriteString(identifierCaseInsensitiveSuffix)
|
||||||
|
}
|
||||||
sb.WriteString(operator)
|
sb.WriteString(operator)
|
||||||
sb.WriteString(secretPrefix)
|
sb.WriteString(secretPrefix)
|
||||||
sb.WriteString(secretRegex)
|
sb.WriteString(secretRegex)
|
||||||
@@ -41,9 +49,17 @@ func generateSemiGenericRegex(identifiers []string, secretRegex string) *regexp.
|
|||||||
return regexp.MustCompile(sb.String())
|
return regexp.MustCompile(sb.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateUniqueTokenRegex(secretRegex string) *regexp.Regexp {
|
func writeIdentifiers(sb *strings.Builder, identifiers []string) {
|
||||||
|
sb.WriteString(identifierPrefix)
|
||||||
|
sb.WriteString(strings.Join(identifiers, "|"))
|
||||||
|
sb.WriteString(identifierSuffix)
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateUniqueTokenRegex(secretRegex string, isCaseInsensitive bool) *regexp.Regexp {
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
sb.WriteString(caseInsensitive)
|
if isCaseInsensitive {
|
||||||
|
sb.WriteString(caseInsensitive)
|
||||||
|
}
|
||||||
sb.WriteString(secretPrefixUnique)
|
sb.WriteString(secretPrefixUnique)
|
||||||
sb.WriteString(secretRegex)
|
sb.WriteString(secretRegex)
|
||||||
sb.WriteString(secretSuffix)
|
sb.WriteString(secretSuffix)
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ScalingoAPIToken() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "Scalingo API token",
|
||||||
|
RuleID: "scalingo-api-token",
|
||||||
|
Regex: regexp.MustCompile(`\btk-us-[a-zA-Z0-9-_]{48}\b`),
|
||||||
|
Keywords: []string{"tk-us-"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
generateSampleSecret("scalingo", "tk-us-"+secrets.NewSecret(alphaNumericExtendedShort("48"))),
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
@@ -10,8 +10,8 @@ func SendbirdAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "sendbird-access-token",
|
RuleID: "sendbird-access-token",
|
||||||
Description: "Sendbird Access Token",
|
Description: "Sendbird Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"sendbird"}, hex("40")),
|
Regex: generateSemiGenericRegex([]string{"sendbird"}, hex("40"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"sendbird",
|
"sendbird",
|
||||||
},
|
},
|
||||||
@@ -29,8 +29,8 @@ func SendbirdAccessID() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "sendbird-access-id",
|
RuleID: "sendbird-access-id",
|
||||||
Description: "Sendbird Access ID",
|
Description: "Sendbird Access ID",
|
||||||
Regex: generateSemiGenericRegex([]string{"sendbird"}, hex8_4_4_4_12()),
|
Regex: generateSemiGenericRegex([]string{"sendbird"}, hex8_4_4_4_12(), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"sendbird",
|
"sendbird",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func SendGridAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "sendgrid-api-token",
|
RuleID: "sendgrid-api-token",
|
||||||
Description: "SendGrid API token",
|
Description: "SendGrid API token",
|
||||||
Regex: generateUniqueTokenRegex(`SG\.(?i)[a-z0-9=_\-\.]{66}`),
|
Regex: generateUniqueTokenRegex(`SG\.(?i)[a-z0-9=_\-\.]{66}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"SG.",
|
"SG.",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func SendInBlueAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "sendinblue-api-token",
|
RuleID: "sendinblue-api-token",
|
||||||
Description: "Sendinblue API token",
|
Description: "Sendinblue API token",
|
||||||
Regex: generateUniqueTokenRegex(`xkeysib-[a-f0-9]{64}\-(?i)[a-z0-9]{16}`),
|
Regex: generateUniqueTokenRegex(`xkeysib-[a-f0-9]{64}\-(?i)[a-z0-9]{16}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"xkeysib-",
|
"xkeysib-",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func SentryAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "sentry-access-token",
|
RuleID: "sentry-access-token",
|
||||||
Description: "Sentry Access Token",
|
Description: "Sentry Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"sentry"}, hex("64")),
|
Regex: generateSemiGenericRegex([]string{"sentry"}, hex("64"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"sentry",
|
"sentry",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func ShippoAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "shippo-api-token",
|
RuleID: "shippo-api-token",
|
||||||
Description: "Shippo API token",
|
Description: "Shippo API token",
|
||||||
Regex: generateUniqueTokenRegex(`shippo_(live|test)_[a-f0-9]{40}`),
|
Regex: generateUniqueTokenRegex(`shippo_(live|test)_[a-f0-9]{40}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"shippo_",
|
"shippo_",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ func SidekiqSecret() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Sidekiq Secret",
|
Description: "Sidekiq Secret",
|
||||||
RuleID: "sidekiq-secret",
|
RuleID: "sidekiq-secret",
|
||||||
SecretGroup: 1,
|
|
||||||
Regex: generateSemiGenericRegex([]string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"},
|
Regex: generateSemiGenericRegex([]string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"},
|
||||||
`[a-f0-9]{8}:[a-f0-9]{8}`),
|
`[a-f0-9]{8}:[a-f0-9]{8}`, true),
|
||||||
Keywords: []string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"},
|
Keywords: []string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,25 +5,35 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Snyk() *config.Rule {
|
func Snyk() *config.Rule {
|
||||||
|
|
||||||
|
keywords := []string{
|
||||||
|
"snyk_token",
|
||||||
|
"snyk_key",
|
||||||
|
"snyk_api_token",
|
||||||
|
"snyk_api_key",
|
||||||
|
"snyk_oauth_token",
|
||||||
|
}
|
||||||
|
|
||||||
// define rule
|
// define rule
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Snyk API token",
|
Description: "Snyk API token",
|
||||||
RuleID: "snyk-api-token",
|
RuleID: "snyk-api-token",
|
||||||
SecretGroup: 1,
|
|
||||||
Regex: generateSemiGenericRegex([]string{"snyk"}, hex8_4_4_4_12()),
|
Regex: generateSemiGenericRegex(keywords, hex8_4_4_4_12(), true),
|
||||||
Keywords: []string{"snyk"},
|
Keywords: keywords,
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := []string{
|
||||||
`const SNYK_TOKEN = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
`const SNYK_TOKEN = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||||
`const SNYK_KEY = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
`const SNYK_KEY = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||||
`const SNYK = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
|
||||||
`SNYK = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
|
||||||
`SNYK_TOKEN := "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
`SNYK_TOKEN := "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||||
`SNYK_TOKEN ::= "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
`SNYK_TOKEN ::= "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||||
`SNYK_TOKEN :::= "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
`SNYK_TOKEN :::= "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||||
`SNYK_TOKEN ?= "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
`SNYK_TOKEN ?= "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||||
|
`SNYK_API_KEY ?= "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||||
|
`SNYK_API_TOKEN = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||||
|
`SNYK_OAUTH_TOKEN = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||||
}
|
}
|
||||||
return validate(r, tps, nil)
|
return validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ func SquareAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "square-access-token",
|
RuleID: "square-access-token",
|
||||||
Description: "Square Access Token",
|
Description: "Square Access Token",
|
||||||
Regex: generateUniqueTokenRegex(`sq0atp-[0-9A-Za-z\-_]{22}`),
|
Regex: generateUniqueTokenRegex(`sq0atp-[0-9A-Za-z\-_]{22}`, true),
|
||||||
Keywords: []string{"sq0atp-"},
|
Keywords: []string{"sq0atp-"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ func SquareSecret() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "square-secret",
|
RuleID: "square-secret",
|
||||||
Description: "Square Secret",
|
Description: "Square Secret",
|
||||||
Regex: generateUniqueTokenRegex(`sq0csp-[0-9A-Za-z\\-_]{43}`),
|
Regex: generateUniqueTokenRegex(`sq0csp-[0-9A-Za-z\\-_]{43}`, true),
|
||||||
Keywords: []string{"sq0csp-"},
|
Keywords: []string{"sq0csp-"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func SquareSpaceAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "squarespace-access-token",
|
RuleID: "squarespace-access-token",
|
||||||
Description: "Squarespace Access Token",
|
Description: "Squarespace Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"squarespace"}, hex8_4_4_4_12()),
|
Regex: generateSemiGenericRegex([]string{"squarespace"}, hex8_4_4_4_12(), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"squarespace",
|
"squarespace",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
@@ -12,7 +10,7 @@ func StripeAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Stripe Access Token",
|
Description: "Stripe Access Token",
|
||||||
RuleID: "stripe-access-token",
|
RuleID: "stripe-access-token",
|
||||||
Regex: regexp.MustCompile(`(?i)(sk|pk)_(test|live)_[0-9a-z]{10,32}`),
|
Regex: generateUniqueTokenRegex(`(sk|pk)_(test|live)_[0-9a-z]{10,32}`, true),
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"sk_test",
|
"sk_test",
|
||||||
"pk_test",
|
"pk_test",
|
||||||
@@ -23,5 +21,6 @@ func StripeAccessToken() *config.Rule {
|
|||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{"stripeToken := \"sk_test_" + secrets.NewSecret(alphaNumeric("30")) + "\""}
|
tps := []string{"stripeToken := \"sk_test_" + secrets.NewSecret(alphaNumeric("30")) + "\""}
|
||||||
return validate(r, tps, nil)
|
fps := []string{"nonMatchingToken := \"task_test_" + secrets.NewSecret(alphaNumeric("30")) + "\""}
|
||||||
|
return validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
@@ -10,19 +12,42 @@ func SumoLogicAccessID() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "sumologic-access-id",
|
RuleID: "sumologic-access-id",
|
||||||
Description: "SumoLogic Access ID",
|
Description: "SumoLogic Access ID",
|
||||||
|
// TODO: Make 'su' case-sensitive.
|
||||||
Regex: generateSemiGenericRegex([]string{"sumo"},
|
Regex: generateSemiGenericRegex([]string{"sumo"},
|
||||||
alphaNumeric("14")),
|
"su[a-zA-Z0-9]{12}", false),
|
||||||
SecretGroup: 1,
|
|
||||||
|
Entropy: 3,
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"sumo",
|
"sumo",
|
||||||
},
|
},
|
||||||
|
Allowlist: config.Allowlist{
|
||||||
|
RegexTarget: "line",
|
||||||
|
Regexes: []*regexp.Regexp{
|
||||||
|
regexp.MustCompile(`sumOf`),
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := []string{
|
||||||
generateSampleSecret("sumo", secrets.NewSecret(alphaNumeric("14"))),
|
`sumologic.accessId = "su9OL59biWiJu7"`, // gitleaks:allow
|
||||||
|
`sumologic_access_id = "sug5XpdpaoxtOH"`, // gitleaks:allow
|
||||||
|
`export SUMOLOGIC_ACCESSID="suDbJw97o9WVo0"`, // gitleaks:allow
|
||||||
|
`SUMO_ACCESS_ID = "suGyI5imvADdvU"`, // gitleaks:allow
|
||||||
|
generateSampleSecret("sumo", "su"+secrets.NewSecret(alphaNumeric("12"))),
|
||||||
}
|
}
|
||||||
return validate(r, tps, nil)
|
fps := []string{
|
||||||
|
`- (NSNumber *)sumOfProperty:(NSString *)property;`,
|
||||||
|
`- (NSInteger)sumOfValuesInRange:(NSRange)range;`,
|
||||||
|
`+ (unsigned char)byteChecksumOfData:(id)arg1;`,
|
||||||
|
`sumOfExposures = sumOfExposures;`, // gitleaks:allow
|
||||||
|
`.si-sumologic.si--color::before { color: #000099; }`,
|
||||||
|
`/// Based on the SumoLogic keyword syntax:`,
|
||||||
|
`sumologic_access_id = ""`,
|
||||||
|
`SUMOLOGIC_ACCESSID: ${SUMOLOGIC_ACCESSID}`,
|
||||||
|
`export SUMOLOGIC_ACCESSID=XXXXXXXXXXXXXX`, // gitleaks:allow
|
||||||
|
}
|
||||||
|
return validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SumoLogicAccessToken() *config.Rule {
|
func SumoLogicAccessToken() *config.Rule {
|
||||||
@@ -31,8 +56,9 @@ func SumoLogicAccessToken() *config.Rule {
|
|||||||
RuleID: "sumologic-access-token",
|
RuleID: "sumologic-access-token",
|
||||||
Description: "SumoLogic Access Token",
|
Description: "SumoLogic Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"sumo"},
|
Regex: generateSemiGenericRegex([]string{"sumo"},
|
||||||
alphaNumeric("64")),
|
alphaNumeric("64"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
|
Entropy: 3,
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"sumo",
|
"sumo",
|
||||||
},
|
},
|
||||||
@@ -40,7 +66,19 @@ func SumoLogicAccessToken() *config.Rule {
|
|||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := []string{
|
||||||
|
`export SUMOLOGIC_ACCESSKEY="3HSa1hQfz6BYzlxf7Yb1WKG3Hyovm56LMFChV2y9LgkRipsXCujcLb5ej3oQUJlx"`, // gitleaks:allow
|
||||||
|
`SUMO_ACCESS_KEY: gxq3rJQkS6qovOg9UY2Q70iH1jFZx0WBrrsiAYv4XHodogAwTKyLzvFK4neRN8Dk`, // gitleaks:allow
|
||||||
|
`SUMOLOGIC_ACCESSKEY: 9RITWb3I3kAnSyUolcVJq4gwM17JRnQK8ugRaixFfxkdSl8ys17ZtEL3LotESKB7`, // gitleaks:allow
|
||||||
|
`sumo_access_key = "3Kof2VffNQ0QgYIhXUPJosVlCaQKm2hfpWE6F1fT9YGY74blQBIPsrkCcf1TwKE5"`, // gitleaks:allow
|
||||||
generateSampleSecret("sumo", secrets.NewSecret(alphaNumeric("64"))),
|
generateSampleSecret("sumo", secrets.NewSecret(alphaNumeric("64"))),
|
||||||
}
|
}
|
||||||
return validate(r, tps, nil)
|
fps := []string{
|
||||||
|
`# SUMO_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`, // gitleaks:allow
|
||||||
|
"-e SUMO_ACCESS_KEY=`etcdctl get /sumologic_secret`",
|
||||||
|
`SUMO_ACCESS_KEY={SumoAccessKey}`,
|
||||||
|
`SUMO_ACCESS_KEY=${SUMO_ACCESS_KEY:=$2}`,
|
||||||
|
`sumo_access_key = "<SUMOLOGIC ACCESS KEY>"`,
|
||||||
|
`SUMO_ACCESS_KEY: AbCeFG123`,
|
||||||
|
}
|
||||||
|
return validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
@@ -12,8 +12,8 @@ func TelegramBotToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Telegram Bot API Token",
|
Description: "Telegram Bot API Token",
|
||||||
RuleID: "telegram-bot-api-token",
|
RuleID: "telegram-bot-api-token",
|
||||||
SecretGroup: 1,
|
|
||||||
Regex: regexp.MustCompile(`(?i)(?:^|[^0-9])([0-9]{5,16}:A[a-zA-Z0-9_\-]{34})(?:$|[^a-zA-Z0-9_\-])`),
|
Regex: regexp.MustCompile(`(?i)(?:^|[^0-9])([0-9]{5,16}:A[a-zA-Z0-9_\-]{34})(?:$|[^a-zA-Z0-9_\-])`),
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"telegram",
|
"telegram",
|
||||||
"api",
|
"api",
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func TravisCIAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "travisci-access-token",
|
RuleID: "travisci-access-token",
|
||||||
Description: "Travis CI Access Token",
|
Description: "Travis CI Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"travis"}, alphaNumeric("22")),
|
Regex: generateSemiGenericRegex([]string{"travis"}, alphaNumeric("22"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"travis",
|
"travis",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ func TrelloAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "trello-access-token",
|
RuleID: "trello-access-token",
|
||||||
Description: "Trello Access Token",
|
Description: "Trello Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"trello"}, `[a-zA-Z-0-9]{32}`),
|
Regex: generateSemiGenericRegex([]string{"trello"}, `[a-zA-Z-0-9]{32}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"trello",
|
"trello",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ func TwitchAPIToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "twitch-api-token",
|
RuleID: "twitch-api-token",
|
||||||
Description: "Twitch API token",
|
Description: "Twitch API token",
|
||||||
Regex: generateSemiGenericRegex([]string{"twitch"}, alphaNumeric("30")),
|
Regex: generateSemiGenericRegex([]string{"twitch"}, alphaNumeric("30"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"twitch",
|
"twitch",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ func TwitterAPIKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Twitter API Key",
|
Description: "Twitter API Key",
|
||||||
RuleID: "twitter-api-key",
|
RuleID: "twitter-api-key",
|
||||||
Regex: generateSemiGenericRegex([]string{"twitter"}, alphaNumeric("25")),
|
Regex: generateSemiGenericRegex([]string{"twitter"}, alphaNumeric("25"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"twitter"},
|
Keywords: []string{"twitter"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,8 +26,7 @@ func TwitterAPISecret() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Twitter API Secret",
|
Description: "Twitter API Secret",
|
||||||
RuleID: "twitter-api-secret",
|
RuleID: "twitter-api-secret",
|
||||||
Regex: generateSemiGenericRegex([]string{"twitter"}, alphaNumeric("50")),
|
Regex: generateSemiGenericRegex([]string{"twitter"}, alphaNumeric("50"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"twitter"},
|
Keywords: []string{"twitter"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,9 +42,9 @@ func TwitterBearerToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Twitter Bearer Token",
|
Description: "Twitter Bearer Token",
|
||||||
RuleID: "twitter-bearer-token",
|
RuleID: "twitter-bearer-token",
|
||||||
Regex: generateSemiGenericRegex([]string{"twitter"}, "A{22}[a-zA-Z0-9%]{80,100}"),
|
Regex: generateSemiGenericRegex([]string{"twitter"}, "A{22}[a-zA-Z0-9%]{80,100}", true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"twitter"},
|
Keywords: []string{"twitter"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
@@ -61,8 +59,7 @@ func TwitterAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Twitter Access Token",
|
Description: "Twitter Access Token",
|
||||||
RuleID: "twitter-access-token",
|
RuleID: "twitter-access-token",
|
||||||
Regex: generateSemiGenericRegex([]string{"twitter"}, "[0-9]{15,25}-[a-zA-Z0-9]{20,40}"),
|
Regex: generateSemiGenericRegex([]string{"twitter"}, "[0-9]{15,25}-[a-zA-Z0-9]{20,40}", true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"twitter"},
|
Keywords: []string{"twitter"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,8 +75,7 @@ func TwitterAccessSecret() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Twitter Access Secret",
|
Description: "Twitter Access Secret",
|
||||||
RuleID: "twitter-access-secret",
|
RuleID: "twitter-access-secret",
|
||||||
Regex: generateSemiGenericRegex([]string{"twitter"}, alphaNumeric("45")),
|
Regex: generateSemiGenericRegex([]string{"twitter"}, alphaNumeric("45"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{"twitter"},
|
Keywords: []string{"twitter"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ func Typeform() *config.Rule {
|
|||||||
RuleID: "typeform-api-token",
|
RuleID: "typeform-api-token",
|
||||||
Description: "Typeform API token",
|
Description: "Typeform API token",
|
||||||
Regex: generateSemiGenericRegex([]string{"typeform"},
|
Regex: generateSemiGenericRegex([]string{"typeform"},
|
||||||
`tfp_[a-z0-9\-_\.=]{59}`),
|
`tfp_[a-z0-9\-_\.=]{59}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"tfp_",
|
"tfp_",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ func VaultServiceToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Vault Service Token",
|
Description: "Vault Service Token",
|
||||||
RuleID: "vault-service-token",
|
RuleID: "vault-service-token",
|
||||||
Regex: generateUniqueTokenRegex(`hvs\.[a-z0-9_-]{90,100}`),
|
Regex: generateUniqueTokenRegex(`hvs\.[a-z0-9_-]{90,100}`, true),
|
||||||
Keywords: []string{"hvs"},
|
Keywords: []string{"hvs"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ func VaultBatchToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Vault Batch Token",
|
Description: "Vault Batch Token",
|
||||||
RuleID: "vault-batch-token",
|
RuleID: "vault-batch-token",
|
||||||
Regex: generateUniqueTokenRegex(`hvb\.[a-z0-9_-]{138,212}`),
|
Regex: generateUniqueTokenRegex(`hvb\.[a-z0-9_-]{138,212}`, true),
|
||||||
Keywords: []string{"hvb"},
|
Keywords: []string{"hvb"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ func YandexAWSAccessToken() *config.Rule {
|
|||||||
RuleID: "yandex-aws-access-token",
|
RuleID: "yandex-aws-access-token",
|
||||||
Description: "Yandex AWS Access Token",
|
Description: "Yandex AWS Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"yandex"},
|
Regex: generateSemiGenericRegex([]string{"yandex"},
|
||||||
`YC[a-zA-Z0-9_\-]{38}`),
|
`YC[a-zA-Z0-9_\-]{38}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"yandex",
|
"yandex",
|
||||||
},
|
},
|
||||||
@@ -32,8 +31,8 @@ func YandexAPIKey() *config.Rule {
|
|||||||
RuleID: "yandex-api-key",
|
RuleID: "yandex-api-key",
|
||||||
Description: "Yandex API Key",
|
Description: "Yandex API Key",
|
||||||
Regex: generateSemiGenericRegex([]string{"yandex"},
|
Regex: generateSemiGenericRegex([]string{"yandex"},
|
||||||
`AQVN[A-Za-z0-9_\-]{35,38}`),
|
`AQVN[A-Za-z0-9_\-]{35,38}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"yandex",
|
"yandex",
|
||||||
},
|
},
|
||||||
@@ -53,8 +52,8 @@ func YandexAccessToken() *config.Rule {
|
|||||||
RuleID: "yandex-access-token",
|
RuleID: "yandex-access-token",
|
||||||
Description: "Yandex Access Token",
|
Description: "Yandex Access Token",
|
||||||
Regex: generateSemiGenericRegex([]string{"yandex"},
|
Regex: generateSemiGenericRegex([]string{"yandex"},
|
||||||
`t1\.[A-Z0-9a-z_-]+[=]{0,2}\.[A-Z0-9a-z_-]{86}[=]{0,2}`),
|
`t1\.[A-Z0-9a-z_-]+[=]{0,2}\.[A-Z0-9a-z_-]{86}[=]{0,2}`, true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"yandex",
|
"yandex",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ func ZendeskSecretKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "zendesk-secret-key",
|
RuleID: "zendesk-secret-key",
|
||||||
Description: "Zendesk Secret Key",
|
Description: "Zendesk Secret Key",
|
||||||
Regex: generateSemiGenericRegex([]string{"zendesk"}, alphaNumeric("40")),
|
Regex: generateSemiGenericRegex([]string{"zendesk"}, alphaNumeric("40"), true),
|
||||||
SecretGroup: 1,
|
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"zendesk",
|
"zendesk",
|
||||||
},
|
},
|
||||||
|
|||||||
+15
-3
@@ -5,6 +5,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
@@ -46,6 +47,17 @@ func runProtect(cmd *cobra.Command, args []string) {
|
|||||||
|
|
||||||
// Setup detector
|
// Setup detector
|
||||||
detector := detect.NewDetector(cfg)
|
detector := detect.NewDetector(cfg)
|
||||||
|
// set color flag at first
|
||||||
|
if detector.NoColor, err = cmd.Flags().GetBool("no-color"); err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("")
|
||||||
|
}
|
||||||
|
// also init logger again without color
|
||||||
|
if detector.NoColor {
|
||||||
|
log.Logger = log.Output(zerolog.ConsoleWriter{
|
||||||
|
Out: os.Stderr,
|
||||||
|
NoColor: detector.NoColor,
|
||||||
|
})
|
||||||
|
}
|
||||||
detector.Config.Path, err = cmd.Flags().GetString("config")
|
detector.Config.Path, err = cmd.Flags().GetString("config")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("")
|
log.Fatal().Err(err).Msg("")
|
||||||
@@ -64,14 +76,14 @@ func runProtect(cmd *cobra.Command, args []string) {
|
|||||||
log.Fatal().Err(err).Msg("")
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
// set redact flag
|
// set redact flag
|
||||||
if detector.Redact, err = cmd.Flags().GetBool("redact"); err != nil {
|
if detector.Redact, err = cmd.Flags().GetUint("redact"); err != nil {
|
||||||
log.Fatal().Err(err).Msg("")
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
if detector.MaxTargetMegaBytes, err = cmd.Flags().GetInt("max-target-megabytes"); err != nil {
|
if detector.MaxTargetMegaBytes, err = cmd.Flags().GetInt("max-target-megabytes"); err != nil {
|
||||||
log.Fatal().Err(err).Msg("")
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
// set color flag
|
// set ignore gitleaks:allow flag
|
||||||
if detector.NoColor, err = cmd.Flags().GetBool("no-color"); err != nil {
|
if detector.IgnoreGitleaksAllow, err = cmd.Flags().GetBool("ignore-gitleaks-allow"); err != nil {
|
||||||
log.Fatal().Err(err).Msg("")
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -47,7 +47,9 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "show verbose output from scan")
|
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "show verbose output from scan")
|
||||||
rootCmd.PersistentFlags().BoolP("no-color", "", false, "turn off color for verbose output")
|
rootCmd.PersistentFlags().BoolP("no-color", "", false, "turn off color for verbose output")
|
||||||
rootCmd.PersistentFlags().Int("max-target-megabytes", 0, "files larger than this will be skipped")
|
rootCmd.PersistentFlags().Int("max-target-megabytes", 0, "files larger than this will be skipped")
|
||||||
rootCmd.PersistentFlags().Bool("redact", false, "redact secrets from logs and stdout")
|
rootCmd.PersistentFlags().BoolP("ignore-gitleaks-allow", "", false, "ignore gitleaks:allow comments")
|
||||||
|
rootCmd.PersistentFlags().Uint("redact", 0, "redact secrets from logs and stdout. To redact only parts of the secret just apply a percent value from 0..100. For example --redact=20 (default 100%)")
|
||||||
|
rootCmd.Flag("redact").NoOptDefVal = "100"
|
||||||
rootCmd.PersistentFlags().Bool("no-banner", false, "suppress banner")
|
rootCmd.PersistentFlags().Bool("no-banner", false, "suppress banner")
|
||||||
err := viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
|
err := viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+8
-17
@@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
const configPath = "../testdata/config/"
|
const configPath = "../testdata/config/"
|
||||||
@@ -22,7 +23,7 @@ func TestTranslate(t *testing.T) {
|
|||||||
cfg: Config{
|
cfg: Config{
|
||||||
Rules: map[string]Rule{"aws-access-key": {
|
Rules: map[string]Rule{"aws-access-key": {
|
||||||
Description: "AWS Access Key",
|
Description: "AWS Access Key",
|
||||||
Regex: regexp.MustCompile("(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
|
Regex: regexp.MustCompile("(?:A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
|
||||||
Tags: []string{"key", "AWS"},
|
Tags: []string{"key", "AWS"},
|
||||||
Keywords: []string{},
|
Keywords: []string{},
|
||||||
RuleID: "aws-access-key",
|
RuleID: "aws-access-key",
|
||||||
@@ -40,7 +41,7 @@ func TestTranslate(t *testing.T) {
|
|||||||
cfg: Config{
|
cfg: Config{
|
||||||
Rules: map[string]Rule{"aws-access-key": {
|
Rules: map[string]Rule{"aws-access-key": {
|
||||||
Description: "AWS Access Key",
|
Description: "AWS Access Key",
|
||||||
Regex: regexp.MustCompile("(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
|
Regex: regexp.MustCompile("(?:A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
|
||||||
Tags: []string{"key", "AWS"},
|
Tags: []string{"key", "AWS"},
|
||||||
Keywords: []string{},
|
Keywords: []string{},
|
||||||
RuleID: "aws-access-key",
|
RuleID: "aws-access-key",
|
||||||
@@ -56,7 +57,7 @@ func TestTranslate(t *testing.T) {
|
|||||||
cfg: Config{
|
cfg: Config{
|
||||||
Rules: map[string]Rule{"aws-access-key": {
|
Rules: map[string]Rule{"aws-access-key": {
|
||||||
Description: "AWS Access Key",
|
Description: "AWS Access Key",
|
||||||
Regex: regexp.MustCompile("(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
|
Regex: regexp.MustCompile("(?:A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
|
||||||
Tags: []string{"key", "AWS"},
|
Tags: []string{"key", "AWS"},
|
||||||
Keywords: []string{},
|
Keywords: []string{},
|
||||||
RuleID: "aws-access-key",
|
RuleID: "aws-access-key",
|
||||||
@@ -96,7 +97,7 @@ func TestTranslate(t *testing.T) {
|
|||||||
Rules: map[string]Rule{
|
Rules: map[string]Rule{
|
||||||
"aws-access-key": {
|
"aws-access-key": {
|
||||||
Description: "AWS Access Key",
|
Description: "AWS Access Key",
|
||||||
Regex: regexp.MustCompile("(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
|
Regex: regexp.MustCompile("(?:A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
|
||||||
Tags: []string{"key", "AWS"},
|
Tags: []string{"key", "AWS"},
|
||||||
Keywords: []string{},
|
Keywords: []string{},
|
||||||
RuleID: "aws-access-key",
|
RuleID: "aws-access-key",
|
||||||
@@ -126,23 +127,13 @@ func TestTranslate(t *testing.T) {
|
|||||||
viper.SetConfigName(tt.cfgName)
|
viper.SetConfigName(tt.cfgName)
|
||||||
viper.SetConfigType("toml")
|
viper.SetConfigType("toml")
|
||||||
err := viper.ReadInConfig()
|
err := viper.ReadInConfig()
|
||||||
if err != nil {
|
require.NoError(t, err)
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var vc ViperConfig
|
var vc ViperConfig
|
||||||
err = viper.Unmarshal(&vc)
|
err = viper.Unmarshal(&vc)
|
||||||
if err != nil {
|
require.NoError(t, err)
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
cfg, err := vc.Translate()
|
cfg, err := vc.Translate()
|
||||||
if tt.wantError != nil {
|
assert.Equal(t, tt.wantError, err)
|
||||||
if err == nil {
|
|
||||||
t.Errorf("expected error")
|
|
||||||
}
|
|
||||||
assert.Equal(t, tt.wantError, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.Equal(t, cfg.Rules, tt.cfg.Rules)
|
assert.Equal(t, cfg.Rules, tt.cfg.Rules)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+247
-274
File diff suppressed because it is too large.
Load diff
Loaded 100 of 123 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user