Move 'extensions' property to custom Observables

... from custom Observable extensions (an extension doesn't need an
'extensions' property).
stix2.0
Chris Lenk 2018-04-09 15:18:29 -04:00
parent b851afba01
commit 5c5ca1f21c
2 changed files with 9 additions and 3 deletions

View File

@ -602,3 +602,8 @@ def test_register_custom_object():
stix2._register_type(CustomObject2)
# Note that we will always check against newest OBJ_MAP.
assert (CustomObject2._type, CustomObject2) in stix2.OBJ_MAP.items()
def test_extension_property_location():
assert 'extensions' in stix2.v20.observables.OBJ_MAP_OBSERVABLE['x-new-observable']._properties
assert 'extensions' not in stix2.v20.observables.EXT_MAP['domain-name']['x-new-ext']._properties

View File

@ -979,6 +979,9 @@ def CustomObservable(type='x-custom-observable', properties=None):
"is not a ListProperty containing ObjectReferenceProperty." % prop_name)
_properties.update(properties)
_properties.update([
('extensions', ExtensionsProperty(enclosing_type=_type)),
])
def __init__(self, **kwargs):
_Observable.__init__(self, **kwargs)
@ -1030,9 +1033,7 @@ def CustomExtension(observable=None, type='x-custom-observable', properties=None
class _Custom(cls, _Extension):
_type = type
_properties = {
'extensions': ExtensionsProperty(enclosing_type=_type),
}
_properties = OrderedDict()
if not properties or not isinstance(properties, list):
raise ValueError("Must supply a list, containing tuples. For example, [('property1', IntegerProperty())]")