Skip to content

Commit 749427b

Browse files
Merge pull request Yelp#25 from shamilpatel25/port-azure-storage
porting azure storage key from upstream yelp
2 parents 53b296b + ba395dc commit 749427b

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

detect_secrets/core/usage.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,12 @@ class PluginOptions:
499499
help_text='Disables scans for Square OAuth tokens.',
500500
filename='square_oauth',
501501
),
502+
PluginDescriptor(
503+
classname='AzureStorageKeyDetector',
504+
flag_text='--no-azure-storage-scan',
505+
help_text='Disables scans for Azure Storage Account access.',
506+
filename='azure_storage_key',
507+
),
502508
]
503509
opt_in_plugins = [
504510
PluginDescriptor(
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
This plugin searches for Azure Storage Account access keys.
3+
"""
4+
import re
5+
6+
from detect_secrets.plugins.base import RegexBasedDetector
7+
8+
9+
class AzureStorageKeyDetector(RegexBasedDetector):
10+
"""Scans for Azure Storage Account access keys."""
11+
secret_type = 'Azure Storage Account access key'
12+
13+
denylist = [
14+
# Account Key (AccountKey=xxxxxxxxx)
15+
re.compile(r'AccountKey=[a-zA-Z0-9+\/=]{88}'),
16+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pytest
2+
3+
from detect_secrets.plugins.azure_storage_key import AzureStorageKeyDetector
4+
5+
6+
class TestAzureStorageKeyDetector:
7+
8+
@pytest.mark.parametrize(
9+
'payload, should_flag',
10+
[
11+
(
12+
'AccountKey=lJzRc1YdHaAA2KCNJJ1tkYwF/+mKK6Ygw0NGe170Xu592euJv2wYUtBlV8z+qnlcNQSnIYVTkLWntUO1F8j8rQ==', # noqa: E501
13+
True,
14+
),
15+
],
16+
)
17+
def test_analyze(self, payload, should_flag):
18+
logic = AzureStorageKeyDetector()
19+
assert logic.analyze_line(payload, 1, 'mock_filename')

0 commit comments

Comments
 (0)