Skip to content

Instantly share code, notes, and snippets.

@renatogroffe
Last active July 17, 2024 20:44
Show Gist options
  • Save renatogroffe/f0db08cee9be6bd0c0b093d0db38f4d4 to your computer and use it in GitHub Desktop.
Save renatogroffe/f0db08cee9be6bd0c0b093d0db38f4d4 to your computer and use it in GitHub Desktop.
"""
This plugin searches for SQL Server, Azure SQL and PostgreSQL connection strings.
"""
import re
from detect_secrets.plugins.base import RegexBasedDetector
class ConnectionStringDetector(RegexBasedDetector):
"""Scans for Connection Strings for SQL Server, Azure SQL and PostgreSQL."""
secret_type = 'Connection String (SQL Server, Azure SQL, PostgreSQL)'
denylist = [
re.compile(r'(Server|Data Source|Address|Addr|Network Address)=.*', re.IGNORECASE),
re.compile(r'(Initial Catalog|Database)=.*', re.IGNORECASE),
re.compile(r'(User Id|Password|Integrated Security)=.*', re.IGNORECASE),
re.compile(r'(host|serverr|port|dbname|database|user|user id|password=)=.*', re.IGNORECASE)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment