fix: [galaxy] fixes issues when galaxies repo contain errors

pull/40/head
Christophe Vandeplas 2019-10-20 18:48:24 +02:00
parent 8ae7383d0c
commit f793c17974
1 changed files with 21 additions and 17 deletions

View File

@ -463,6 +463,7 @@ def galaxy_update_local_copy(force=False):
cluster_uuids = {}
for galaxy_fname in galaxies_fnames:
try:
fullPathClusters = os.path.join(local_path_clusters, galaxy_fname)
with open(fullPathClusters) as fp:
galaxy = json.load(fp)
@ -480,6 +481,9 @@ def galaxy_update_local_copy(force=False):
cluster_uuids[cluster['uuid']]['tag_name'] = 'misp-galaxy:{}="{}"'.format(galaxy['type'], cluster['value'])
if 'icon' in galaxy_main:
cluster_uuids[cluster['uuid']]['icon'] = galaxy_main['icon']
except Exception:
# we ignore incorrect galaxies
pass
with open(local_path_uuid_mapping, 'w') as f:
json.dump(cluster_uuids, f, sort_keys=True, indent=4)