Fix error when printing WindowsRegistryKey
Caused by WindowsRegistryKey having a 'values' property. Fixes #236.master
parent
06e23b08b8
commit
34002c4f7c
|
@ -1290,6 +1290,8 @@ def test_windows_registry_key_example():
|
|||
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)
|
||||
|
||||
|
||||
def test_x509_certificate_example():
|
||||
|
|
|
@ -1264,6 +1264,8 @@ def test_windows_registry_key_example():
|
|||
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)
|
||||
|
||||
|
||||
def test_x509_certificate_example():
|
||||
|
|
|
@ -706,6 +706,19 @@ class WindowsRegistryValueType(_STIXBase):
|
|||
])
|
||||
|
||||
|
||||
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 WindowsRegistryKey(_Observable):
|
||||
"""For more detailed information on this object's properties, see
|
||||
`the STIX 2.0 specification <http://docs.oasis-open.org/cti/stix/v2.0/cs01/part4-cyber-observable-objects/stix-v2.0-cs01-part4-cyber-observable-objects.html#_Toc496716291>`__.
|
||||
|
@ -726,7 +739,7 @@ class WindowsRegistryKey(_Observable):
|
|||
@property
|
||||
def values(self):
|
||||
# Needed because 'values' is a property on collections.Mapping objects
|
||||
return self._inner['values']
|
||||
return CallableValues(self, self._inner['values'])
|
||||
|
||||
|
||||
class X509V3ExtenstionsType(_STIXBase):
|
||||
|
|
|
@ -758,6 +758,19 @@ class WindowsRegistryValueType(_STIXBase):
|
|||
])
|
||||
|
||||
|
||||
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 WindowsRegistryKey(_Observable):
|
||||
# TODO: Add link
|
||||
"""For more detailed information on this object's properties, see
|
||||
|
@ -779,7 +792,7 @@ class WindowsRegistryKey(_Observable):
|
|||
@property
|
||||
def values(self):
|
||||
# Needed because 'values' is a property on collections.Mapping objects
|
||||
return self._inner['values']
|
||||
return CallableValues(self, self._inner['values'])
|
||||
|
||||
|
||||
class X509V3ExtenstionsType(_STIXBase):
|
||||
|
|
Loading…
Reference in New Issue