diff --git a/docs/guide/creating.ipynb b/docs/guide/creating.ipynb index 92a3336..6544e89 100644 --- a/docs/guide/creating.ipynb +++ b/docs/guide/creating.ipynb @@ -330,6 +330,19 @@ "indicator.name" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "\n", + "**Warning**\n", + "\n", + "Note that there are several attributes on these objects used for method names. Accessing those will return a bound method, not the attribute value.\n", + "\n", + "
\n" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1110,21 +1123,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 2", "language": "python", - "name": "python3" + "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 3 + "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.7" + "pygments_lexer": "ipython2", + "version": "2.7.15" } }, "nbformat": 4, diff --git a/stix2/properties.py b/stix2/properties.py index 340a4ba..3daa35b 100644 --- a/stix2/properties.py +++ b/stix2/properties.py @@ -11,7 +11,7 @@ from six import string_types, text_type import stix2 -from .base import _Observable, _STIXBase +from .base import _STIXBase from .core import STIX2_OBJ_MAPS, parse, parse_observable from .exceptions import ( CustomContentError, DictionaryKeyError, MissingPropertiesError, @@ -228,19 +228,6 @@ class ListProperty(Property): return result -class CallableValues(list): - """Wrapper to allow `values()` method on WindowsRegistryKey objects. - Needed because `values` is also a property. - """ - - def __init__(self, parent_instance, *args, **kwargs): - self.parent_instance = parent_instance - super(CallableValues, self).__init__(*args, **kwargs) - - def __call__(self): - return _Observable.values(self.parent_instance) - - class StringProperty(Property): def __init__(self, **kwargs): diff --git a/stix2/test/v20/test_observed_data.py b/stix2/test/v20/test_observed_data.py index a822efb..bfe9c34 100644 --- a/stix2/test/v20/test_observed_data.py +++ b/stix2/test/v20/test_observed_data.py @@ -1301,9 +1301,9 @@ def test_windows_registry_key_example(): values=[v], ) assert w.key == "hkey_local_machine\\system\\bar\\foo" - assert w.values[0].name == "Foo" - assert w.values[0].data == "qwerty" - assert w.values[0].data_type == "REG_SZ" + assert w["values"][0].name == "Foo" + assert w["values"][0].data == "qwerty" + assert w["values"][0].data_type == "REG_SZ" # ensure no errors in serialization because of 'values' assert "Foo" in str(w) diff --git a/stix2/test/v21/test_observed_data.py b/stix2/test/v21/test_observed_data.py index c1f15cd..371018c 100644 --- a/stix2/test/v21/test_observed_data.py +++ b/stix2/test/v21/test_observed_data.py @@ -1382,9 +1382,9 @@ def test_windows_registry_key_example(): values=[v], ) assert w.key == "hkey_local_machine\\system\\bar\\foo" - assert w.values[0].name == "Foo" - assert w.values[0].data == "qwerty" - assert w.values[0].data_type == "REG_SZ" + assert w["values"][0].name == "Foo" + assert w["values"][0].data == "qwerty" + assert w["values"][0].data_type == "REG_SZ" # ensure no errors in serialization because of 'values' assert "Foo" in str(w) diff --git a/stix2/v20/observables.py b/stix2/v20/observables.py index dc2b4aa..81e2c48 100644 --- a/stix2/v20/observables.py +++ b/stix2/v20/observables.py @@ -12,7 +12,7 @@ from ..base import _Extension, _Observable, _STIXBase from ..custom import _custom_extension_builder, _custom_observable_builder from ..exceptions import AtLeastOnePropertyError, DependentPropertiesError from ..properties import ( - BinaryProperty, BooleanProperty, CallableValues, DictionaryProperty, + BinaryProperty, BooleanProperty, DictionaryProperty, EmbeddedObjectProperty, EnumProperty, ExtensionsProperty, FloatProperty, HashesProperty, HexProperty, IntegerProperty, ListProperty, ObjectReferenceProperty, StringProperty, TimestampProperty, TypeProperty, @@ -723,11 +723,6 @@ class WindowsRegistryKey(_Observable): ('extensions', ExtensionsProperty(spec_version="2.0", enclosing_type=_type)), ]) - @property - def values(self): - # Needed because 'values' is a property on collections.Mapping objects - return CallableValues(self, self._inner['values']) - class X509V3ExtenstionsType(_STIXBase): """For more detailed information on this object's properties, see diff --git a/stix2/v21/observables.py b/stix2/v21/observables.py index 6f53255..1703263 100644 --- a/stix2/v21/observables.py +++ b/stix2/v21/observables.py @@ -15,7 +15,7 @@ from ..exceptions import ( AtLeastOnePropertyError, DependentPropertiesError, STIXDeprecationWarning, ) from ..properties import ( - BinaryProperty, BooleanProperty, CallableValues, DictionaryProperty, + BinaryProperty, BooleanProperty, DictionaryProperty, EmbeddedObjectProperty, EnumProperty, ExtensionsProperty, FloatProperty, HashesProperty, HexProperty, IDProperty, IntegerProperty, ListProperty, ObjectReferenceProperty, ReferenceProperty, StringProperty, @@ -935,11 +935,6 @@ class WindowsRegistryKey(_Observable): ]) _id_contributing_properties = ["key", "values"] - @property - def values(self): - # Needed because 'values' is a property on collections.Mapping objects - return CallableValues(self, self._inner['values']) - class X509V3ExtenstionsType(_STIXBase): # TODO: Add link