Skip to content

Commit

Permalink
removed single email restriction for from
Browse files Browse the repository at this point in the history
  • Loading branch information
hardik-crest committed May 16, 2024
1 parent a235e68 commit 37f7a13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion release_notes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
**Unreleased**
* Added restrictions for `splunk`, `phantom` and `cisco` domains for 'from' input in **send email** and **send htmlemail**
* Added restrictions for `splunk`, `phantom` and `cisco` domains for 'from' field in **send email** and **send htmlemail** actions
18 changes: 5 additions & 13 deletions smtp_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,10 @@ 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):
# SMTP only supports a single email as the sender
if ',' in input_data or ';' in input_data:
return action_result.set_status(
phantom.APP_ERROR,
"SMTP only supports a single email for the 'from' field, please enter email in valid format."
)

# 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]
domain = input_data.split("@")[-1].lower()

if any(restricted_domain in domain for restricted_domain in restricted_domains):
return action_result.set_status(
Expand Down Expand Up @@ -825,11 +818,10 @@ def _send_email(self, param, action_result):
email_from = param.get(SMTP_JSON_FROM, sender_address)

# validate sender email if inputted as a parameter
if action_id != "test_connectivity":
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()
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)
Expand Down

0 comments on commit 37f7a13

Please sign in to comment.