From 28c00d6541287ef8c5e206ede1a7cb991dabd5dc Mon Sep 17 00:00:00 2001 From: Christophe Vandeplas Date: Mon, 13 May 2024 13:52:40 +0200 Subject: [PATCH] chg: [mitre] added TODO about more metadata that breaks things --- tools/gen_mitre.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/gen_mitre.py b/tools/gen_mitre.py index 9d7ad39..2e0639b 100755 --- a/tools/gen_mitre.py +++ b/tools/gen_mitre.py @@ -146,12 +146,6 @@ for domain in domains: if item['type'] not in types.values(): continue - # skip deprecated and/or revoked - # if 'revoked' in item and item['revoked']: - # continue - # if 'x_mitre_deprecated' in item and item['x_mitre_deprecated']: - # continue - # print(json.dumps(item, indent=2, sort_keys=True, ensure_ascii=False)) try: # build the new data structure @@ -178,6 +172,12 @@ for domain in domains: if 'x_mitre_aliases' in item: value['meta']['synonyms'] = item['x_mitre_aliases'] + # handle deprecated and/or revoked + # if 'x_mitre_deprecated' in item and item['x_mitre_deprecated']: + # value['deprecated'] = True + # if 'revoked' in item and item['revoked']: + # value['revoked'] = True + if 'external_references' in item: for reference in item['external_references']: if 'url' in reference and reference['url'] not in value['meta']['refs']: @@ -205,9 +205,9 @@ for domain in domains: value['meta']['mitre_data_sources'] = item['x_mitre_data_sources'] if 'x_mitre_platforms' in item: value['meta']['mitre_platforms'] = item['x_mitre_platforms'] - # TODO add the other x_mitre elements dynamically + # TODO add the other x_mitre elements dynamically, but now it seems to break the tests # x_mitre_fields = [key for key in item.keys() if key.startswith('x_mitre')] - # skip_x_mitre_fields = ['x_mitre_aliases', 'x_mitre_version', 'x_mitre_old_attack_id', 'mitre_attack_spec_version'] + # skip_x_mitre_fields = ['x_mitre_deprecated', 'x_mitre_aliases', 'x_mitre_version', 'x_mitre_old_attack_id', 'x_mitre_attack_spec_version'] # for skip_field in skip_x_mitre_fields: # try: # x_mitre_fields.remove(skip_field) @@ -220,7 +220,6 @@ for domain in domains: value['type'] = item['type'] # remove this before dump to json # print(json.dumps(value, sort_keys=True, indent=2)) - # FIXME if 'x_mitre_deprecated' , 'revoked' all_data_uuid[uuid] = value except Exception: