Skip to content

Commit

Permalink
[SOAR15334]- Updated email validator to show a warning if the example…
Browse files Browse the repository at this point in the history
… did not match
  • Loading branch information
jerichardson-r7 committed Nov 2, 2023
1 parent 727a74f commit 856ad7b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from icon_validator.rules.validator import KomandPluginValidator
from icon_validator.exceptions import ValidationException
from icon_validator.styling import *


class ConfidentialValidator(KomandPluginValidator):
Expand All @@ -17,14 +18,15 @@ class ConfidentialValidator(KomandPluginValidator):
# Search help file
@staticmethod
def validate_help(plugin_path: str):
with open(f"{plugin_path}/help.md") as h:
with open(f"help.md") as h:
help_lines: [str] = h.readlines()

ConfidentialValidator.validate_emails(help_lines, "help.md")

# Check content line by line for emails that validate the rule
@staticmethod
def validate_emails(content: [str], path_to_file: str):
print(content)
email_pattern = re.compile(r"([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+){0,}")
for i in range(0, len(content)):
matches = email_pattern.findall(content[i])
Expand All @@ -33,8 +35,8 @@ def validate_emails(content: [str], path_to_file: str):
for match in matches:
user_email_pattern = re.compile(r"user\d*\@example.com")
if not user_email_pattern.search(match):
ConfidentialValidator.violations.append(f"{path_to_file}, line: {i + 1}")

print(
f"{YELLOW}WARNING: Email does not match recommended example user@example.com")
# Search code base
@staticmethod
def validate_code(plugin_path: str):
Expand Down

0 comments on commit 856ad7b

Please sign in to comment.