mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
Decode Base64 (#1488)
* Support base64 decoding during scans rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED * Add failing tests for the case when the match starts outside the decoded value * Align locations for overlapping, encoded matches rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED * Add --max-decode-depth flag and update README help output rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED * Move keywords off of fragment rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED * Fix comment typo rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED * Refactor how keywords are used in detect rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED * Clarify comments and rename method to match rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED * Improve performance rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED * Fix issues after rebase Only adjust matchIndex to fix the following line issue when not working with encoded segments since they handle adjusting the index themselves. rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED * Update detect/decoder.go Don't escape characters that don't need escaping Co-authored-by: Richard Gomez <32133502+rgmz@users.noreply.github.com> * Update flag help text rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED * Add meta data tags from decoding rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED --------- Co-authored-by: Richard Gomez <32133502+rgmz@users.noreply.github.com>
This commit is contained in:
1 parent
c5b15c9d74
commit
2278a2a97e
8 files changed
+712
-47
No files matched your search
Vendored
+75
@@ -0,0 +1,75 @@
|
||||
# We want to be able to find this key regardless if it's b64 encoded or not
|
||||
[[rules]]
|
||||
id = 'private-key'
|
||||
description = 'Private Key'
|
||||
regex = '''(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----[\s\S-]*?-----END[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----'''
|
||||
tags = ['key', 'private']
|
||||
keywords = [
|
||||
'-----begin',
|
||||
]
|
||||
|
||||
# This exists to test what would happen if a normal rule matched something that
|
||||
# also gets decoded. We don't want to break anyone's existing rules that might
|
||||
# be looking for specific segments of b64 encoded data.
|
||||
[[rules]]
|
||||
id = 'b64-encoded-private-key'
|
||||
description = 'Private Key'
|
||||
regex = '''(?:LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0t|0tLS0tQkVHSU4gUFJJVkFURSBLRVktLS0tL|tLS0tLUJFR0lOIFBSSVZBVEUgS0VZLS0tLS)[a-zA-Z0-9+\/]+={0,3}'''
|
||||
tags = ['key', 'private']
|
||||
keywords = [
|
||||
'ls0tls1crudjtibquklwqvrfietfws0tls0t',
|
||||
'0tls0tqkvhsu4gufjjvkfursblrvktls0tl',
|
||||
'tls0tlujfr0loifbssvzbveugs0vzls0tls',
|
||||
]
|
||||
|
||||
|
||||
[[rules]]
|
||||
id = 'aws-iam-unique-identifier'
|
||||
description = 'AWS IAM Unique Identifier'
|
||||
# The funky not group at the beginning consists of ascii ranges
|
||||
regex = '''(?:^|[^!$-&\(-9<>-~])((?:A3T[A-Z0-9]|ACCA|ABIA|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16})\b'''
|
||||
tags = ['aws', 'identifier']
|
||||
entropy = 3.2
|
||||
secretGroup = 1
|
||||
keywords = [
|
||||
'a3t',
|
||||
'abia',
|
||||
'acca',
|
||||
'agpa',
|
||||
'aida',
|
||||
'aipa',
|
||||
'akia',
|
||||
'anpa',
|
||||
'anva',
|
||||
'aroa',
|
||||
'asia',
|
||||
]
|
||||
|
||||
[[rules]]
|
||||
id = 'aws-secret-access-key'
|
||||
description = 'AWS Secret Access Key'
|
||||
regex = '''(?i)aws[\w\-]{0,32}[\'\"]?\s*?[:=\(]\s*?[\'\"]?([a-z0-9\/+]{40})\b'''
|
||||
tags = ['aws', 'secret']
|
||||
entropy = 4
|
||||
secretGroup = 1
|
||||
keywords = [
|
||||
'aws',
|
||||
]
|
||||
|
||||
[[rules]]
|
||||
# Use a small one for making sure things shifting around are kept up with
|
||||
# appropriately
|
||||
id = 'small-secret'
|
||||
description = 'Small Secret'
|
||||
regex = '''\bsmall-secret\b'''
|
||||
tags = ['small', 'secret']
|
||||
|
||||
[[rules]]
|
||||
# When the example value is decoded this will overlap and this is here to
|
||||
# test that the location information is reported accurately when the match
|
||||
# goes outside the bounds of the encoded value
|
||||
id = 'overlapping'
|
||||
description = 'Overlapping'
|
||||
regex = '''secret=(decoded-secret-value)'''
|
||||
tags = ['overlapping']
|
||||
secretGroup = 1
|
||||
Reference in new issue
Block a user