From 856ad7bb1204861eab2b843f1d7049f93245c53b Mon Sep 17 00:00:00 2001 From: Jenna Richardson Date: Thu, 2 Nov 2023 13:58:12 +0000 Subject: [PATCH] [SOAR15334]- Updated email validator to show a warning if the example did not match --- .../rules/plugin_validators/confidential_validator.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/icon_validator/rules/plugin_validators/confidential_validator.py b/icon_validator/rules/plugin_validators/confidential_validator.py index ff572a79..d9f6261b 100644 --- a/icon_validator/rules/plugin_validators/confidential_validator.py +++ b/icon_validator/rules/plugin_validators/confidential_validator.py @@ -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): @@ -17,7 +18,7 @@ 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") @@ -25,6 +26,7 @@ def validate_help(plugin_path: str): # 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]) @@ -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):