island: Use '.get()' when accessing value in dictionary during reverse schema generation

This commit is contained in:
Shreya Malviya 2021-10-13 18:18:47 +05:30
parent b24b8439c5
commit 08e57f3824
1 changed files with 3 additions and 3 deletions

View File

@ -25,7 +25,7 @@ def _crawl_config_schema_definitions_for_reverse_schema(schema: Dict, reverse_sc
definitions = schema["definitions"]
for definition in definitions:
definition_type = definitions[definition]["title"]
for field in definitions[definition]["anyOf"]:
for field in definitions[definition].get("anyOf", []):
config_field = field["title"]
for attack_technique in field.get("attack_techniques", []):
_add_config_field_to_reverse_schema(
@ -37,9 +37,9 @@ def _crawl_config_schema_properties_for_reverse_schema(schema: Dict, reverse_sch
properties = schema["properties"]
for prop in properties:
property_type = properties[prop]["title"]
for category_name in properties[prop]["properties"]:
for category_name in properties[prop].get("properties", []):
category = properties[prop]["properties"][category_name]
for config_option_name in category["properties"]:
for config_option_name in category.get("properties", []):
config_option = category["properties"][config_option_name]
for attack_technique in config_option.get("related_attack_techniques", []):
# No config values could be a reason that related attack techniques are left