| 12345678910111213141516171819202122232425262728 |
- package rules
- import (
- "regexp"
- "github.com/zricethezav/gitleaks/v8/config"
- )
- func PrivateKey() *config.Rule {
- // define rule
- r := config.Rule{
- Description: "Private Key",
- RuleID: "private-key",
- Regex: regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY----`),
- Keywords: []string{"-----BEGIN"},
- }
- // validate
- tps := []string{`-----BEGIN PRIVATE KEY-----
- anything
- -----END PRIVATE KEY-----`,
- `-----BEGIN RSA PRIVATE KEY-----
- abcdefghijklmnopqrstuvwxyz
- -----END RSA PRIVATE KEY-----
- `,
- } // gitleaks:allow
- return validate(r, tps, nil)
- }
|