-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #359 from DariuszPorowski/master
Azure Storage Key Detector plugin
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
This plugin searches for Azure Storage Account access keys. | ||
""" | ||
import re | ||
|
||
from detect_secrets.plugins.base import RegexBasedDetector | ||
|
||
|
||
class AzureStorageKeyDetector(RegexBasedDetector): | ||
"""Scans for Azure Storage Account access keys.""" | ||
secret_type = 'Azure Storage Account access key' | ||
|
||
denylist = [ | ||
# Account Key (AccountKey=xxxxxxxxx) | ||
re.compile(r'AccountKey=[a-zA-Z0-9+\/=]{88}'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pytest | ||
|
||
from detect_secrets.plugins.azure_storage_key import AzureStorageKeyDetector | ||
|
||
|
||
class TestAzureStorageKeyDetector: | ||
|
||
@pytest.mark.parametrize( | ||
'payload, should_flag', | ||
[ | ||
( | ||
'AccountKey=lJzRc1YdHaAA2KCNJJ1tkYwF/+mKK6Ygw0NGe170Xu592euJv2wYUtBlV8z+qnlcNQSnIYVTkLWntUO1F8j8rQ==', # noqa: E501 | ||
True, | ||
), | ||
], | ||
) | ||
def test_analyze(self, payload, should_flag): | ||
logic = AzureStorageKeyDetector() | ||
assert logic.analyze_line(filename='mock_filename', line=payload) |