Add _id_contributing_properties functionality to custom SCOs. Tests coming soon. Fixes #351

master
Desai, Kartikey H 2020-02-24 21:11:42 -05:00
parent c2b71672f5
commit 41e541959d
2 changed files with 5 additions and 3 deletions

View File

@ -53,7 +53,7 @@ def _custom_marking_builder(cls, type, properties, version):
return _CustomMarking
def _custom_observable_builder(cls, type, properties, version):
def _custom_observable_builder(cls, type, properties, version, id_contrib_props=[]):
class _CustomObservable(cls, _Observable):
if not re.match(TYPE_REGEX, type):
@ -98,6 +98,8 @@ def _custom_observable_builder(cls, type, properties, version):
_type = type
_properties = OrderedDict(properties)
if version != '2.0':
_id_contributing_properties = id_contrib_props
def __init__(self, **kwargs):
_Observable.__init__(self, **kwargs)

View File

@ -966,7 +966,7 @@ class X509Certificate(_Observable):
self._check_at_least_one_property(att_list)
def CustomObservable(type='x-custom-observable', properties=None):
def CustomObservable(type='x-custom-observable', properties=None, id_contrib_props=[]):
"""Custom STIX Cyber Observable Object type decorator.
Example:
@ -987,7 +987,7 @@ def CustomObservable(type='x-custom-observable', properties=None):
properties,
[('extensions', ExtensionsProperty(spec_version='2.1', enclosing_type=type))],
]))
return _custom_observable_builder(cls, type, _properties, '2.1')
return _custom_observable_builder(cls, type, _properties, '2.1', id_contrib_props)
return wrapper