|
1 | 1 | from django.conf import settings |
2 | 2 |
|
3 | | -DEFAULT_SENSITIVE_KEYS = [ |
4 | | - "^password$", |
5 | | - ".*secret.*", |
6 | | - ".*token.*", |
7 | | - ".*key.*", |
8 | | - ".*pass.*", |
9 | | - ".*auth.*", |
10 | | - "^Bearer.*", |
11 | | - ".*ssn.*", # Social Security Number (or equivalent in some countries) |
12 | | - ".*credit.*card.*", # Credit card numbers |
13 | | - ".*cvv.*", # CVV code for credit cards |
14 | | - ".*dob.*", # Date of Birth |
15 | | - ".*pin.*", # Personal Identification Numbers |
16 | | - ".*salt.*", # Salts used in cryptography |
17 | | - ".*encrypt.*", # Encryption keys or related values |
18 | | - ".*api.*", # API keys |
19 | | - ".*jwt.*", # JSON Web Tokens |
20 | | - ".*session.*id.*", # Session Identifiers |
21 | | - "^Authorization$", # Authorization headers |
22 | | - ".*user.*name.*", # Usernames (can sometimes be used in combination with other data for malicious purposes) |
23 | | - ".*address.*", # Physical or email addresses |
24 | | - ".*phone.*", # Phone numbers |
25 | | - "^otp.*", # One-Time Passwords or related values |
26 | | -] |
27 | | - |
28 | | -DEFAULT_SENSITIVE_HEADERS = [ |
29 | | - "Authorization", # Tokens and credentials |
30 | | - "Cookie", # User session identifiers |
31 | | - "Set-Cookie", # Server set session identifiers |
32 | | - "X-API-Key", # API keys |
33 | | - "X-CSRFToken", # CSRF tokens |
34 | | - "Proxy-Authorization", # Credentials for a proxy connection |
35 | | - "If-None-Match", # Can be used for cache fingerprinting |
36 | | - "Server", # Can reveal specifics about the server |
37 | | - "WWW-Authenticate", # Authentication method details |
38 | | - "X-Correlation-ID", # Correlation IDs for logging |
39 | | - "X-Frame-Options", # Security-related header |
40 | | - "Strict-Transport-Security", # Security-related header |
41 | | - "X-XSS-Protection", # Security-related header |
42 | | - "X-Content-Type-Options", # Security-related header |
43 | | - "X-Download-Options", # Security-related header |
44 | | - "X-Permitted-Cross-Domain-Policies", # Security-related header |
45 | | -] |
| 3 | +from django_google_structured_logger.constants import DEFAULT_SENSITIVE_HEADERS, DEFAULT_SENSITIVE_KEYS |
46 | 4 |
|
47 | 5 | LOG_MAX_STR_LEN = getattr(settings, "LOG_MAX_STR_LEN", 200) |
48 | 6 | LOG_MAX_LIST_LEN = getattr(settings, "LOG_MAX_LIST_LEN", 10) |
49 | 7 | LOG_EXCLUDED_ENDPOINTS = getattr(settings, "LOG_EXCLUDED_ENDPOINTS", []) |
50 | 8 | LOG_SENSITIVE_KEYS = getattr(settings, "LOG_SENSITIVE_KEYS", DEFAULT_SENSITIVE_KEYS) |
51 | 9 | LOG_MASK_STYLE = getattr(settings, "LOG_MASK_STYLE", "partial") |
52 | 10 | LOG_MIDDLEWARE_ENABLED = getattr(settings, "LOG_MIDDLEWARE_ENABLED", True) |
53 | | -LOG_EXCLUDED_HEADERS = getattr( |
54 | | - settings, "LOG_EXCLUDED_HEADERS", DEFAULT_SENSITIVE_HEADERS |
55 | | -) |
| 11 | +LOG_EXCLUDED_HEADERS = getattr(settings, "LOG_EXCLUDED_HEADERS", DEFAULT_SENSITIVE_HEADERS) |
56 | 12 | LOG_USER_ID_FIELD = getattr(settings, "LOG_USER_ID_FIELD", "id") |
57 | 13 | LOG_USER_DISPLAY_FIELD = getattr(settings, "LOG_USER_DISPLAY_FIELD", "email") |
58 | 14 | LOG_MAX_DEPTH = getattr(settings, "LOG_MAX_DEPTH", 4) |
0 commit comments