mirror of
https://github.com/valitydev/SigmaHQ.git
synced 2024-11-06 17:35:19 +00:00
Merge branch 'fix_filename_test' of https://github.com/frack113/sigma into fix_filename_test
This commit is contained in:
commit
688903192d
@ -47,18 +47,18 @@ class TestRules(unittest.TestCase):
|
||||
return data
|
||||
|
||||
# Tests
|
||||
def test_confirm_extension_is_yml(self):
|
||||
files_with_incorrect_extensions = []
|
||||
# def test_confirm_extension_is_yml(self):
|
||||
# files_with_incorrect_extensions = []
|
||||
|
||||
for file in self.yield_next_rule_file_path(self.path_to_rules):
|
||||
file_name_and_extension = os.path.splitext(file)
|
||||
if len(file_name_and_extension) == 2:
|
||||
extension = file_name_and_extension[1]
|
||||
if extension != ".yml":
|
||||
files_with_incorrect_extensions.append(file)
|
||||
# for file in self.yield_next_rule_file_path(self.path_to_rules):
|
||||
# file_name_and_extension = os.path.splitext(file)
|
||||
# if len(file_name_and_extension) == 2:
|
||||
# extension = file_name_and_extension[1]
|
||||
# if extension != ".yml":
|
||||
# files_with_incorrect_extensions.append(file)
|
||||
|
||||
self.assertEqual(files_with_incorrect_extensions, [], Fore.RED +
|
||||
"There are rule files with extensions other than .yml")
|
||||
# self.assertEqual(files_with_incorrect_extensions, [], Fore.RED +
|
||||
# "There are rule files with extensions other than .yml")
|
||||
|
||||
def test_legal_trademark_violations(self):
|
||||
files_with_legal_issues = []
|
||||
@ -519,12 +519,26 @@ class TestRules(unittest.TestCase):
|
||||
|
||||
def test_file_names(self):
|
||||
faulty_rules = []
|
||||
name_lst = []
|
||||
filename_pattern = re.compile('[a-z0-9_]{10,70}\.yml')
|
||||
for file in self.yield_next_rule_file_path(self.path_to_rules):
|
||||
filename = os.path.basename(file)
|
||||
if filename_pattern.match(filename) == None or not '_' in filename:
|
||||
if filename in name_lst:
|
||||
print(Fore.YELLOW + "Rule {} is a duplicate file name.".format(file))
|
||||
faulty_rules.append(file)
|
||||
elif filename[-4:] != ".yml":
|
||||
print(Fore.YELLOW + "Rule {} has a invalid extension (.yml).".format(file))
|
||||
faulty_rules.append(file)
|
||||
elif len(filename) > 74:
|
||||
print(Fore.YELLOW + "Rule {} has a file name too long >70.".format(file))
|
||||
faulty_rules.append(file)
|
||||
elif len(filename) < 14:
|
||||
print(Fore.YELLOW + "Rule {} has a file name too sort <10.".format(file))
|
||||
faulty_rules.append(file)
|
||||
elif filename_pattern.match(filename) == None or not '_' in filename:
|
||||
print(Fore.YELLOW + "Rule {} has a file name that doesn't match our standard.".format(file))
|
||||
faulty_rules.append(file)
|
||||
name_lst.append(filename)
|
||||
|
||||
self.assertEqual(faulty_rules, [], Fore.RED +
|
||||
"There are rules with malformed file names (too short, too long, uppercase letters, a minus sign etc.). Please see the file names used in our repository and adjust your file names accordingly. The pattern for a valid file name is '[a-z0-9_]{10,70}\.yml' and it has to contain at least an underline character.")
|
||||
|
Loading…
Reference in New Issue
Block a user