-
Notifications
You must be signed in to change notification settings - Fork 481
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 #267 from EdOverflow/twilio
Create plugin to detect Twilio API keys.
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
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
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,21 @@ | ||
""" | ||
This plugin searches for Twilio API keys | ||
""" | ||
from __future__ import absolute_import | ||
|
||
import re | ||
|
||
from .base import RegexBasedDetector | ||
|
||
|
||
class TwilioKeyDetector(RegexBasedDetector): | ||
"""Scans for Twilio API keys.""" | ||
secret_type = 'Twilio API Key' | ||
|
||
denylist = [ | ||
# Account SID (ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) | ||
re.compile(r'AC[a-z0-9]{32}'), | ||
|
||
# Auth token (SKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) | ||
re.compile(r'SK[a-z0-9]{32}'), | ||
] |
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,26 @@ | ||
from __future__ import absolute_import | ||
|
||
import pytest | ||
|
||
from detect_secrets.plugins.twilio import TwilioKeyDetector | ||
|
||
|
||
class TestTwilioKeyDetector(object): | ||
|
||
@pytest.mark.parametrize( | ||
'payload, should_flag', | ||
[ | ||
( | ||
'SKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', | ||
True, | ||
), | ||
( | ||
'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', | ||
True, | ||
), | ||
], | ||
) | ||
def test_analyze(self, payload, should_flag): | ||
logic = TwilioKeyDetector() | ||
output = logic.analyze_line(payload, 1, 'mock_filename') | ||
assert output |