Просмотр исходного кода

Make private key check less greedy and include fifth dash (#1440)

* Make private key check less greedy and include fifth dash

* Remove trailing space
bplaxco 1 год назад
Родитель
Сommit
bf8a49fc29
2 измененных файлов с 2 добавлено и 2 удалено
  1. 1 1
      cmd/generate/config/rules/privatekey.go
  2. 1 1
      config/gitleaks.toml

+ 1 - 1
cmd/generate/config/rules/privatekey.go

@@ -12,7 +12,7 @@ func PrivateKey() *config.Rule {
 	r := config.Rule{
 		Description: "Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.",
 		RuleID:      "private-key",
-		Regex:       regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----[\s\S-]*KEY(?: BLOCK)?----`),
+		Regex:       regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----[\s\S-]*?KEY(?: BLOCK)?-----`),
 		Keywords:    []string{"-----BEGIN"},
 	}
 

+ 1 - 1
config/gitleaks.toml

@@ -2544,7 +2544,7 @@ keywords = [
 [[rules]]
 id = "private-key"
 description = "Identified a Private Key, which may compromise cryptographic security and sensitive data encryption."
-regex = '''(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----[\s\S-]*KEY(?: BLOCK)?----'''
+regex = '''(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----[\s\S-]*?KEY(?: BLOCK)?-----'''
 keywords = [
     "-----begin",
 ]