Make sure custom properties are returned by object. closes #85

stix2.0
Emmanuelle Vargas-Gonzalez 2017-10-12 14:08:32 -04:00
parent 134267bfd6
commit 6deaddc04e
2 changed files with 9 additions and 1 deletions

View File

@ -40,7 +40,14 @@ class _STIXBase(collections.Mapping):
"""Base class for STIX object types"""
def object_properties(self):
return list(self._properties.keys())
props = set(self._properties.keys())
custom_props = list(set(self._inner.keys()) - props)
custom_props.sort()
all_properties = list(self._properties.keys())
all_properties.extend(custom_props) # Any custom properties to the bottom
return all_properties
def _check_property(self, prop_name, prop, kwargs):
if prop_name not in kwargs:

View File

@ -91,6 +91,7 @@ def test_custom_property_in_bundled_object():
bundle = stix2.Bundle(identity, allow_custom=True)
assert bundle.objects[0].x_foo == "bar"
assert '"x_foo": "bar"' in str(bundle)
@stix2.sdo.CustomObject('x-new-type', [