diff --git a/plugins/rapid7_insightvm/help.md b/plugins/rapid7_insightvm/help.md index 9813216a4e..38361ce1b0 100644 --- a/plugins/rapid7_insightvm/help.md +++ b/plugins/rapid7_insightvm/help.md @@ -3966,7 +3966,7 @@ Example output: # Version History -* 6.2.0 - `Scan Completion` - New trigger added to retrieve vulnerability information on assets when a scan is completed +* 6.2.0 - `Scan Completion` - New trigger added to retrieve vulnerability information on assets when a scan is completed | Improved error handling across all API calls * 6.1.1 - Update actions `Update Site Excluded Targets` and `Update Site Included Targets` to prevent error on empty addresses * 6.1.0 - Add new optional input `override_blackout` in `Scan` action * 6.0.0 - Fix file output type for `Generate Adhoc SQL Report` | Replace custom output type `file` with `insightvm_file` for each item in the `asset` `files` output in multiple actions diff --git a/plugins/rapid7_insightvm/komand_rapid7_insightvm/actions/asset_search/action.py b/plugins/rapid7_insightvm/komand_rapid7_insightvm/actions/asset_search/action.py index 53f346c519..28f90b62b9 100755 --- a/plugins/rapid7_insightvm/komand_rapid7_insightvm/actions/asset_search/action.py +++ b/plugins/rapid7_insightvm/komand_rapid7_insightvm/actions/asset_search/action.py @@ -17,12 +17,14 @@ def __init__(self): def run(self, params={}): - resource_helper = ResourceRequests(self.connection.session, self.logger) search_criteria = params.get(Input.SEARCHCRITERIA) size = params.get(Input.SIZE, 0) sort_criteria = params.get(Input.SORT_CRITERIA, {}) - self.logger.info(f"Performing filtered asset search with criteria {search_criteria}") + + self.logger.info(f"Performing filtered asset search with criteria {search_criteria}...") + resource_helper = ResourceRequests(self.connection.session, self.logger) endpoint = endpoints.Asset.search(self.connection.console_url) + parameters = [] for key, value in sort_criteria.items(): diff --git a/plugins/rapid7_insightvm/komand_rapid7_insightvm/util/resource_requests.py b/plugins/rapid7_insightvm/komand_rapid7_insightvm/util/resource_requests.py index f2b09b9423..ead476183b 100644 --- a/plugins/rapid7_insightvm/komand_rapid7_insightvm/util/resource_requests.py +++ b/plugins/rapid7_insightvm/komand_rapid7_insightvm/util/resource_requests.py @@ -41,7 +41,7 @@ class ResourceRequests(object): # Static headers for all requests _HEADERS = {"Content-Type": "application/json", "Accept": "application/json"} - _ENSURECONNECTIVITY = ( + _ENSURE_CONNECTIVITY = ( "Ensure proper network connectivity between the InsightConnect orchestrator and the InsightVM console" ) @@ -50,10 +50,10 @@ class ResourceRequests(object): requests.HTTPError: "If this issue persists contact support for assistance.", requests.ConnectionError: "Unable to connect to IVM console." "If this issue persists contact support for assistance.", - requests.Timeout: _ENSURECONNECTIVITY, - requests.ConnectTimeout: _ENSURECONNECTIVITY, - requests.ReadTimeout: _ENSURECONNECTIVITY, - requests.TooManyRedirects: _ENSURECONNECTIVITY, + requests.Timeout: _ENSURE_CONNECTIVITY, + requests.ConnectTimeout: _ENSURE_CONNECTIVITY, + requests.ReadTimeout: _ENSURE_CONNECTIVITY, + requests.TooManyRedirects: _ENSURE_CONNECTIVITY, } # For request exceptions not in REQUEST_EXCEPTIONS @@ -103,17 +103,17 @@ def resource_request( extras = {"json": payload, "params": parameters.params} try: response = request_method(url=endpoint, verify=False, **extras) - except requests.RequestException as e: - assistance = self._REQUEST_EXCEPTIONS.get(type(e), self._UNHANDLED_EXCEPTION) - raise PluginException(cause=e, assistance=assistance) + except requests.RequestException as error: + assistance = self._REQUEST_EXCEPTIONS.get(type(error), self._UNHANDLED_EXCEPTION) + raise PluginException(cause=error, assistance=assistance) resource_request_status_code_check(response.text, response.status_code) if json_response: try: resource = response.json() - except json.decoder.JSONDecodeError: - raise PluginException(preset=PluginException.Preset.INVALID_JSON) + except json.decoder.JSONDecodeError as error: + raise PluginException(preset=PluginException.Preset.INVALID_JSON, data=f"Error returned: {error}") else: resource = {"raw": response.text} @@ -193,15 +193,15 @@ def get_resource_page(self, endpoint: str, method: str, params: RequestParams, p extras = {"json": payload, "params": params.params} try: response = request_method(url=endpoint, verify=False, **extras) - except requests.RequestException as e: - assistance = self._REQUEST_EXCEPTIONS.get(type(e), self._UNHANDLED_EXCEPTION) - raise PluginException(cause=e, assistance=assistance) + except requests.RequestException as error: + assistance = self._REQUEST_EXCEPTIONS.get(type(error), self._UNHANDLED_EXCEPTION) + raise PluginException(cause=error, assistance=assistance) resource_request_status_code_check(response.text, response.status_code) try: response_json = response.json() - except json.decoder.JSONDecodeError: - raise PluginException(preset=PluginException.Preset.INVALID_JSON) + except json.decoder.JSONDecodeError as error: + raise PluginException(preset=PluginException.Preset.INVALID_JSON, data=f"Error returned: {error}") result = RequestResult( page_num=response_json["page"]["number"],