From b2cc4ccd0866440c348016210f77b9fe5373db2a Mon Sep 17 00:00:00 2001 From: niclas Date: Tue, 5 Mar 2024 15:33:10 +0100 Subject: [PATCH] Fix [galaxies] add version --- clusters/tidal-campaigns.json | 3 ++- clusters/tidal-groups.json | 3 ++- clusters/tidal-references.json | 3 ++- clusters/tidal-software.json | 3 ++- clusters/tidal-tactic.json | 3 ++- clusters/tidal-technique.json | 3 ++- tools/tidal-api/main.py | 10 ++++++---- tools/tidal-api/models/cluster.py | 21 +++++++++++++++------ 8 files changed, 33 insertions(+), 16 deletions(-) diff --git a/clusters/tidal-campaigns.json b/clusters/tidal-campaigns.json index ba36260..0c0636d 100644 --- a/clusters/tidal-campaigns.json +++ b/clusters/tidal-campaigns.json @@ -642,5 +642,6 @@ "uuid": "8bde8146-0656-5800-82e6-e24e008e4f4a", "value": "SolarWinds Compromise" } - ] + ], + "version": 1 } diff --git a/clusters/tidal-groups.json b/clusters/tidal-groups.json index 53185a4..2543872 100644 --- a/clusters/tidal-groups.json +++ b/clusters/tidal-groups.json @@ -10488,5 +10488,6 @@ "uuid": "5e34409e-2f55-4384-b519-80747d02394c", "value": "ZIRCONIUM" } - ] + ], + "version": 1 } diff --git a/clusters/tidal-references.json b/clusters/tidal-references.json index e084937..39b4552 100644 --- a/clusters/tidal-references.json +++ b/clusters/tidal-references.json @@ -57458,5 +57458,6 @@ "uuid": "4922dbb5-d3fd-4bf2-8af7-3b8889579c31", "value": "Sysdig Kinsing November 2020" } - ] + ], + "version": 1 } diff --git a/clusters/tidal-software.json b/clusters/tidal-software.json index 6cf642b..5cf5020 100644 --- a/clusters/tidal-software.json +++ b/clusters/tidal-software.json @@ -33305,5 +33305,6 @@ "uuid": "91e1ee26-d6ae-4203-a466-93c9e5019b47", "value": "ZxxZ" } - ] + ], + "version": 1 } diff --git a/clusters/tidal-tactic.json b/clusters/tidal-tactic.json index aaf9e9b..3432967 100644 --- a/clusters/tidal-tactic.json +++ b/clusters/tidal-tactic.json @@ -3425,5 +3425,6 @@ "uuid": "52c0edbc-ce4d-429a-b1d5-720403e0172f", "value": "Impact" } - ] + ], + "version": 1 } diff --git a/clusters/tidal-technique.json b/clusters/tidal-technique.json index f7e47b4..d626c9b 100644 --- a/clusters/tidal-technique.json +++ b/clusters/tidal-technique.json @@ -12734,5 +12734,6 @@ "uuid": "4eb755e6-41f1-4c92-b14d-87a61a446258", "value": "XSL Script Processing" } - ] + ], + "version": 1 } diff --git a/tools/tidal-api/main.py b/tools/tidal-api/main.py index 469c164..a95f9b1 100644 --- a/tools/tidal-api/main.py +++ b/tools/tidal-api/main.py @@ -38,29 +38,31 @@ def create_galaxy( uuid=galaxy.uuid, enrichment=extended_relations, subs=create_subs, + version=version, ) cluster.add_values(data) case "software": cluster = SoftwareCluster( **config["cluster"], uuid=galaxy.uuid, + version=version, enrichment=extended_relations, subs=create_subs, ) cluster.add_values(data) case "campaigns": - cluster = CampaignsCluster(**config["cluster"], uuid=galaxy.uuid) + cluster = CampaignsCluster(**config["cluster"], uuid=galaxy.uuid, version=version) cluster.add_values(data) case "technique": cluster = TechniqueCluster( - **config["cluster"], uuid=galaxy.uuid, subs=create_subs + **config["cluster"], uuid=galaxy.uuid, subs=create_subs, version=version ) cluster.add_values(data) case "tactic": - cluster = TacticCluster(**config["cluster"], uuid=galaxy.uuid) + cluster = TacticCluster(**config["cluster"], uuid=galaxy.uuid, version=version) cluster.add_values(data) case "references": - cluster = ReferencesCluster(**config["cluster"], uuid=galaxy.uuid) + cluster = ReferencesCluster(**config["cluster"], uuid=galaxy.uuid, version=version) cluster.add_values(data) case _: print("Error: Invalid endpoint") diff --git a/tools/tidal-api/models/cluster.py b/tools/tidal-api/models/cluster.py index 1877d04..9d7594f 100644 --- a/tools/tidal-api/models/cluster.py +++ b/tools/tidal-api/models/cluster.py @@ -114,6 +114,7 @@ class Cluster: source: str, type: str, uuid: str, + version: int, ): self.authors = authors self.category = category @@ -122,6 +123,7 @@ class Cluster: self.source = source self.type = type self.uuid = uuid + self.version = version self.values = [] self.CLUSTER_PATH = "../../clusters" @@ -145,6 +147,7 @@ class Cluster: "type": self.type, "uuid": self.uuid, "values": self.values, + "version": self.version, } def _get_relation_from_mitre_id( @@ -176,10 +179,11 @@ class GroupCluster(Cluster): source: str, type: str, uuid: str, + version: int, enrichment: bool = False, subs: bool = False, ): - super().__init__(authors, category, description, name, source, type, uuid) + super().__init__(authors, category, description, name, source, type, uuid, version) self.enrichment = enrichment self.subs = subs @@ -263,10 +267,11 @@ class SoftwareCluster(Cluster): source: str, type: str, uuid: str, + version: int, enrichment: bool = False, subs: bool = False, ): - super().__init__(authors, category, description, name, source, type, uuid) + super().__init__(authors, category, description, name, source, type, uuid, version) self.enrichment = enrichment self.subs = subs @@ -361,9 +366,10 @@ class TechniqueCluster(Cluster): source: str, type: str, uuid: str, + version: int, subs: bool = False, ): - super().__init__(authors, category, description, name, source, type, uuid) + super().__init__(authors, category, description, name, source, type, uuid, version) self.subs = subs def add_values(self, data): @@ -432,8 +438,9 @@ class TacticCluster(Cluster): source: str, type: str, uuid: str, + version: int, ): - super().__init__(authors, category, description, name, source, type, uuid) + super().__init__(authors, category, description, name, source, type, uuid, version) def add_values(self, data): for entry in data["data"]: @@ -472,8 +479,9 @@ class ReferencesCluster(Cluster): source: str, type: str, uuid: str, + version: int, ): - super().__init__(authors, category, description, name, source, type, uuid) + super().__init__(authors, category, description, name, source, type, uuid, version) def add_values(self, data): for entry in data["data"]: @@ -506,8 +514,9 @@ class CampaignsCluster(Cluster): source: str, type: str, uuid: str, + version: int, ): - super().__init__(authors, category, description, name, source, type, uuid) + super().__init__(authors, category, description, name, source, type, uuid, version) def add_values(self, data): for entry in data["data"]: