island: Use dict's `setdefault()` to shorten

`_add_config_field_to_reverse_schema()` in
config_schema_per_attack_technique.py
This commit is contained in:
Shreya Malviya 2021-09-24 12:39:15 +05:30
parent 4a65ac37ef
commit f3da34e969
1 changed files with 1 additions and 5 deletions

View File

@ -34,11 +34,7 @@ def _add_config_field_to_reverse_schema(
definition_type: str, config_field: str, attack_technique: str, reverse_schema: Dict
) -> None:
if attack_technique in reverse_schema:
technique = reverse_schema[attack_technique]
if definition_type in technique:
technique[definition_type].append(config_field)
else:
technique[definition_type] = [config_field]
reverse_schema[attack_technique].setdefault(definition_type, []).append(config_field)
else:
reverse_schema[attack_technique] = {definition_type: [config_field]}