Skip to content

Commit

Permalink
Merge branch 'parser_feature' of github.com:MISP/misp-stix into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisr3d committed Dec 5, 2024
2 parents 9deb708 + 765bc26 commit cc31d42
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,17 @@ def __init__(self, main: 'ExternalSTIX2toMISPParser'):
self._mapping = ExternalSTIX2IdentityMapping

def parse(self, identity_ref: str):
identity = self.main_parser._get_stix_object(identity_ref)
if getattr(identity, 'identity_class', None) == 'class':
self._parse_galaxy(identity, 'sector')
else:
name = self._fetch_identity_object_name(identity)
getattr(self, f'_parse_{name}_object')(identity)
misp_object = self._create_misp_object(name, identity)
for attribute in self._generic_parser(identity, name):
misp_object.add_attribute(**attribute)
self.main_parser._add_misp_object(misp_object, identity)
if identity_ref not in self.main_parser._creators:
identity = self.main_parser._get_stix_object(identity_ref)
if getattr(identity, 'identity_class', None) == 'class':
self._parse_galaxy(identity, 'sector')
else:
name = self._fetch_identity_object_name(identity)
getattr(self, f'_parse_{name}_object')(identity)
misp_object = self._create_misp_object(name, identity)
for attribute in self._generic_parser(identity, name):
misp_object.add_attribute(**attribute)
self.main_parser._add_misp_object(misp_object, identity)

@staticmethod
def _fetch_identity_object_name(identity: _IDENTITY_TYPING) -> str:
Expand Down
Loading

0 comments on commit cc31d42

Please sign in to comment.