Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Storage Key Detector plugin #359

Merged
merged 4 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions detect_secrets/plugins/azure_storage_key.py
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}'),
]
19 changes: 19 additions & 0 deletions tests/plugins/azure_storage_key_test.py
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)