Skip to content

Commit

Permalink
Merge branch 'contrib/zeekforit_master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
zeekforit authored Jan 9, 2024
2 parents 177dbfb + 9542df6 commit 225f8b5
Show file tree
Hide file tree
Showing 44 changed files with 2,199 additions and 365 deletions.
6 changes: 6 additions & 0 deletions Packs/Base/ReleaseNotes/1_33_15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Scripts

##### CommonServerPython

- Fixed an issue where logging curl calls could expose sensitive values.
8 changes: 7 additions & 1 deletion Packs/Base/Scripts/CommonServerPython/CommonServerPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def __line__():
EVENTS = "events"
DATA_TYPES = [EVENTS, ASSETS]

SECRET_REPLACEMENT_STRING = '<XX_REPLACED>'


def register_module_line(module_name, start_end, line, wrapper=0):
"""
Expand Down Expand Up @@ -1591,7 +1593,7 @@ def encode(self, message):
else:
res = "Failed encoding message with error: {}".format(exception)
for s in self.replace_strs:
res = res.replace(s, '<XX_REPLACED>')
res = res.replace(s, SECRET_REPLACEMENT_STRING)
return res

def __call__(self, message):
Expand Down Expand Up @@ -1670,6 +1672,7 @@ def build_curl(self, text):
url = ''
headers = []
headers_to_skip = ['Content-Length', 'User-Agent', 'Accept-Encoding', 'Connection']
headers_to_sanitize = ['Authorization', 'Cookie']
request_parts = repr(data).split('\\\\r\\\\n') # splitting lines on repr since data is a bytes-string
for line, part in enumerate(request_parts):
if line == 0:
Expand All @@ -1681,6 +1684,9 @@ def build_curl(self, text):
else:
if any(header_to_skip in part for header_to_skip in headers_to_skip):
continue
if any(header_to_sanitize in part for header_to_sanitize in headers_to_sanitize):
headers.append(part.split(' ')[0] + " " + SECRET_REPLACEMENT_STRING)
continue
headers.append(part)
curl_headers = ''
for header in headers:
Expand Down
10 changes: 5 additions & 5 deletions Packs/Base/Scripts/CommonServerPython/CommonServerPython_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ def test_build_curl_post_noproxy():
"Content-Type: application/json\\r\\n\\r\\n'")
ilog.build_curl("send: b'{\"data\": \"value\"}'")
assert ilog.curl == [
'curl -X POST https://demisto.com/api -H "Authorization: TOKEN" -H "Content-Type: application/json" '
'curl -X POST https://demisto.com/api -H "Authorization: <XX_REPLACED>" -H "Content-Type: application/json" '
'--noproxy "*" -d \'{"data": "value"}\''
]

Expand All @@ -1479,7 +1479,7 @@ def test_build_curl_post_xml():
"Content-Type: application/json\\r\\n\\r\\n'")
ilog.build_curl("send: b'<?xml version=\"1.0\" encoding=\"utf-8\"?>'")
assert ilog.curl == [
'curl -X POST https://demisto.com/api -H "Authorization: TOKEN" -H "Content-Type: application/json" '
'curl -X POST https://demisto.com/api -H "Authorization: <XX_REPLACED>" -H "Content-Type: application/json" '
'--noproxy "*" -d \'<?xml version="1.0" encoding="utf-8"?>\''
]

Expand Down Expand Up @@ -1511,7 +1511,7 @@ def test_build_curl_get_withproxy(mocker):
"Content-Type: application/json\\r\\n\\r\\n'")
ilog.build_curl("send: b'{\"data\": \"value\"}'")
assert ilog.curl == [
'curl -X GET https://demisto.com/api -H "Authorization: TOKEN" -H "Content-Type: application/json" '
'curl -X GET https://demisto.com/api -H "Authorization: <XX_REPLACED>" -H "Content-Type: application/json" '
'--proxy http://proxy -k -d \'{"data": "value"}\''
]

Expand Down Expand Up @@ -1548,9 +1548,9 @@ def test_build_curl_multiple_queries():
"Content-Type: application/json\\r\\n\\r\\n'")
ilog.build_curl("send: b'{\"getdata\": \"value\"}'")
assert ilog.curl == [
'curl -X POST https://demisto.com/api/post -H "Authorization: TOKEN" -H "Content-Type: application/json" '
'curl -X POST https://demisto.com/api/post -H "Authorization: <XX_REPLACED>" -H "Content-Type: application/json" '
'--noproxy "*" -d \'{"postdata": "value"}\'',
'curl -X GET https://demisto.com/api/get -H "Authorization: TOKEN" -H "Content-Type: application/json" '
'curl -X GET https://demisto.com/api/get -H "Authorization: <XX_REPLACED>" -H "Content-Type: application/json" '
'--noproxy "*" -d \'{"getdata": "value"}\''
]

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.33.14",
"currentVersion": "1.33.15",
"author": "Cortex XSOAR",
"serverMinVersion": "6.0.0",
"url": "https://www.paloaltonetworks.com/cortex",
Expand Down
4 changes: 3 additions & 1 deletion Packs/CiscoSpark/.secrets-ignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
https://webexapis.com
https://webexapis.com
https://developer.webex.com
https://redirect.com
Loading

0 comments on commit 225f8b5

Please sign in to comment.