Skip to content

Commit

Permalink
SOAR-18579-Better error handling for invalid dns
Browse files Browse the repository at this point in the history
  • Loading branch information
rbowden-r7 committed Jan 24, 2025
1 parent a9e8457 commit d1364d2
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 28 deletions.
6 changes: 3 additions & 3 deletions plugins/salesforce/.CHECKSUM
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"spec": "63b7270d95683b98e315808e4df20354",
"manifest": "391ed2bce80fc53ee24774278259d26e",
"setup": "295d03a5efdf6658a6a10babe80a9a06",
"spec": "ae7dbbf62a58205ff91cd8d658ff5299",
"manifest": "e5d067d713f2381cc4875c19c200e489",
"setup": "bfad8c5af259dc2c0235de74e1b7d8dd",
"schemas": [
{
"identifier": "advanced_search/schema.py",
Expand Down
2 changes: 1 addition & 1 deletion plugins/salesforce/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-plugin:6.2.0
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-plugin:6.2.3

LABEL organization=rapid7
LABEL sdk=python
Expand Down
2 changes: 1 addition & 1 deletion plugins/salesforce/bin/komand_salesforce
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from sys import argv

Name = "Salesforce"
Vendor = "rapid7"
Version = "2.1.12"
Version = "2.1.13"
Description = "[Salesforce](https://www.salesforce.com) is a CRM solution that brings together all customer information in a single, integrated platform that enables building a customer-centered business from marketing right through to sales, customer service and business analysis. The Salesforce plugin allows you to search, update, and manage salesforce records. This plugin utilizes the [Salesforce API](https://developer.salesforce.com/docs/atlas.en-us.216.0.api_rest.meta/api_rest/intro_what_is_rest_api.htm)"


Expand Down
1 change: 1 addition & 0 deletions plugins/salesforce/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ Example output:

# Version History

* 2.1.13 - Task Monitor Users: improve error response to UI | Bump SDK to 6.2.3
* 2.1.12 - Task Monitor Users: ensure datetime includes microseconds | Bump SDK to 6.2.0
* 2.1.11 - Task Monitor Users: Return 500 for retry your request error | Bump SDK to 6.1.4
* 2.1.10 - Set Monitor Users task output length | Fix to remove whitespace from connection inputs
Expand Down
34 changes: 23 additions & 11 deletions plugins/salesforce/komand_salesforce/util/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
SOBJECT_UPDATED_USERS,
)
from komand_salesforce.util.exceptions import ApiException
from requests.exceptions import ConnectionError as DNSError


def rate_limiting(max_tries: int):
Expand Down Expand Up @@ -190,17 +191,27 @@ def _get_token(
client_url = f"https://{salesforce_url}/services/oauth2/token"

self.logger.info(f"SalesforceAPI: Getting API token from {client_url}... ")
response = requests.request(
method="POST",
url=client_url,
data={
"grant_type": "password",
"client_id": client_id,
"client_secret": client_secret,
"username": username,
"password": password + security_token,
},
)

try:
response = requests.request(
method="POST",
url=client_url,
data={
"grant_type": "password",
"client_id": client_id,
"client_secret": client_secret,
"username": username,
"password": password + security_token,
},
)
except DNSError as error_message:
self.logger.info(f"Network error or DNS resolution failed: {error_message}")
raise ApiException(
cause="Network error or DNS resolution failed. Please check the domain entered",
assistance="Network error or DNS resolution failed. Please check the domain entered",
status_code=400,
data="Network error or DNS resolution failed. Please check the domain entered",
)

if 400 <= response.status_code <= 504:
decoded_response = response.content.decode()
Expand Down Expand Up @@ -357,6 +368,7 @@ def get_error(self, response: str) -> Tuple[str, str, int]:
"invalid_grant": "Invalid password or security token supplied.",
"invalid_client_id": "Invalid client ID supplied.",
"invalid_client": "Invalid client secret supplied.",
"unsupported_grant_type": "Grant type not supported, Please ensure correct login URL is provided",
}

try:
Expand Down
5 changes: 3 additions & 2 deletions plugins/salesforce/plugin.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ products: [insightconnect]
name: salesforce
title: Salesforce
description: "[Salesforce](https://www.salesforce.com) is a CRM solution that brings together all customer information in a single, integrated platform that enables building a customer-centered business from marketing right through to sales, customer service and business analysis. The Salesforce plugin allows you to search, update, and manage salesforce records. This plugin utilizes the [Salesforce API](https://developer.salesforce.com/docs/atlas.en-us.216.0.api_rest.meta/api_rest/intro_what_is_rest_api.htm)"
version: 2.1.12
version: 2.1.13
connection_version: 2
vendor: rapid7
support: community
Expand All @@ -13,7 +13,7 @@ status: []
supported_versions: ["Salesforce API v58 2023-06-30"]
sdk:
type: full
version: 6.2.0
version: 6.2.3
user: nobody
resources:
source_url: https://github.com/rapid7/insightconnect-plugins/tree/master/plugins/salesforce
Expand All @@ -37,6 +37,7 @@ references:
- "[Connecting your app to the API](https://developer.salesforce.com/docs/atlas.en-us.216.0.api_rest.meta/api_rest/quickstart.htm)"
- "[SOQL](https://developer.salesforce.com/docs/atlas.en-us.216.0.soql_sosl.meta/soql_sosl/sforce_api_calls_soql.htm)"
version_history:
- "2.1.13 - Task Monitor Users: improve error response to UI | Bump SDK to 6.2.3"
- "2.1.12 - Task Monitor Users: ensure datetime includes microseconds | Bump SDK to 6.2.0"
- "2.1.11 - Task Monitor Users: Return 500 for retry your request error | Bump SDK to 6.1.4"
- "2.1.10 - Set Monitor Users task output length | Fix to remove whitespace from connection inputs"
Expand Down
21 changes: 11 additions & 10 deletions plugins/salesforce/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
from setuptools import setup, find_packages


setup(name="salesforce-rapid7-plugin",
version="2.1.12",
description="[Salesforce](https://www.salesforce.com) is a CRM solution that brings together all customer information in a single, integrated platform that enables building a customer-centered business from marketing right through to sales, customer service and business analysis. The Salesforce plugin allows you to search, update, and manage salesforce records. This plugin utilizes the [Salesforce API](https://developer.salesforce.com/docs/atlas.en-us.216.0.api_rest.meta/api_rest/intro_what_is_rest_api.htm)",
author="rapid7",
author_email="",
url="",
packages=find_packages(),
install_requires=['insightconnect-plugin-runtime'], # Add third-party dependencies to requirements.txt, not here!
scripts=['bin/komand_salesforce']
)
setup(
name="salesforce-rapid7-plugin",
version="2.1.13",
description="[Salesforce](https://www.salesforce.com) is a CRM solution that brings together all customer information in a single, integrated platform that enables building a customer-centered business from marketing right through to sales, customer service and business analysis. The Salesforce plugin allows you to search, update, and manage salesforce records. This plugin utilizes the [Salesforce API](https://developer.salesforce.com/docs/atlas.en-us.216.0.api_rest.meta/api_rest/intro_what_is_rest_api.htm)",
author="rapid7",
author_email="",
url="",
packages=find_packages(),
install_requires=["insightconnect-plugin-runtime"], # Add third-party dependencies to requirements.txt, not here!
scripts=["bin/komand_salesforce"],
)

0 comments on commit d1364d2

Please sign in to comment.