Skip to content

Commit

Permalink
PAPP-34503
Browse files Browse the repository at this point in the history
 - remove email domain validation logic
  • Loading branch information
leobao-splunk committed Aug 29, 2024
1 parent 9df479d commit 2e4dce9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
4 changes: 2 additions & 2 deletions smtp.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"read_only": false,
"parameters": {
"from": {
"description": "Sender Address, domain can not include 'phantom', 'splunk', or 'cisco'",
"description": "Sender Address",
"data_type": "string",
"order": 0,
"contains": [
Expand Down Expand Up @@ -404,7 +404,7 @@
"read_only": false,
"parameters": {
"from": {
"description": "Sender Address, domain can not include 'phantom', 'splunk', or 'cisco'",
"description": "Sender Address",
"data_type": "string",
"order": 0,
"primary": true,
Expand Down
27 changes: 0 additions & 27 deletions smtp_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,6 @@ def _validate_integer(self, action_result, parameter, key, allow_zero=False):

return phantom.APP_SUCCESS, parameter

def _validate_sender_email(self, action_result, input_data):
# sender emails also have additional restriction
# to not include splunk related terms in the domain name
restricted_domains = ["splunk", "cisco", "phantom"]
domain = input_data.split("@")[-1].lower()

if any(restricted_domain in domain for restricted_domain in restricted_domains):
return action_result.set_status(
phantom.APP_ERROR,
"The domain provided in email is restricted (contains one of : splunk, cisco, phantom).\
Please use a different email in the 'from' field."
)

return action_result.set_status(phantom.APP_SUCCESS)

def _validate_email(self, input_data):
# validations are always tricky things, making it 100% foolproof, will take a
# very complicated regex, even multiple regexes and each could lead to a bug that
Expand Down Expand Up @@ -818,12 +803,6 @@ def _send_email(self, param, action_result):
sender_address = config.get('sender_address', config.get(phantom.APP_JSON_USERNAME))
email_from = param.get(SMTP_JSON_FROM, sender_address)

# validate sender email if inputted as a parameter
if action_id != "test_connectivity" and param.get(SMTP_JSON_FROM):
ret_val = self._validate_sender_email(action_result, email_from)
if phantom.is_fail(ret_val):
return action_result.get_status()

encoding = config.get(SMTP_ENCODING, False)
smtputf8 = config.get(SMTP_ALLOW_SMTPUTF8, False)
body = param[SMTP_JSON_BODY]
Expand Down Expand Up @@ -1045,12 +1024,6 @@ def _handle_send_htmlemail(self, param): # noqa: C901
sender_address = config.get('sender_address', config.get(phantom.APP_JSON_USERNAME))
email_from = param.get(SMTP_JSON_FROM, sender_address)

# validate sender email if inputted as a parameter
if param.get(SMTP_JSON_FROM):
ret_val = self._validate_sender_email(action_result, email_from)
if phantom.is_fail(ret_val):
return action_result.get_status()

email_to = param['to']
email_cc = param.get('cc')
email_bcc = param.get('bcc')
Expand Down

0 comments on commit 2e4dce9

Please sign in to comment.