diff --git a/Packs/Code42/Integrations/Code42/Code42.py b/Packs/Code42/Integrations/Code42/Code42.py index fb48223c408b..a93350fb1c60 100644 --- a/Packs/Code42/Integrations/Code42/Code42.py +++ b/Packs/Code42/Integrations/Code42/Code42.py @@ -148,6 +148,12 @@ def _get_all_high_risk_employees_from_page(page, risk_tags): return res +def _try_convert_str_list_to_list(str_list): + if isinstance(str_list, str): + return str_list.split() + return str_list + + class Code42Client(BaseClient): """ Client will implement the service API, should not contain Cortex XSOAR logic. @@ -193,18 +199,19 @@ def remove_user_from_high_risk_employee(self, username): return user_id def add_user_risk_tags(self, username, risk_tags): + risk_tags = _try_convert_str_list_to_list(risk_tags) user_id = self.get_user_id(username) self._sdk.detectionlists.add_user_risk_tags(user_id, risk_tags) return user_id def remove_user_risk_tags(self, username, risk_tags): + risk_tags = _try_convert_str_list_to_list(risk_tags) user_id = self.get_user_id(username) self._sdk.detectionlists.remove_user_risk_tags(user_id, risk_tags) return user_id def get_all_high_risk_employees(self, risk_tags=None): - if isinstance(risk_tags, str): - risk_tags = [risk_tags] + risk_tags = _try_convert_str_list_to_list(risk_tags) res = [] pages = self._sdk.detectionlists.high_risk_employee.get_all() for page in pages: @@ -631,8 +638,8 @@ def highriskemployee_get_all_command(client, args): @logger def highriskemployee_add_risk_tags_command(client, args): - username = args["username"] - tags = args["risktags"] + username = args.get("username") + tags = args.get("risktags") try: user_id = client.add_user_risk_tags(username, tags) rt_context = {"UserID": user_id, "Username": username, "RiskTags": tags} @@ -644,8 +651,8 @@ def highriskemployee_add_risk_tags_command(client, args): @logger def highriskemployee_remove_risk_tags_command(client, args): - username = args["username"] - tags = args["risktags"] + username = args.get("username") + tags = args.get("risktags") try: user_id = client.remove_user_risk_tags(username, tags) rt_context = {"UserID": user_id, "Username": username, "RiskTags": tags} diff --git a/Packs/Code42/Integrations/Code42/Code42.yml b/Packs/Code42/Integrations/Code42/Code42.yml index 416bfb241d78..cfea28e1e326 100644 --- a/Packs/Code42/Integrations/Code42/Code42.yml +++ b/Packs/Code42/Integrations/Code42/Code42.yml @@ -318,7 +318,7 @@ script: - contextPath: Code42.HighRiskEmployee.Note description: Note associated with the High Risk Employee. type: string - description: Removes a user from the High Risk Employee List. + description: Adds a user from the High Risk Employee List. - name: code42-highriskemployee-remove arguments: - name: username @@ -333,7 +333,7 @@ script: - name: code42-highriskemployee-get-all arguments: - name: risktags - description: To filter results by employees who have these risk tags. + description: To filter results by employees who have these risk tags. Space delimited. outputs: - contextPath: Code42.HighRiskEmployee.UserID description: Internal Code42 User ID for the High Risk Employee. @@ -352,7 +352,7 @@ script: description: The username of the High Risk Employee. - name: risktags required: true - description: Risk tags to associate with the High Risk Employee. + description: Space-delimited risk tags to associate with the High Risk Employee. outputs: - contextPath: Code42.HighRiskEmployee.UserID description: Internal Code42 User ID for the Departing Employee. @@ -369,7 +369,7 @@ script: description: The username of the High Risk Employee. - name: risktags required: true - description: Risk tags to disassociate from the High Risk Employee. + description: Space-delimited risk tags to disassociate from the High Risk Employee. outputs: - contextPath: Code42.HighRiskEmployee.UserID description: Internal Code42 User ID for the Departing Employee. diff --git a/Packs/Code42/Integrations/Code42/Code42_test.py b/Packs/Code42/Integrations/Code42/Code42_test.py index e30512bac844..bb798e58f535 100644 --- a/Packs/Code42/Integrations/Code42/Code42_test.py +++ b/Packs/Code42/Integrations/Code42/Code42_test.py @@ -1307,13 +1307,7 @@ def test_highriskemployee_get_all_command_when_given_risk_tags_only_gets_employe client = create_client(code42_high_risk_employee_mock) _, _, res = highriskemployee_get_all_command( client, - { - "risktags": [ - "PERFORMANCE_CONCERNS", - "SUSPICIOUS_SYSTEM_ACTIVITY", - "POOR_SECURITY_PRACTICES", - ] - }, + {"risktags": "PERFORMANCE_CONCERNS SUSPICIOUS_SYSTEM_ACTIVITY POOR_SECURITY_PRACTICES"}, ) # Only first employee has the given risk tags expected = [json.loads(MOCK_GET_ALL_HIGH_RISK_EMPLOYEES_RESPONSE)["items"][0]] @@ -1332,11 +1326,7 @@ def test_highriskemployee_get_all_command_when_no_employees(code42_high_risk_emp _, _, res = highriskemployee_get_all_command( client, { - "risktags": [ - "PERFORMANCE_CONCERNS", - "SUSPICIOUS_SYSTEM_ACTIVITY", - "POOR_SECURITY_PRACTICES", - ] + "risktags": "PERFORMANCE_CONCERNS SUSPICIOUS_SYSTEM_ACTIVITY POOR_SECURITY_PRACTICES" }, ) # Only first employee has the given risk tags @@ -1353,14 +1343,14 @@ def test_highriskemployee_add_risk_tags_command(code42_sdk_mock): expected_user_id = "123412341234123412" # value found in GET_USER_RESPONSE assert res == expected_user_id code42_sdk_mock.detectionlists.add_user_risk_tags.assert_called_once_with( - expected_user_id, "FLIGHT_RISK" + expected_user_id, ["FLIGHT_RISK"] ) def test_highriskemployee_remove_risk_tags_command(code42_sdk_mock): client = create_client(code42_sdk_mock) _, _, res = highriskemployee_remove_risk_tags_command( - client, {"username": "user1@example.com", "risktags": ["FLIGHT_RISK", "CONTRACT_EMPLOYEE"]} + client, {"username": "user1@example.com", "risktags": "FLIGHT_RISK CONTRACT_EMPLOYEE"} ) expected_user_id = "123412341234123412" # value found in GET_USER_RESPONSE assert res == expected_user_id