mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 04:34:46 +01:00
24 lines
510 B
Go
24 lines
510 B
Go
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-----[\s\S-]*KEY----`),
|
|
Keywords: []string{"-----BEGIN PRIVATE"},
|
|
}
|
|
|
|
// validate
|
|
tps := []string{`-----BEGIN PRIVATE KEY-----
|
|
anything
|
|
-----END PRIVATE KEY-----`} // gitleaks:allow
|
|
return validate(r, tps, nil)
|
|
}
|