Minor readability changes in config service

This commit is contained in:
VakarisZ 2019-05-22 10:31:57 +03:00
parent 6c97b44b69
commit f9c4b3e180
1 changed files with 7 additions and 14 deletions

View File

@ -55,13 +55,9 @@ class AttackConfig(object):
for key, definition in monkey_schema['definitions'].items(): for key, definition in monkey_schema['definitions'].items():
for array_field in definition['anyOf']: for array_field in definition['anyOf']:
# Check if current array field has attack_techniques assigned to it # Check if current array field has attack_techniques assigned to it
if 'attack_techniques' not in array_field: if 'attack_techniques' in array_field:
continue should_remove = not AttackConfig.should_enable_field(array_field['attack_techniques'],
try: attack_techniques)
should_remove = not AttackConfig.should_enable_field(array_field['attack_techniques'], attack_techniques)
except KeyError:
# Monkey schema field contains not yet implemented technique
continue
# If exploiter's attack technique is disabled, disable the exploiter/scanner/PBA # If exploiter's attack technique is disabled, disable the exploiter/scanner/PBA
AttackConfig.r_alter_array(monkey_config, key, array_field['enum'][0], remove=should_remove) AttackConfig.r_alter_array(monkey_config, key, array_field['enum'][0], remove=should_remove)
@ -127,9 +123,6 @@ class AttackConfig(object):
:param users_techniques: ATT&CK techniques that user chose :param users_techniques: ATT&CK techniques that user chose
:return: True, if user enabled all techniques used by the field, false otherwise :return: True, if user enabled all techniques used by the field, false otherwise
""" """
# Method can't decide field value because it has no attack techniques assign to it.
if not field_techniques:
raise KeyError
for technique in field_techniques: for technique in field_techniques:
if not users_techniques[technique]: if not users_techniques[technique]:
return False return False