Scans code and configuration files for SendGrid API keys using a regex pattern, suitable for secret‑scanning pipelines and CI checks.
# Source: https://github.com/Yelp/detect-secrets | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""
This plugin searches for SendGrid API keys
"""
import re
from detect_secrets.plugins.base import RegexBasedDetector
class SendGridDetector(RegexBasedDetector):
"""Scans for SendGrid API keys."""
secret_type = 'SendGrid API Key'
denylist = [
# SendGrid API key
# ref. https://d2w67tjf43xwdp.cloudfront.net/Classroom/Basics/API/what_is_my_api_key.html
re.compile(r'SG\.[a-zA-Z0-9_-]{22}\.[a-zA-Z0-9_-]{43}'),
]
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key