Skip to content

Commit

Permalink
Remove email validation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hardik-crest committed Jun 27, 2024
1 parent 606d0fb commit 1c94200
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions smtp_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import encryption_helper
import phantom.app as phantom
import phantom.rules as ph_rules
import phantom.utils as ph_utils
import requests
from bleach.css_sanitizer import CSSSanitizer
from bleach_allowlist import all_styles, all_tags, generally_xss_unsafe
Expand Down Expand Up @@ -77,7 +76,8 @@ def initialize(self):

# action_result = self.add_action_result(ActionResult())

self.set_validator('email', self._validate_email)
# skipping the validation for email
self.set_validator('email', lambda input: True)

return phantom.APP_SUCCESS

Expand Down Expand Up @@ -253,28 +253,6 @@ def _validate_sender_email(self, action_result, input_data):

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
# will invalidate the input (at a customer site), leading to actions being stopped from carrying out.
# So keeping things as simple as possible here. The SMTP server will hopefully do a good job of
# validating it's input, any errors that are sent back to the app will get propagated to the user.

emails = []

# First work on the comma as the separator
if ',' in input_data:
emails = input_data.split(',')
elif ';' in input_data:
emails = input_data.split(';')
else:
emails = [input_data]

for email in emails:
if not ph_utils.is_email(email.strip()):
return False
return True

def make_rest_call(self, action_result, url, verify=False):

try:
Expand Down

0 comments on commit 1c94200

Please sign in to comment.