forked from Yelp/detect-secrets
-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathbasic_auth.py
More file actions
26 lines (20 loc) · 793 Bytes
/
basic_auth.py
File metadata and controls
26 lines (20 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import re
from .base import RegexBasedDetector
# This list is derived from RFC 3986 Section 2.2.
#
# We don't expect any of these delimiter characters to appear in
# the username/password component of the URL, seeing that this would probably
# result in an unexpected URL parsing (and probably won't even work).
RESERVED_CHARACTERS = ':/?#[]@'
SUB_DELIMITER_CHARACTERS = '!$&\'()*+,;='
class BasicAuthDetector(RegexBasedDetector):
"""Scans for Basic Auth formatted URIs."""
secret_type = 'Basic Auth Credentials'
denylist = [
re.compile(
r'://[^{}\s]+:([^{}\s]+)@'.format(
re.escape(RESERVED_CHARACTERS + SUB_DELIMITER_CHARACTERS),
re.escape(RESERVED_CHARACTERS + SUB_DELIMITER_CHARACTERS),
),
),
]