From 939a2d542849a87ac785f8318dcdf2e74df1ab46 Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Fri, 14 Dec 2018 10:12:30 +0100 Subject: [PATCH] add: Applying interoperability parameter to v2.1 objects --- stix2/v20/bundle.py | 9 +++++++-- stix2/v21/bundle.py | 9 +++++++-- stix2/v21/common.py | 6 ++++++ stix2/v21/sdo.py | 5 +++++ stix2/v21/sro.py | 9 +++++++++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/stix2/v20/bundle.py b/stix2/v20/bundle.py index 76386ef..1a8323f 100644 --- a/stix2/v20/bundle.py +++ b/stix2/v20/bundle.py @@ -31,7 +31,12 @@ class Bundle(_STIXBase): else: kwargs['objects'] = list(args) + kwargs.get('objects', []) - self.__allow_custom = kwargs.get('allow_custom', False) - self._properties['objects'].contained.allow_custom = kwargs.get('allow_custom', False) + allow_custom = kwargs.get('allow_custom', False) + self.__allow_custom = allow_custom + self._properties['objects'].contained.allow_custom = allow_custom + interoperability = kwargs.get('interoperability', False) + self.__interoperability = interoperability + self._properties['id'].interoperability = interoperability + self._properties['objects'].contained.interoperability = interoperability super(Bundle, self).__init__(**kwargs) diff --git a/stix2/v21/bundle.py b/stix2/v21/bundle.py index c9e083a..311e50b 100644 --- a/stix2/v21/bundle.py +++ b/stix2/v21/bundle.py @@ -29,7 +29,12 @@ class Bundle(_STIXBase): else: kwargs['objects'] = list(args) + kwargs.get('objects', []) - self.__allow_custom = kwargs.get('allow_custom', False) - self._properties['objects'].contained.allow_custom = kwargs.get('allow_custom', False) + allow_custom = kwargs.get('allow_custom', False) + self.__allow_custom = allow_custom + self._properties['objects'].contained.allow_custom = allow_custom + interoperability = kwargs.get('interoperability', False) + self.__interoperability = interoperability + self._properties['id'].interoperability = interoperability + self._properties['objects'].contained.interoperability = interoperability super(Bundle, self).__init__(**kwargs) diff --git a/stix2/v21/common.py b/stix2/v21/common.py index 0aded3b..2082cc2 100644 --- a/stix2/v21/common.py +++ b/stix2/v21/common.py @@ -171,6 +171,12 @@ class MarkingDefinition(_STIXBase, _MarkingsMixin): if not isinstance(kwargs['definition'], marking_type): defn = _get_dict(kwargs['definition']) kwargs['definition'] = marking_type(**defn) + interoperability = kwargs.get('interoperability', False) + self._properties['id'].interoperability = interoperability + if kwargs.get('created_by_ref'): + self._properties['created_by_ref'].interoperability = interoperability + if kwargs.get('object_marking_refs'): + self._properties['object_marking_refs'].contained.interoperability = interoperability super(MarkingDefinition, self).__init__(**kwargs) diff --git a/stix2/v21/sdo.py b/stix2/v21/sdo.py index 37699a6..bb60d93 100644 --- a/stix2/v21/sdo.py +++ b/stix2/v21/sdo.py @@ -434,6 +434,11 @@ class Report(STIXDomainObject): ('granular_markings', ListProperty(GranularMarking)), ]) + def __init__(self, *args, **kwargs): + self._properties['object_refs'].contained.interoperability = kwargs.get('interoperability', False) + + super(Report, self).__init__(*args, **kwargs) + class ThreatActor(STIXDomainObject): # TODO: Add link diff --git a/stix2/v21/sro.py b/stix2/v21/sro.py index f947b2e..4671776 100644 --- a/stix2/v21/sro.py +++ b/stix2/v21/sro.py @@ -52,6 +52,9 @@ class Relationship(STIXRelationshipObject): kwargs['relationship_type'] = relationship_type if target_ref and not kwargs.get('target_ref'): kwargs['target_ref'] = target_ref + interoperability = kwargs.get('interoperability', False) + self._properties['source_ref'].interoperability = interoperability + self._properties['target_ref'].interoperability = interoperability super(Relationship, self).__init__(**kwargs) @@ -101,6 +104,12 @@ class Sighting(STIXRelationshipObject): # Allow sighting_of_ref as a positional arg. if sighting_of_ref and not kwargs.get('sighting_of_ref'): kwargs['sighting_of_ref'] = sighting_of_ref + interoperability = kwargs.get('interoperability', False) + self._properties['sighting_of_ref'].interoperability = interoperability + if kwargs.get('observed_data_refs'): + self._properties['observed_data_refs'].contained.interoperability = interoperability + if kwargs.get('where_sighted_refs'): + self._properties['where_sighted_refs'].contained.interoperability = interoperability super(Sighting, self).__init__(**kwargs)