mirror of https://github.com/MISP/PyMISP
chg: Don't parse the meta key into cluster elements on a MISPEvent, but allow users to manually perform this action
parent
a94b81ae72
commit
5445479960
|
@ -1195,6 +1195,7 @@ class MISPGalaxyCluster(AbstractMISP):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.Galaxy: MISPGalaxy
|
self.Galaxy: MISPGalaxy
|
||||||
self.GalaxyElement: List[MISPGalaxyClusterElement] = []
|
self.GalaxyElement: List[MISPGalaxyClusterElement] = []
|
||||||
|
self.meta = {}
|
||||||
self.GalaxyClusterRelation: List[MISPGalaxyClusterRelation] = []
|
self.GalaxyClusterRelation: List[MISPGalaxyClusterRelation] = []
|
||||||
self.Org: MISPOrganisation
|
self.Org: MISPOrganisation
|
||||||
self.Orgc: MISPOrganisation
|
self.Orgc: MISPOrganisation
|
||||||
|
@ -1218,8 +1219,18 @@ class MISPGalaxyCluster(AbstractMISP):
|
||||||
def cluster_relations(self, cluster_relations: List[MISPGalaxyClusterRelation]):
|
def cluster_relations(self, cluster_relations: List[MISPGalaxyClusterRelation]):
|
||||||
self.GalaxyClusterRelation = cluster_relations
|
self.GalaxyClusterRelation = cluster_relations
|
||||||
|
|
||||||
|
def parse_meta_as_elements(self):
|
||||||
|
"""Function to parse the meta field into GalaxyClusterElements"""
|
||||||
|
# Parse the cluster elements from the kwargs meta fields
|
||||||
|
for key, value in self.meta.items():
|
||||||
|
# The meta will merge fields together, i.e. Two 'countries' will be a list, so split these up
|
||||||
|
if not isinstance(value, list):
|
||||||
|
value = [value]
|
||||||
|
for v in value:
|
||||||
|
self.add_cluster_element(key=key, value=v)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def meta(self) -> Dict:
|
def elements_meta(self) -> Dict:
|
||||||
"""Function to return the galaxy cluster elements as a dictionary structure of lists
|
"""Function to return the galaxy cluster elements as a dictionary structure of lists
|
||||||
that comes from a MISPGalaxy within a MISPEvent. Lossy, you lose the element ID
|
that comes from a MISPGalaxy within a MISPEvent. Lossy, you lose the element ID
|
||||||
"""
|
"""
|
||||||
|
@ -1260,13 +1271,7 @@ class MISPGalaxyCluster(AbstractMISP):
|
||||||
if 'uuid' in kwargs:
|
if 'uuid' in kwargs:
|
||||||
self.uuid = kwargs.pop('uuid')
|
self.uuid = kwargs.pop('uuid')
|
||||||
if 'meta' in kwargs:
|
if 'meta' in kwargs:
|
||||||
# Parse the cluster elements from the kwargs meta fields
|
self.meta = kwargs.pop('meta')
|
||||||
for key, value in kwargs.pop('meta').items():
|
|
||||||
# The meta will merge fields together, i.e. Two 'countries' will be a list, so split these up
|
|
||||||
if not isinstance(value, list):
|
|
||||||
value = [value]
|
|
||||||
for v in value:
|
|
||||||
self.add_cluster_element(key=key, value=v)
|
|
||||||
if 'Galaxy' in kwargs:
|
if 'Galaxy' in kwargs:
|
||||||
self.Galaxy = MISPGalaxy()
|
self.Galaxy = MISPGalaxy()
|
||||||
self.Galaxy.from_dict(**kwargs.pop('Galaxy'))
|
self.Galaxy.from_dict(**kwargs.pop('Galaxy'))
|
||||||
|
|
Loading…
Reference in New Issue