6
0
Fork 0
mirror of https://github.com/MISP/misp-galaxy.git synced 2024-12-04 20:57:18 +00:00
misp-galaxy/tools/del_duplicate_uuids.py

27 lines
504 B
Python
Raw Normal View History

#!/usr/bin/env python3
# coding=utf-8
"""
Tool to remove duplicates in cluster references
"""
import sys
import json
with open(sys.argv[1], 'r') as f:
data = json.load(f)
unique_uuid = set()
values = []
for c in data['values']:
if c['uuid'] in unique_uuid:
sys.stderr.write(f"Duplicate UUID - {c['uuid']}\n")
continue
unique_uuid.add(c['uuid'])
values.append(c)
data['values'] = []
data['values'] = values
with open(sys.argv[1], 'w') as f:
json.dump(data, f)