Skip to content

Commit b1998cb

Browse files
author
Juliya Smith
committed
Merge master
2 parents 72b5bf4 + 3c67ed7 commit b1998cb

3 files changed

Lines changed: 17 additions & 20 deletions

File tree

Packs/Code42/Integrations/Code42/Code42.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ def _get_all_high_risk_employees_from_page(page, risk_tags):
148148
return res
149149

150150

151+
def _try_convert_str_list_to_list(str_list):
152+
if isinstance(str_list, str):
153+
return str_list.split()
154+
return str_list
155+
156+
151157
class Code42Client(BaseClient):
152158
"""
153159
Client will implement the service API, should not contain Cortex XSOAR logic.
@@ -196,18 +202,19 @@ def remove_user_from_high_risk_employee(self, username):
196202
return user_id
197203

198204
def add_user_risk_tags(self, username, risk_tags):
205+
risk_tags = _try_convert_str_list_to_list(risk_tags)
199206
user_id = self.get_user_id(username)
200207
self._sdk.detectionlists.add_user_risk_tags(user_id, risk_tags)
201208
return user_id
202209

203210
def remove_user_risk_tags(self, username, risk_tags):
211+
risk_tags = _try_convert_str_list_to_list(risk_tags)
204212
user_id = self.get_user_id(username)
205213
self._sdk.detectionlists.remove_user_risk_tags(user_id, risk_tags)
206214
return user_id
207215

208216
def get_all_high_risk_employees(self, risk_tags, results):
209-
if isinstance(risk_tags, str):
210-
risk_tags = [risk_tags]
217+
risk_tags = _try_convert_str_list_to_list(risk_tags)
211218
res = []
212219
pages = self._sdk.detectionlists.high_risk_employee.get_all()
213220
for page in pages:

Packs/Code42/Integrations/Code42/Code42.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ script:
323323
- contextPath: Code42.HighRiskEmployee.Note
324324
description: Note associated with the High Risk Employee.
325325
type: string
326-
description: Removes a user from the High Risk Employee List.
326+
description: Adds a user from the High Risk Employee List.
327327
- name: code42-highriskemployee-remove
328328
arguments:
329329
- name: username
@@ -338,7 +338,7 @@ script:
338338
- name: code42-highriskemployee-get-all
339339
arguments:
340340
- name: risktags
341-
description: To filter results by employees who have these risk tags.
341+
description: To filter results by employees who have these risk tags. Space delimited.
342342
- name: results
343343
description: The number of items to return.
344344
defaultvalue: 50
@@ -361,7 +361,7 @@ script:
361361
description: The username of the High Risk Employee.
362362
- name: risktags
363363
required: true
364-
description: Risk tags to associate with the High Risk Employee.
364+
description: Space-delimited risk tags to associate with the High Risk Employee.
365365
outputs:
366366
- contextPath: Code42.HighRiskEmployee.UserID
367367
description: Internal Code42 User ID for the Departing Employee.
@@ -378,7 +378,7 @@ script:
378378
description: The username of the High Risk Employee.
379379
- name: risktags
380380
required: true
381-
description: Risk tags to disassociate from the High Risk Employee.
381+
description: Space-delimited risk tags to disassociate from the High Risk Employee.
382382
outputs:
383383
- contextPath: Code42.HighRiskEmployee.UserID
384384
description: Internal Code42 User ID for the Departing Employee.

Packs/Code42/Integrations/Code42/Code42_test.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,13 +1303,7 @@ def test_highriskemployee_get_all_command_when_given_risk_tags_only_gets_employe
13031303
client = create_client(code42_high_risk_employee_mock)
13041304
_, _, res = highriskemployee_get_all_command(
13051305
client,
1306-
{
1307-
"risktags": [
1308-
"PERFORMANCE_CONCERNS",
1309-
"SUSPICIOUS_SYSTEM_ACTIVITY",
1310-
"POOR_SECURITY_PRACTICES",
1311-
]
1312-
},
1306+
{"risktags": "PERFORMANCE_CONCERNS SUSPICIOUS_SYSTEM_ACTIVITY POOR_SECURITY_PRACTICES"},
13131307
)
13141308
# Only first employee has the given risk tags
13151309
expected = [json.loads(MOCK_GET_ALL_HIGH_RISK_EMPLOYEES_RESPONSE)["items"][0]]
@@ -1345,11 +1339,7 @@ def test_highriskemployee_get_all_command_when_no_employees(code42_high_risk_emp
13451339
_, _, res = highriskemployee_get_all_command(
13461340
client,
13471341
{
1348-
"risktags": [
1349-
"PERFORMANCE_CONCERNS",
1350-
"SUSPICIOUS_SYSTEM_ACTIVITY",
1351-
"POOR_SECURITY_PRACTICES",
1352-
]
1342+
"risktags": "PERFORMANCE_CONCERNS SUSPICIOUS_SYSTEM_ACTIVITY POOR_SECURITY_PRACTICES"
13531343
},
13541344
)
13551345
# Only first employee has the given risk tags
@@ -1366,14 +1356,14 @@ def test_highriskemployee_add_risk_tags_command(code42_sdk_mock):
13661356
expected_user_id = "123412341234123412" # value found in GET_USER_RESPONSE
13671357
assert res == expected_user_id
13681358
code42_sdk_mock.detectionlists.add_user_risk_tags.assert_called_once_with(
1369-
expected_user_id, "FLIGHT_RISK"
1359+
expected_user_id, ["FLIGHT_RISK"]
13701360
)
13711361

13721362

13731363
def test_highriskemployee_remove_risk_tags_command(code42_sdk_mock):
13741364
client = create_client(code42_sdk_mock)
13751365
_, _, res = highriskemployee_remove_risk_tags_command(
1376-
client, {"username": "user1@example.com", "risktags": ["FLIGHT_RISK", "CONTRACT_EMPLOYEE"]}
1366+
client, {"username": "user1@example.com", "risktags": "FLIGHT_RISK CONTRACT_EMPLOYEE"}
13771367
)
13781368
expected_user_id = "123412341234123412" # value found in GET_USER_RESPONSE
13791369
assert res == expected_user_id

0 commit comments

Comments
 (0)