-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new rules for vault tokens (#919)
* add new rules for vault tokens * Configure max length for vault rules
- Loading branch information
1 parent
cd52267
commit b1853bd
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package rules | ||
|
||
import ( | ||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets" | ||
"github.com/zricethezav/gitleaks/v8/config" | ||
) | ||
|
||
func VaultServiceToken() *config.Rule { | ||
// define rule | ||
r := config.Rule{ | ||
Description: "Vault Service Token", | ||
RuleID: "vault-service-token", | ||
Regex: generateUniqueTokenRegex(`hvs\.[a-z0-9_-]{90,100}`), | ||
Keywords: []string{"hvs"}, | ||
} | ||
|
||
// validate | ||
tps := []string{ | ||
generateSampleSecret("vault", "hvs."+secrets.NewSecret(alphaNumericExtendedShort("90"))), | ||
} | ||
return validate(r, tps, nil) | ||
} | ||
|
||
func VaultBatchToken() *config.Rule { | ||
// define rule | ||
r := config.Rule{ | ||
Description: "Vault Batch Token", | ||
RuleID: "vault-batch-token", | ||
Regex: generateUniqueTokenRegex(`hvb\.[a-z0-9_-]{138,212}`), | ||
Keywords: []string{"hvb"}, | ||
} | ||
|
||
// validate | ||
tps := []string{ | ||
generateSampleSecret("vault", "hvb."+secrets.NewSecret(alphaNumericExtendedShort("138"))), | ||
} | ||
return validate(r, tps, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters