Merge branch 'master' of github.com:oasis-open/cti-python-stix2
commit
5aaf07702d
|
@ -330,6 +330,19 @@
|
||||||
"indicator.name"
|
"indicator.name"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"<div class=\"alert alert-warning\">\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",
|
||||||
|
"</div>\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
|
@ -1110,21 +1123,21 @@
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 3",
|
"display_name": "Python 2",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python3"
|
"name": "python2"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"codemirror_mode": {
|
"codemirror_mode": {
|
||||||
"name": "ipython",
|
"name": "ipython",
|
||||||
"version": 3
|
"version": 2
|
||||||
},
|
},
|
||||||
"file_extension": ".py",
|
"file_extension": ".py",
|
||||||
"mimetype": "text/x-python",
|
"mimetype": "text/x-python",
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython2",
|
||||||
"version": "3.6.7"
|
"version": "2.7.15"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|
|
@ -11,7 +11,7 @@ from six import string_types, text_type
|
||||||
|
|
||||||
import stix2
|
import stix2
|
||||||
|
|
||||||
from .base import _Observable, _STIXBase
|
from .base import _STIXBase
|
||||||
from .core import STIX2_OBJ_MAPS, parse, parse_observable
|
from .core import STIX2_OBJ_MAPS, parse, parse_observable
|
||||||
from .exceptions import (
|
from .exceptions import (
|
||||||
CustomContentError, DictionaryKeyError, MissingPropertiesError,
|
CustomContentError, DictionaryKeyError, MissingPropertiesError,
|
||||||
|
@ -228,19 +228,6 @@ class ListProperty(Property):
|
||||||
return result
|
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):
|
class StringProperty(Property):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
|
@ -1301,9 +1301,9 @@ def test_windows_registry_key_example():
|
||||||
values=[v],
|
values=[v],
|
||||||
)
|
)
|
||||||
assert w.key == "hkey_local_machine\\system\\bar\\foo"
|
assert w.key == "hkey_local_machine\\system\\bar\\foo"
|
||||||
assert w.values[0].name == "Foo"
|
assert w["values"][0].name == "Foo"
|
||||||
assert w.values[0].data == "qwerty"
|
assert w["values"][0].data == "qwerty"
|
||||||
assert w.values[0].data_type == "REG_SZ"
|
assert w["values"][0].data_type == "REG_SZ"
|
||||||
# ensure no errors in serialization because of 'values'
|
# ensure no errors in serialization because of 'values'
|
||||||
assert "Foo" in str(w)
|
assert "Foo" in str(w)
|
||||||
|
|
||||||
|
|
|
@ -1382,9 +1382,9 @@ def test_windows_registry_key_example():
|
||||||
values=[v],
|
values=[v],
|
||||||
)
|
)
|
||||||
assert w.key == "hkey_local_machine\\system\\bar\\foo"
|
assert w.key == "hkey_local_machine\\system\\bar\\foo"
|
||||||
assert w.values[0].name == "Foo"
|
assert w["values"][0].name == "Foo"
|
||||||
assert w.values[0].data == "qwerty"
|
assert w["values"][0].data == "qwerty"
|
||||||
assert w.values[0].data_type == "REG_SZ"
|
assert w["values"][0].data_type == "REG_SZ"
|
||||||
# ensure no errors in serialization because of 'values'
|
# ensure no errors in serialization because of 'values'
|
||||||
assert "Foo" in str(w)
|
assert "Foo" in str(w)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ from ..base import _Extension, _Observable, _STIXBase
|
||||||
from ..custom import _custom_extension_builder, _custom_observable_builder
|
from ..custom import _custom_extension_builder, _custom_observable_builder
|
||||||
from ..exceptions import AtLeastOnePropertyError, DependentPropertiesError
|
from ..exceptions import AtLeastOnePropertyError, DependentPropertiesError
|
||||||
from ..properties import (
|
from ..properties import (
|
||||||
BinaryProperty, BooleanProperty, CallableValues, DictionaryProperty,
|
BinaryProperty, BooleanProperty, DictionaryProperty,
|
||||||
EmbeddedObjectProperty, EnumProperty, ExtensionsProperty, FloatProperty,
|
EmbeddedObjectProperty, EnumProperty, ExtensionsProperty, FloatProperty,
|
||||||
HashesProperty, HexProperty, IntegerProperty, ListProperty,
|
HashesProperty, HexProperty, IntegerProperty, ListProperty,
|
||||||
ObjectReferenceProperty, StringProperty, TimestampProperty, TypeProperty,
|
ObjectReferenceProperty, StringProperty, TimestampProperty, TypeProperty,
|
||||||
|
@ -723,11 +723,6 @@ class WindowsRegistryKey(_Observable):
|
||||||
('extensions', ExtensionsProperty(spec_version="2.0", enclosing_type=_type)),
|
('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):
|
class X509V3ExtenstionsType(_STIXBase):
|
||||||
"""For more detailed information on this object's properties, see
|
"""For more detailed information on this object's properties, see
|
||||||
|
|
|
@ -15,7 +15,7 @@ from ..exceptions import (
|
||||||
AtLeastOnePropertyError, DependentPropertiesError, STIXDeprecationWarning,
|
AtLeastOnePropertyError, DependentPropertiesError, STIXDeprecationWarning,
|
||||||
)
|
)
|
||||||
from ..properties import (
|
from ..properties import (
|
||||||
BinaryProperty, BooleanProperty, CallableValues, DictionaryProperty,
|
BinaryProperty, BooleanProperty, DictionaryProperty,
|
||||||
EmbeddedObjectProperty, EnumProperty, ExtensionsProperty, FloatProperty,
|
EmbeddedObjectProperty, EnumProperty, ExtensionsProperty, FloatProperty,
|
||||||
HashesProperty, HexProperty, IDProperty, IntegerProperty, ListProperty,
|
HashesProperty, HexProperty, IDProperty, IntegerProperty, ListProperty,
|
||||||
ObjectReferenceProperty, ReferenceProperty, StringProperty,
|
ObjectReferenceProperty, ReferenceProperty, StringProperty,
|
||||||
|
@ -935,11 +935,6 @@ class WindowsRegistryKey(_Observable):
|
||||||
])
|
])
|
||||||
_id_contributing_properties = ["key", "values"]
|
_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):
|
class X509V3ExtenstionsType(_STIXBase):
|
||||||
# TODO: Add link
|
# TODO: Add link
|
||||||
|
|
Loading…
Reference in New Issue