Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Param defaults, fixes to GetDeviceDetails, DRYer
  • Loading branch information
jshcodes committed Dec 25, 2020
commit 1798e4ec24a240d678277b74fa40feb5ec868b6c
44 changes: 27 additions & 17 deletions src/falconpy/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,58 +68,68 @@ def PerformActionV2(self, parameters, body):
HEADERS = self.headers
PARAMS = parameters
BODY = body
result = self.Result()
try:
response = requests.request("POST", FULL_URL, params=PARAMS, json=BODY, headers=HEADERS, verify=False)
returned = result(response.status_code, response.headers, response.json())
returned = self.Result()(response.status_code, response.headers, response.json())
except Exception as e:
returned = result(500, {}, str(e))
returned = self.Result()(500, {}, str(e))

return returned

def GetDeviceDetails(self, parameters):
def GetDeviceDetails(self, ids):
""" Get details on one or more hosts by providing agent IDs (AID).
You can get a host's agent IDs (AIDs) from the /devices/queries/devices/v1 endpoint, the Falcon console or the Streaming API.
"""
# [GET] https://assets.falcon.crowdstrike.com/support/api/swagger.html#/hosts/GetDeviceDetails
FULL_URL = self.base_url+'/devices/entities/devices/v1'
ID_LIST = str(ids).replace(",","&ids=")
FULL_URL = self.base_url+'/devices/entities/devices/v1?ids={}'.format(ID_LIST)
HEADERS = self.headers
try:
response = requests.request("GET", FULL_URL, headers=HEADERS, verify=False)
returned = self.Result()(response.status_code, response.headers, response.json())
except Exception as e:
returned = self.Result()(500, {}, str(e))

return returned

def QueryHiddenDevices(self, parameters={}):
""" Perform the specified action on the Prevention Policies specified in the request. """
# [GET] https://assets.falcon.crowdstrike.com/support/api/swagger.html#/hosts/QueryHiddenDevices
FULL_URL = self.base_url+'/devices/queries/devices-hidden/v1'
HEADERS = self.headers
PARAMS = parameters
result = self.Result()
try:
response = requests.request("GET", FULL_URL, params=PARAMS, headers=HEADERS, verify=False)
returned = result(response.status_code, response.headers, response.json())
returned = self.Result()(response.status_code, response.headers, response.json())
except Exception as e:
returned = result(500, {}, str(e))
returned = self.Result()(500, {}, str(e))

return returned
def QueryDevicesByFilterScroll(self, parameters):

def QueryDevicesByFilterScroll(self, parameters={}):
""" Perform the specified action on the Prevention Policies specified in the request. """
# [GET] https://assets.falcon.crowdstrike.com/support/api/swagger.html#/hosts/QueryDevicesByFilterScroll
FULL_URL = self.base_url+'/devices/queries/devices-scroll/v1'
HEADERS = self.headers
PARAMS = parameters
result = self.Result()
try:
response = requests.request("GET", FULL_URL, params=PARAMS, headers=HEADERS, verify=False)
returned = result(response.status_code, response.headers, response.json())
returned = self.Result()(response.status_code, response.headers, response.json())
except Exception as e:
returned = result(500, {}, str(e))
returned = self.Result()(500, {}, str(e))

return returned

def QueryDevicesByFilter(self, parameters, body):
def QueryDevicesByFilter(self, parameters={}):
""" Search for hosts in your environment by platform, hostname, IP, and other criteria. """
# [GET] https://assets.falcon.crowdstrike.com/support/api/swagger.html#/hosts/QueryDevicesByFilter
FULL_URL = self.base_url+'/devices/queries/devices/v1'
HEADERS = self.headers
PARAMS = parameters
result = self.Result()
try:
response = requests.request("GET", FULL_URL, params=PARAMS, headers=HEADERS, verify=False)
returned = result(response.status_code, response.headers, response.json())
returned = self.Result()(response.status_code, response.headers, response.json())
except Exception as e:
returned = result(500, {}, str(e))
returned = self.Result()(500, {}, str(e))

return returned