Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev-bug - remove more sensitive data from the logs #37901

Merged
merged 21 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Packs/Base/ReleaseNotes/1_39_12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#### Scripts

##### CommonServerPython

- Logging improvements.
7 changes: 4 additions & 3 deletions Packs/Base/Scripts/CommonServerPython/CommonServerPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -8843,7 +8843,8 @@ def censor_request_logs(request_log):
:return: The censored request log
:rtype: ``str``
"""
keywords_to_censor = ['Authorization:', 'Cookie', "Token", "username", "password", "apiKey"]
keywords_to_censor = ['Authorization:', 'Cookie', "Token", "username",
"password", "Key", "identifier", "credential", "client"]
lower_keywords_to_censor = [word.lower() for word in keywords_to_censor]

trimed_request_log = request_log.lstrip(SEND_PREFIX)
Expand All @@ -8855,8 +8856,8 @@ def censor_request_logs(request_log):
if any(keyword in word.lower() for keyword in lower_keywords_to_censor):
next_word = request_log_lst[i + 1] if i + 1 < len(request_log_lst) else None
if next_word:
# If the next word is "Bearer" or "Basic" then we replace the word after it since thats the token
if next_word.lower() in ["bearer", "basic"] and i + 2 < len(request_log_lst):
# If the next word is "Bearer", "JWT" or "Basic" then we replace the word after it since thats the token
if next_word.lower() in ["bearer", "jwt", "basic"] and i + 2 < len(request_log_lst):
request_log_lst[i + 2] = MASK
elif request_log_lst[i + 1].endswith("}'"):
request_log_lst[i + 1] = "\"{}\"}}'".format(MASK)
Expand Down
18 changes: 17 additions & 1 deletion Packs/Base/Scripts/CommonServerPython/CommonServerPython_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9753,11 +9753,27 @@ def test_create_clickable_test_wrong_text_value():
"GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\nAuthorization: Bearer token123\\r\\n",
"GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\nAuthorization: Bearer <XX_REPLACED>\\r\\n"
),
(
"GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\nAuthorization: JWT token123\\r\\n",
"GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\nAuthorization: JWT <XX_REPLACED>\\r\\n"
),
(
"send: b'GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\n'",
str("send: b'GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\n'")
),
])
(
"send: b'GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\apiKey: 1234\\r\\n'",
"send: b'GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\apiKey: <XX_REPLACED>\\r\\n'"
),
(
"send: b'GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\credentials: {'good':'day'}\\r\\n'",
"send: b'GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\credentials: <XX_REPLACED>\\r\\n'"
),
(
"send: b'GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\client_name: client\\r\\n'",
"send: b'GET /api/v1/users HTTP/1.1\\r\\nHost: example.com\\r\\client_name: <XX_REPLACED>\\r\\n'"
),],
ids=["Bearer", "Cookie", "Authorization", "Bearer", "JWT", "No change", "Key", "credential", "client"],)
def test_censor_request_logs(request_log, expected_output):
"""
Given:
Expand Down
2 changes: 1 addition & 1 deletion Packs/Base/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Base",
"description": "The base pack for Cortex XSOAR.",
"support": "xsoar",
"currentVersion": "1.39.11",
"currentVersion": "1.39.12",
"author": "Cortex XSOAR",
"serverMinVersion": "6.0.0",
"url": "https://www.paloaltonetworks.com/cortex",
Expand Down
Loading