Skip to content

Commit 759596d

Browse files
committed
add secret key as optional for the regex
1 parent b1774f1 commit 759596d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/scrapy_settings_log/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def spider_closed(self, spider):
5454
if spider.settings.getbool("MASKED_SENSITIVE_SETTINGS_ENABLED", True):
5555
default_regexes = [
5656
".*(?i)(api[\W_]*key).*", # apikey and possible variations e.g: shub_apikey or SC_APIKEY
57-
".*(?i)(AWS[\W_]*SECRET[\W_]*ACCESS[\W_]*KEY).*", # AWS_SECRET_ACCESS_KEY and possible variations
57+
".*(?i)(AWS[\W_]*(SECRET[\W_]*)?ACCESS[\W_]*KEY).*", # AWS_SECRET_ACCESS_KEY and possible variations
5858
".*(?i)([\W_]*password[\W_]*).*" # password word
5959
]
6060
regex_list = spider.settings.getlist("MASKED_SENSITIVE_SETTINGS_REGEX_LIST", default_regexes)

tests/test_code.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def test_log_all_should_not_return_aws_secret_key_value_by_default(caplog):
144144
"SETTINGS_LOGGING_ENABLED": True,
145145
"AWS_SECRET_ACCESS_KEY": 'secret_value1',
146146
"aws_secret_access_key": 'secret_value2',
147+
"aws_access_key": 'secret_value2',
147148
}
148149

149150
spider = MockSpider(settings)
@@ -153,6 +154,7 @@ def test_log_all_should_not_return_aws_secret_key_value_by_default(caplog):
153154

154155
assert '"AWS_SECRET_ACCESS_KEY": "**********"' in caplog.text
155156
assert '"aws_secret_access_key": "**********"' in caplog.text
157+
assert '"aws_access_key": "**********"' in caplog.text
156158
assert 'secret_value' not in caplog.text
157159

158160

0 commit comments

Comments
 (0)