Browse Source

fix: automatically fix missing uuids

pull/283/head
Christophe Vandeplas 2 years ago
parent
commit
65eb66a739
4 changed files with 10 additions and 5 deletions
  1. +1
    -0
      clusters/botnet.json
  2. +2
    -2
      clusters/malpedia.json
  3. +1
    -0
      jq_all_the_things.sh
  4. +6
    -3
      tools/add_missing_uuid.py

+ 1
- 0
clusters/botnet.json View File

@@ -899,6 +899,7 @@
"https://www.bleepingcomputer.com/news/security/new-iot-botnet-torii-uses-six-methods-for-persistence-has-no-clear-purpose/"
]
},
"uuid": "92f38212-94e2-4d70-9b5e-e977eb1e7b79",
"value": "Torii"
},
{


+ 2
- 2
clusters/malpedia.json View File

@@ -13413,7 +13413,7 @@
"synonyms": [],
"type": []
},
"uuid": "",
"uuid": "39f609e3-e6fe-4c2c-af0e-b28bc81b2ecf",
"value": ""
},
{
@@ -14429,7 +14429,7 @@
"synonyms": [],
"type": []
},
"uuid": "",
"uuid": "4db80a62-d318-48e7-b70b-759924ff515e",
"value": ""
},
{


+ 1
- 0
jq_all_the_things.sh View File

@@ -17,6 +17,7 @@ set -x

for dir in clusters/*.json
do
python3 tools/add_missing_uuid.py -f ${dir}
# Beautify it
cat ${dir} | jq --sort-keys . | sponge ${dir}
done


+ 6
- 3
tools/add_missing_uuid.py View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
@@ -9,13 +9,16 @@ parser = argparse.ArgumentParser(description='Add missing uuids in clusters')
parser.add_argument("-f", "--filename", required=True, help="name of the cluster")
args = parser.parse_args()

if 'mitre-' in args.filename:
exit()

with open(args.filename) as json_file:
data = json.load(json_file)
json_file.close()

for value in data['values']:
if 'uuid' not in value:
if not value.get('uuid'):
value['uuid'] = str(uuid.uuid4())

with open(args.filename, 'w') as json_file:
json.dump(data, json_file, indent=4)
json.dump(data, json_file, indent=2, sort_keys=True, ensure_ascii=False)

Loading…
Cancel
Save