Skip to content

Commit bbbf827

Browse files
feat(SP-1601): rule to detect Bearer tokens (#4)
* feat(SP-1601): rule to detect Bearer tokens * add missing max
1 parent 4b2783a commit bbbf827

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

global_config.toml

+13-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ title = "Global gitleaks config"
2323
"tests"]
2424
regexes = ['''test'''] # Ignoring lines with test
2525

26+
# The following rules look for credentials with a well-known format, usually from third parties.
27+
# These rules evaluate all file types.
2628

2729
[[rules]]
2830
description = "AWS Secret Key"
@@ -144,7 +146,17 @@ title = "Global gitleaks config"
144146
regex = '''(?i)twilio(.{0,20})?SK[0-9a-f]{32}'''
145147
tags = ["key", "twilio"]
146148

147-
# The following rules check for credentials assigned to variables that its value has an entropy of more than 3 bits.
149+
[[rules]]
150+
description = "Authorization Bearer tokens"
151+
regex = '''(?i)Bearer(?:\s)+(\S{8,})'''
152+
tags = ["key", "HTTP", "bearer"]
153+
[[rules.Entropies]]
154+
Min = "3.8"
155+
Max = "7"
156+
Group = "1"
157+
158+
159+
# The following rules look for credentials assigned to variables that its value has an entropy of more than 3 bits.
148160
# To achieve this there's a regexp for each language. The regexp checks for a variable with a suspicious name followed
149161
# by a value assignation (for example, := in Go, = in JS, etc.). Then, looks for a group of non-space characters enclosed
150162
# between quotes. If that group has an entropy higher than 3 bits the rule will trigger.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"something": {
3+
"id": 1234,
4+
"cool": true,
5+
"params": {
6+
"method": "POST",
7+
"url": "https://somewhere/api/new",
8+
"headers": {
9+
"Authorization": "Bearer GHoKU9fg5aieJaR3nzjx3dcG4J52mFVCNaAnxbKHurPz"
10+
}
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)