From 059de052ad43114558bd594fb9c2bf5c35a498f7 Mon Sep 17 00:00:00 2001 From: niclas Date: Tue, 20 Feb 2024 11:56:55 +0100 Subject: [PATCH] chg [tidal] only generate set metadata --- tools/tidal-api/create_campaigns.py | 26 +++++++++++++++++----- tools/tidal-api/create_groups.py | 34 ++++++++++++++++++++++------- tools/tidal-api/create_software.py | 26 +++++++++++++++++----- 3 files changed, 66 insertions(+), 20 deletions(-) diff --git a/tools/tidal-api/create_campaigns.py b/tools/tidal-api/create_campaigns.py index 9604361..8b6123c 100644 --- a/tools/tidal-api/create_campaigns.py +++ b/tools/tidal-api/create_campaigns.py @@ -26,13 +26,27 @@ def create_cluster(galaxy, data): value["description"] = campaigns["description"] + # Metadata fields + source = campaigns["source"] + campaign_attack_id = campaigns["campaign_attack_id"] + first_seen = campaigns["first_seen"] + last_seen = campaigns["last_seen"] + tags = campaigns["tags"] + owner = campaigns["owner_name"] + value["meta"] = {} - value["meta"]["source"] = campaigns["source"] - value["meta"]["campaign-attack-id"] = campaigns["campaign_attack_id"] - value["meta"]["first-seen"] = campaigns["first_seen"] - value["meta"]["last-seen"] = campaigns["last_seen"] - value["meta"]["tags"] = campaigns["tags"] - value["meta"]["owner"] = campaigns["owner_name"] + if source: + value["meta"]["source"] = source + if campaign_attack_id: + value["meta"]["campaign-attack-id"] = campaign_attack_id + if first_seen: + value["meta"]["first-seen"] = first_seen + if last_seen: + value["meta"]["last-seen"] = last_seen + if tags: + value["meta"]["tags"] = tags + if owner: + value["meta"]["owner"] = owner value["related"] = relations value["uuid"] = campaigns["id"] diff --git a/tools/tidal-api/create_groups.py b/tools/tidal-api/create_groups.py index 940053a..163d80f 100644 --- a/tools/tidal-api/create_groups.py +++ b/tools/tidal-api/create_groups.py @@ -33,15 +33,33 @@ def create_cluster(galaxy, data): value["description"] = group["description"] + # Metadata fields + source = group["source"] + group_attack_id = group["group_attack_id"] + country = [country["country_name"] for country in group["country"]] + observed_country = [country["country_code"] for country in group["observed_country"]] + motive = [motive["name"] for motive in group["observed_motivation"]] + target_category = [sector["name"] for sector in group["observed_sector"]] + tags = group["tags"] + owner = group["owner_name"] + value["meta"] = {} - value["meta"]["source"] = group["source"] - value["meta"]["group-attack-id"] = group["group_attack_id"] - value["meta"]["country"] = [country["country_code"] for country in group["country"]] - value["meta"]["observed_country"] = [country["country_code"] for country in group["observed_country"]] - value["meta"]["motive"] = [motive["name"] for motive in group["observed_motivation"]] - value["meta"]["target-category"] = [sector["name"] for sector in group["observed_sector"]] - value["meta"]["tags"] = group["tags"] - value["meta"]["owner"] = group["owner_name"] + if source: + value["meta"]["source"] = source + if group_attack_id: + value["meta"]["group-attack-id"] = group_attack_id + if country: + value["meta"]["country"] = country + if observed_country: + value["meta"]["observed_country"] = observed_country + if motive: + value["meta"]["motive"] = motive + if target_category: + value["meta"]["target-category"] = target_category + if tags: + value["meta"]["tags"] = tags + if owner: + value["meta"]["owner"] = owner value["related"] = relations value["uuid"] = group["id"] diff --git a/tools/tidal-api/create_software.py b/tools/tidal-api/create_software.py index 1219c21..9cebad3 100644 --- a/tools/tidal-api/create_software.py +++ b/tools/tidal-api/create_software.py @@ -37,13 +37,27 @@ def create_cluster(galaxy, data): value["description"] = software["description"] + # Metadata fields + source = software["source"] + type = software["type"] + software_attack_id = software["software_attack_id"] + platforms = software["platforms"] + tags = software["tags"] + owner = software["owner_name"] + value["meta"] = {} - value["meta"]["source"] = software["source"] - value["meta"]["type"] = software["type"] - value["meta"]["software-attack-id"] = software["software_attack_id"] - value["meta"]["platforms"] = software["platforms"] - value["meta"]["tags"] = software["tags"] - value["meta"]["owner"] = software["owner_name"] + if source: + value["meta"]["source"] = source + if type: + value["meta"]["type"] = type + if software_attack_id: + value["meta"]["software-attack-id"] = software_attack_id + if platforms: + value["meta"]["platforms"] = platforms + if tags: + value["meta"]["tags"] = tags + if owner: + value["meta"]["owner"] = owner value["related"] = relations value["uuid"] = software["id"]