2121
2222INTEGRATION_CONTEXT_BRAND = 'PaloAltoNetworksXDR'
2323XDR_INCIDENT_TYPE_NAME = 'Cortex XDR Incident'
24+ INTEGRATION_NAME = 'Cortex XDR - IR'
2425
2526XDR_INCIDENT_FIELDS = {
2627 "status" : {"description" : "Current status of the incident: \" new\" ,\" under_"
@@ -1681,9 +1682,16 @@ def get_endpoints_command(client, args):
16811682 sort_by_first_seen = sort_by_first_seen ,
16821683 sort_by_last_seen = sort_by_last_seen
16831684 )
1685+
1686+ standard_endpoints = generate_endpoint_by_contex_standard (endpoints , False )
1687+ endpoint_context_list = []
1688+ for endpoint in standard_endpoints :
1689+ endpoint_context = endpoint .to_context ().get (Common .Endpoint .CONTEXT_PATH )
1690+ endpoint_context_list .append (endpoint_context )
1691+
16841692 context = {
16851693 f'{ INTEGRATION_CONTEXT_BRAND } .Endpoint(val.endpoint_id == obj.endpoint_id)' : endpoints ,
1686- Common .Endpoint .CONTEXT_PATH : return_endpoint_standard_context ( endpoints )
1694+ Common .Endpoint .CONTEXT_PATH : endpoint_context_list
16871695 }
16881696 account_context = create_account_context (endpoints )
16891697 if account_context :
@@ -1695,17 +1703,77 @@ def get_endpoints_command(client, args):
16951703 )
16961704
16971705
1698- def return_endpoint_standard_context (endpoints ):
1699- endpoints_context_list = []
1700- for endpoint in endpoints :
1701- endpoints_context_list .append (assign_params (** {
1702- "Hostname" : (endpoint ['host_name' ] if endpoint .get ('host_name' , '' ) else endpoint .get ('endpoint_name' )),
1703- "ID" : endpoint .get ('endpoint_id' ),
1704- "IPAddress" : endpoint .get ('ip' ),
1705- "Domain" : endpoint .get ('domain' ),
1706- "OS" : endpoint .get ('os_type' ),
1707- }))
1708- return endpoints_context_list
1706+ def convert_os_to_standard (endpoint_os ):
1707+ os_type = ''
1708+ endpoint_os = endpoint_os .lower ()
1709+ if 'windows' in endpoint_os :
1710+ os_type = "Windows"
1711+ elif 'linux' in endpoint_os :
1712+ os_type = "Linux"
1713+ elif 'macos' in endpoint_os :
1714+ os_type = "Macos"
1715+ elif 'android' in endpoint_os :
1716+ os_type = "Android"
1717+ return os_type
1718+
1719+
1720+ def generate_endpoint_by_contex_standard (endpoints , ip_as_string ):
1721+ standard_endpoints = []
1722+ for single_endpoint in endpoints :
1723+ status = 'Online' if single_endpoint .get ('endpoint_status' ) == 'connected' else 'Offline'
1724+ is_isolated = 'No' if 'unisolated' in single_endpoint .get ('is_isolated' , '' ).lower () else 'Yes'
1725+ hostname = single_endpoint ['host_name' ] if single_endpoint .get ('host_name' , '' ) else single_endpoint .get (
1726+ 'endpoint_name' )
1727+ ip = single_endpoint .get ('ip' )
1728+ # in the `xdr-get-endpoints` command the ip is returned as list, in order not to break bc we will keep it
1729+ # in the `endpoint` command we use the standard
1730+ if ip_as_string and isinstance (ip , list ):
1731+ ip = ip [0 ]
1732+ os_type = convert_os_to_standard (single_endpoint .get ('os_type' , '' ))
1733+ endpoint = Common .Endpoint (
1734+ id = single_endpoint .get ('endpoint_id' ),
1735+ hostname = hostname ,
1736+ ip_address = ip ,
1737+ os = os_type ,
1738+ status = status ,
1739+ is_isolated = is_isolated ,
1740+ mac_address = single_endpoint .get ('mac_address' ),
1741+ domain = single_endpoint .get ('domain' ),
1742+ vendor = INTEGRATION_NAME )
1743+
1744+ standard_endpoints .append (endpoint )
1745+ return standard_endpoints
1746+
1747+
1748+ def endpoint_command (client , args ):
1749+ endpoint_id_list = argToList (args .get ('id' ))
1750+ endpoint_ip_list = argToList (args .get ('ip' ))
1751+ endpoint_hostname_list = argToList (args .get ('hostname' ))
1752+
1753+ endpoints = client .get_endpoints (
1754+ endpoint_id_list = endpoint_id_list ,
1755+ ip_list = endpoint_ip_list ,
1756+ hostname = endpoint_hostname_list ,
1757+ )
1758+ standard_endpoints = generate_endpoint_by_contex_standard (endpoints , True )
1759+ command_results = []
1760+ if standard_endpoints :
1761+ for endpoint in standard_endpoints :
1762+ endpoint_context = endpoint .to_context ().get (Common .Endpoint .CONTEXT_PATH )
1763+ hr = tableToMarkdown ('Cortex XDR Endpoint' , endpoint_context )
1764+
1765+ command_results .append (CommandResults (
1766+ readable_output = hr ,
1767+ raw_response = endpoints ,
1768+ indicator = endpoint
1769+ ))
1770+
1771+ else :
1772+ command_results .append (CommandResults (
1773+ readable_output = "No endpoints were found" ,
1774+ raw_response = endpoints ,
1775+ ))
1776+ return command_results
17091777
17101778
17111779def create_parsed_alert (product , vendor , local_ip , local_port , remote_ip , remote_port , event_timestamp , severity ,
@@ -3297,6 +3365,9 @@ def main():
32973365 elif demisto .command () == 'xdr-run-script-kill-process' :
32983366 return_results (run_script_kill_process_command (client , args ))
32993367
3368+ elif demisto .command () == 'endpoint' :
3369+ return_results (endpoint_command (client , args ))
3370+
33003371 except Exception as err :
33013372 if demisto .command () == 'fetch-incidents' :
33023373 LOG (str (err ))
0 commit comments