bugfix for using lowercase platform in data source yaml file, bugfix for having empty score logbook in techniques yaml file, small code style improvement
parent
2c6f83f069
commit
68699a9e06
11
generic.py
11
generic.py
|
@ -386,7 +386,7 @@ def backup_file(filename):
|
|||
suffix = 1
|
||||
backup_filename = filename.replace('.yaml', '_backup_' + str(suffix) + '.yaml')
|
||||
while os.path.exists(backup_filename):
|
||||
backup_filename = backup_filename.replace('_backup_' + str(suffix) + '.yaml', '_backup_' + str(suffix+1) + '.yaml')
|
||||
backup_filename = backup_filename.replace('_backup_' + str(suffix) + '.yaml', '_backup_' + str(suffix + 1) + '.yaml')
|
||||
suffix += 1
|
||||
|
||||
shutil.copy2(filename, backup_filename)
|
||||
|
@ -470,7 +470,7 @@ def ask_multiple_choice(question, list_answers):
|
|||
answer = input(' >> ')
|
||||
print('')
|
||||
|
||||
return list_answers[int(answer)-1]
|
||||
return list_answers[int(answer) - 1]
|
||||
|
||||
|
||||
def fix_date_and_remove_null(yaml_file, date, input_type='ruamel'):
|
||||
|
@ -613,8 +613,7 @@ def get_applicable_data_sources_platform(platforms):
|
|||
"""
|
||||
applicable_data_sources = set()
|
||||
if platforms == 'all' or 'all' in platforms:
|
||||
# pylint: disable=unused-variable
|
||||
for k, v in DATA_SOURCES.items():
|
||||
for v in DATA_SOURCES.values():
|
||||
applicable_data_sources.update(v)
|
||||
else:
|
||||
for p in platforms:
|
||||
|
@ -693,7 +692,7 @@ def calculate_score(list_detections, zero_value=0):
|
|||
number = 0
|
||||
for v in list_detections:
|
||||
score = get_latest_score(v)
|
||||
if score >= 0:
|
||||
if score and score >= 0:
|
||||
avg_score += score
|
||||
number += 1
|
||||
|
||||
|
@ -977,7 +976,7 @@ def get_statistics_data_sources():
|
|||
data_sources_dict_sorted = dict(sorted(data_sources_dict.items(), key=lambda kv: kv[1]['count'], reverse=True))
|
||||
str_format = '{:<6s} {:s}'
|
||||
print(str_format.format('Count', 'Data Source'))
|
||||
print('-'*50)
|
||||
print('-' * 50)
|
||||
for k, v in data_sources_dict_sorted.items():
|
||||
print(str_format.format(str(v['count']), k))
|
||||
|
||||
|
|
|
@ -113,7 +113,14 @@ def check_health_data_sources(filename, ds_content, health_is_called, no_print=F
|
|||
health_is_called)
|
||||
|
||||
ds_list = [kv['data_source_name'].lower() for kv in ds_content['data_sources']]
|
||||
applicable_data_sources = get_applicable_data_sources_platform(platform)
|
||||
|
||||
# For using the platform variable, we need first-letter-capital values and we don't need the 'empty' value from the check above.
|
||||
valid_platform_list = []
|
||||
for p in platform:
|
||||
if p in PLATFORMS.keys():
|
||||
valid_platform_list.append(PLATFORMS[p])
|
||||
|
||||
applicable_data_sources = get_applicable_data_sources_platform(valid_platform_list)
|
||||
for ds in applicable_data_sources:
|
||||
if ds.lower() not in ds_list:
|
||||
has_error = _print_error_msg('[!] Data source: \'' + ds + '\' is MISSING from the YAML file', health_is_called)
|
||||
|
|
Loading…
Reference in New Issue