Skip to content

Commit 202106a

Browse files
authoredNov 5, 2024··
Add human readable description for curl rules (#1625)
Provides more context to the user than the base rule name.
1 parent 8e94f98 commit 202106a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed
 

‎cmd/generate/config/rules/curl.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
// https://curl.se/docs/manpage.html#-u
1212
func CurlBasicAuth() *config.Rule {
1313
r := config.Rule{
14-
RuleID: "curl-auth-user",
15-
// TODO: Description: "",
16-
Regex: regexp.MustCompile(`\bcurl\b(?:.*|.*(?:[\r\n]{1,2}.*){1,5})[ \t\n\r](?:-u|--user)(?:=|[ \t]{0,5})(?:"([^:"]{3,}:[^"]{3,})"|'([^:']{3,}:[^']{3,})'|((?:"[^"]{3,}"|'[^']{3,}'|[\w$@.-]+):(?:"[^"]{3,}"|'[^']{3,}'|[\w${}@.-]+)))(?:\s|\z)`),
17-
Keywords: []string{"curl"},
18-
Entropy: 2,
14+
RuleID: "curl-auth-user",
15+
Description: "Discovered a potential basic authorization token provided in a curl command, which could compromise the curl accessed resource.",
16+
Regex: regexp.MustCompile(`\bcurl\b(?:.*|.*(?:[\r\n]{1,2}.*){1,5})[ \t\n\r](?:-u|--user)(?:=|[ \t]{0,5})(?:"([^:"]{3,}:[^"]{3,})"|'([^:']{3,}:[^']{3,})'|((?:"[^"]{3,}"|'[^']{3,}'|[\w$@.-]+):(?:"[^"]{3,}"|'[^']{3,}'|[\w${}@.-]+)))(?:\s|\z)`),
17+
Keywords: []string{"curl"},
18+
Entropy: 2,
1919
Allowlists: []config.Allowlist{
2020
{
2121
Regexes: []*regexp.Regexp{
@@ -99,8 +99,8 @@ func CurlHeaderAuth() *config.Rule {
9999
// language=regexp
100100
authPat := `(?i)(?:Authorization:[ \t]{0,5}(?:Basic[ \t]([a-z0-9+/]{8,}={0,3})|(?:Bearer|(?:Api-)?Token)[ \t]([\w=~@.+/-]{8,})|([\w=~@.+/-]{8,}))|(?:(?:X-(?:[a-z]+-)?)?(?:Api-?)?(?:Key|Token)):[ \t]{0,5}([\w=~@.+/-]{8,}))`
101101
r := config.Rule{
102-
RuleID: "curl-auth-header",
103-
// TODO: Description: "",
102+
RuleID: "curl-auth-header",
103+
Description: "Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.",
104104
Regex: regexp.MustCompile(
105105
// language=regexp
106106
fmt.Sprintf(`\bcurl\b(?:.*?|.*?(?:[\r\n]{1,2}.*?){1,5})[ \t\n\r](?:-H|--header)(?:=|[ \t]{0,5})(?:"%s"|'%s')(?:\B|\s|\z)`, authPat, authPat)),

‎config/gitleaks.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,14 @@ keywords = ["contentful"]
280280

281281
[[rules]]
282282
id = "curl-auth-header"
283-
description = ""
283+
description = "Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource."
284284
regex = '''\bcurl\b(?:.*?|.*?(?:[\r\n]{1,2}.*?){1,5})[ \t\n\r](?:-H|--header)(?:=|[ \t]{0,5})(?:"(?i)(?:Authorization:[ \t]{0,5}(?:Basic[ \t]([a-z0-9+/]{8,}={0,3})|(?:Bearer|(?:Api-)?Token)[ \t]([\w=~@.+/-]{8,})|([\w=~@.+/-]{8,}))|(?:(?:X-(?:[a-z]+-)?)?(?:Api-?)?(?:Key|Token)):[ \t]{0,5}([\w=~@.+/-]{8,}))"|'(?i)(?:Authorization:[ \t]{0,5}(?:Basic[ \t]([a-z0-9+/]{8,}={0,3})|(?:Bearer|(?:Api-)?Token)[ \t]([\w=~@.+/-]{8,})|([\w=~@.+/-]{8,}))|(?:(?:X-(?:[a-z]+-)?)?(?:Api-?)?(?:Key|Token)):[ \t]{0,5}([\w=~@.+/-]{8,}))')(?:\B|\s|\z)'''
285285
entropy = 2.75
286286
keywords = ["curl"]
287287

288288
[[rules]]
289289
id = "curl-auth-user"
290-
description = ""
290+
description = "Discovered a potential basic authorization token provided in a curl command, which could compromise the curl accessed resource."
291291
regex = '''\bcurl\b(?:.*|.*(?:[\r\n]{1,2}.*){1,5})[ \t\n\r](?:-u|--user)(?:=|[ \t]{0,5})(?:"([^:"]{3,}:[^"]{3,})"|'([^:']{3,}:[^']{3,})'|((?:"[^"]{3,}"|'[^']{3,}'|[\w$@.-]+):(?:"[^"]{3,}"|'[^']{3,}'|[\w${}@.-]+)))(?:\s|\z)'''
292292
entropy = 2
293293
keywords = ["curl"]

0 commit comments

Comments
 (0)
Please sign in to comment.