Skip to content

Commit

Permalink
PAPP-34356 added constants for repeated input parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyc-phantom committed Oct 14, 2024
1 parent 029b721 commit f0fe863
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
20 changes: 11 additions & 9 deletions crowdstrikeoauthapi_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ def _handle_list_incidents(self, param):
"status.desc",
]

params = {k: param[k] for k in param.keys() if k in ["filter", "limit", "offset", "sort"]}
params = {k: param[k] for k in param.keys() if k in [CROWDSTRIKE_FILTER, CROWDSTRIKE_LIMIT, CROWDSTRIKE_OFFSET, CROWDSTRIKE_SORT]}

resp = self._check_data(action_result, params, max_limit, sort_data)
if phantom.is_fail(resp):
Expand Down Expand Up @@ -814,7 +814,7 @@ def _handle_list_incident_behaviors(self, param):
max_limit = None
sort_data = ["--", "timestamp.asc", "timestamp.desc"]

params = {k: param[k] for k in param.keys() if k in ["filter", "limit", "offset", "sort"]}
params = {k: param[k] for k in param.keys() if k in [CROWDSTRIKE_FILTER, CROWDSTRIKE_LIMIT, CROWDSTRIKE_OFFSET, CROWDSTRIKE_SORT]}

resp = self._check_data(action_result, params, max_limit, sort_data)
if phantom.is_fail(resp):
Expand Down Expand Up @@ -897,7 +897,7 @@ def _handle_list_crowdscores(self, param):
# Add an action result object to self (BaseConnector) to represent the action for this param
action_result = self.add_action_result(ActionResult(dict(param)))

params = {k: param[k] for k in param.keys() if k in ["filter", "limit", "offset", "sort"]}
params = {k: param[k] for k in param.keys() if k in [CROWDSTRIKE_FILTER, CROWDSTRIKE_LIMIT, CROWDSTRIKE_OFFSET, CROWDSTRIKE_SORT]}

max_limit = None
sort_data = ["--", "score.asc", "score.desc", "timestamp.asc", "timestamp.desc"]
Expand Down Expand Up @@ -1088,7 +1088,7 @@ def _handle_query_device(self, param):
action_result = self.add_action_result(ActionResult(dict(param)))
max_limit = 5000

params = {k: param[k] for k in param.keys() if k in ["filter", "limit", "offset", "sort"]}
params = {k: param[k] for k in param.keys() if k in [CROWDSTRIKE_FILTER, CROWDSTRIKE_LIMIT, CROWDSTRIKE_OFFSET, CROWDSTRIKE_SORT]}

resp = self._check_data(action_result, params, max_limit)
if phantom.is_fail(resp):
Expand Down Expand Up @@ -1136,7 +1136,7 @@ def _handle_list_groups(self, param):
"name.desc",
]

params = {k: param[k] for k in param.keys() if k in ["filter", "limit", "sort"]}
params = {k: param[k] for k in param.keys() if k in [CROWDSTRIKE_FILTER, CROWDSTRIKE_LIMIT, CROWDSTRIKE_SORT]}

resp = self._check_data(action_result, params, max_limit, sort_data)

Expand Down Expand Up @@ -1336,7 +1336,7 @@ def _handle_list_put_files(self, param):
self.save_progress("In action handler for: {0}".format(self.get_action_identifier()))
action_result = self.add_action_result(ActionResult(dict(param)))

params = {k: param[k] for k in param.keys() if k in ["filter", "limit", "offset", "sort"]}
params = {k: param[k] for k in param.keys() if k in [CROWDSTRIKE_FILTER, CROWDSTRIKE_LIMIT, CROWDSTRIKE_OFFSET, CROWDSTRIKE_SORT]}

resp = self._check_data(action_result, params)

Expand Down Expand Up @@ -1828,7 +1828,9 @@ def _handle_list_alerts(self, param):
if phantom.is_fail(resp):
return action_result.get_status()

params = {k: param[k] for k in param.keys() if k in ["limit", "filter", "sort", "include_hidden"]}
params = {
k: param[k] for k in param.keys() if k in [CROWDSTRIKE_FILTER, CROWDSTRIKE_LIMIT, CROWDSTRIKE_SORT, CROWDSTRIKE_INCLUDE_HIDDEN]
}

if "include_hidden" not in params:
params["include_hidden"] = False
Expand Down Expand Up @@ -1873,7 +1875,7 @@ def _handle_list_detections(self, param):
self.save_progress("In action handler for: {0}".format(self.get_action_identifier()))
action_result = self.add_action_result(ActionResult(dict(param)))

params = {k: param[k] for k in param.keys() if k in ["limit", "filter", "sort"]}
params = {k: param[k] for k in param.keys() if k in [CROWDSTRIKE_FILTER, CROWDSTRIKE_LIMIT, CROWDSTRIKE_SORT]}

resp = self._check_data(action_result, params)

Expand Down Expand Up @@ -2138,7 +2140,7 @@ def _handle_list_sessions(self, param):
self.save_progress("In action handler for: {0}".format(self.get_action_identifier()))
action_result = self.add_action_result(ActionResult(dict(param)))

params = {k: param[k] for k in param.keys() if k in ["limit", "filter", "sort"]}
params = {k: param[k] for k in param.keys() if k in [CROWDSTRIKE_FILTER, CROWDSTRIKE_LIMIT, CROWDSTRIKE_SORT]}

resp = self._check_data(action_result, params)

Expand Down
7 changes: 7 additions & 0 deletions crowdstrikeoauthapi_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
CROWDSTRIKE_POLL_INTERVAL = "detonate_timeout"
CROWDSTRIKE_RESOURCE_ID = "resource_id"

# general parameters
CROWDSTRIKE_FILTER = "filter"
CROWDSTRIKE_INCLUDE_HIDDEN = "include_hidden"
CROWDSTRIKE_LIMIT = "limit"
CROWDSTRIKE_OFFSET = "offset"
CROWDSTRIKE_SORT = "sort"

DEFAULT_POLLNOW_EVENTS_COUNT = 2000
DEFAULT_EVENTS_COUNT = 10000
DEFAULT_BLANK_LINES_ALLOWABLE_LIMIT = 50
Expand Down

0 comments on commit f0fe863

Please sign in to comment.