Skip to content

Commit

Permalink
Merge pull request #267 from EdOverflow/twilio
Browse files Browse the repository at this point in the history
Create plugin to detect Twilio API keys.
  • Loading branch information
domanchi authored Dec 2, 2019
2 parents 0de3ac2 + 798ff3f commit af887c7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ The current heuristic searches we implement out of the box include:

* **KeywordDetector**: checks to see if certain keywords are being used e.g. `password` or `secret`

* **RegexBasedDetector**: checks for any keys matching certain regular expressions (Artifactory, AWS, Slack, Stripe, Mailchimp).
* **RegexBasedDetector**: checks for any keys matching certain regular expressions (Artifactory, AWS, Slack, Stripe, Mailchimp, Twilio).

* **JwtTokenDetector**: checks for formally correct JWTs.

Expand Down
21 changes: 21 additions & 0 deletions detect_secrets/plugins/twilio.py
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}'),
]
26 changes: 26 additions & 0 deletions tests/plugins/twilio_test.py
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

0 comments on commit af887c7

Please sign in to comment.