mirror of
https://github.com/MISP/misp-galaxy.git
synced 2024-11-26 00:37:18 +00:00
fix: automatically fix missing uuids
This commit is contained in:
parent
2fbd8ce485
commit
65eb66a739
4 changed files with 10 additions and 5 deletions
|
@ -899,6 +899,7 @@
|
||||||
"https://www.bleepingcomputer.com/news/security/new-iot-botnet-torii-uses-six-methods-for-persistence-has-no-clear-purpose/"
|
"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"
|
"value": "Torii"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -13413,7 +13413,7 @@
|
||||||
"synonyms": [],
|
"synonyms": [],
|
||||||
"type": []
|
"type": []
|
||||||
},
|
},
|
||||||
"uuid": "",
|
"uuid": "39f609e3-e6fe-4c2c-af0e-b28bc81b2ecf",
|
||||||
"value": ""
|
"value": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -14429,7 +14429,7 @@
|
||||||
"synonyms": [],
|
"synonyms": [],
|
||||||
"type": []
|
"type": []
|
||||||
},
|
},
|
||||||
"uuid": "",
|
"uuid": "4db80a62-d318-48e7-b70b-759924ff515e",
|
||||||
"value": ""
|
"value": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@ set -x
|
||||||
|
|
||||||
for dir in clusters/*.json
|
for dir in clusters/*.json
|
||||||
do
|
do
|
||||||
|
python3 tools/add_missing_uuid.py -f ${dir}
|
||||||
# Beautify it
|
# Beautify it
|
||||||
cat ${dir} | jq --sort-keys . | sponge ${dir}
|
cat ${dir} | jq --sort-keys . | sponge ${dir}
|
||||||
done
|
done
|
||||||
|
|
9
tools/add_missing_uuid.py
Normal file → Executable file
9
tools/add_missing_uuid.py
Normal file → Executable file
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import json
|
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")
|
parser.add_argument("-f", "--filename", required=True, help="name of the cluster")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if 'mitre-' in args.filename:
|
||||||
|
exit()
|
||||||
|
|
||||||
with open(args.filename) as json_file:
|
with open(args.filename) as json_file:
|
||||||
data = json.load(json_file)
|
data = json.load(json_file)
|
||||||
json_file.close()
|
json_file.close()
|
||||||
|
|
||||||
for value in data['values']:
|
for value in data['values']:
|
||||||
if 'uuid' not in value:
|
if not value.get('uuid'):
|
||||||
value['uuid'] = str(uuid.uuid4())
|
value['uuid'] = str(uuid.uuid4())
|
||||||
|
|
||||||
with open(args.filename, 'w') as json_file:
|
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…
Reference in a new issue