Skip to content

Commit 464a0da

Browse files
committed
refac default regex
1 parent b8b47dc commit 464a0da

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/scrapy_settings_log/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ def spider_closed(self, spider):
5151
regex = settings.get("SETTINGS_LOGGING_REGEX")
5252
if regex is not None:
5353
settings = {k: v for k, v in settings.items() if re.search(regex, k)}
54-
default_regexes = [
55-
"(?i)(api[\W_]*key)", # apikey and possible variations
56-
"(?i)(AWS[\W_]*SECRET[\W_]*ACCESS[\W_]*KEY)" # AWS_SECRET_ACCESS_KEY and possible variations
57-
]
5854
if settings.get("MASKED_SENSITIVE_SETTINGS_ENABLED", True):
55+
default_regexes = [
56+
"(?i)(api[\W_]*key)", # apikey and possible variations
57+
"(?i)(AWS[\W_]*SECRET[\W_]*ACCESS[\W_]*KEY)" # AWS_SECRET_ACCESS_KEY and possible variations
58+
]
5959
regex_list = settings.get("MASKED_SENSITIVE_SETTINGS_REGEX_LIST", default_regexes)
6060
for reg in regex_list:
6161
updated_settings = {k: '*'*len(v) for k, v in settings.items() if re.match(reg, k)}

0 commit comments

Comments
 (0)