Add _id_contributing_properties functionality to custom SCOs. Tests coming soon. Fixes #351
parent
c2b71672f5
commit
41e541959d
|
@ -53,7 +53,7 @@ def _custom_marking_builder(cls, type, properties, version):
|
||||||
return _CustomMarking
|
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):
|
class _CustomObservable(cls, _Observable):
|
||||||
|
|
||||||
if not re.match(TYPE_REGEX, type):
|
if not re.match(TYPE_REGEX, type):
|
||||||
|
@ -98,6 +98,8 @@ def _custom_observable_builder(cls, type, properties, version):
|
||||||
|
|
||||||
_type = type
|
_type = type
|
||||||
_properties = OrderedDict(properties)
|
_properties = OrderedDict(properties)
|
||||||
|
if version != '2.0':
|
||||||
|
_id_contributing_properties = id_contrib_props
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
_Observable.__init__(self, **kwargs)
|
_Observable.__init__(self, **kwargs)
|
||||||
|
|
|
@ -966,7 +966,7 @@ class X509Certificate(_Observable):
|
||||||
self._check_at_least_one_property(att_list)
|
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.
|
"""Custom STIX Cyber Observable Object type decorator.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
@ -987,7 +987,7 @@ def CustomObservable(type='x-custom-observable', properties=None):
|
||||||
properties,
|
properties,
|
||||||
[('extensions', ExtensionsProperty(spec_version='2.1', enclosing_type=type))],
|
[('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
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue