Skip to content

Commit 8168ad3

Browse files
committed
Updated AssociatedObject for CybOX 2.0
1 parent f8fb362 commit 8168ad3

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

cybox/core/associated_object.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Copyright (c) 2013, The MITRE Corporation. All rights reserved.
22
# See LICENSE.txt for complete terms.
33

4+
import cybox
45
import cybox.utils as utils
5-
import cybox.bindings.cybox_core_1_0 as core_binding
6+
import cybox.bindings.cybox_core as core_binding
67
from cybox.core.object import Object
8+
from cybox.common import VocabString
79

810
class AssociatedObject(Object):
911

@@ -18,7 +20,7 @@ def __init__(self, type_=None, association_type_=None, defined_object=None):
1820

1921
def to_obj(self):
2022
obj = super(AssociatedObject, self).to_obj(core_binding.AssociatedObjectType())
21-
obj.set_association_type(self.association_type_)
23+
obj.set_Association_Type(self.association_type_.to_obj())
2224
return obj
2325

2426
def to_dict(self):
@@ -31,29 +33,13 @@ def from_obj(object_obj):
3133
if not object_obj:
3234
return None
3335
obj = Object.from_obj(object_obj, AssociatedObject())
34-
obj.association_type_ = object_obj.get_association_type()
36+
obj.association_type_ = VocabString.from_obj(object_obj.get_association_type())
3537
return obj
3638

3739
@staticmethod
3840
def from_dict(object_dict):
3941
if not object_dict:
4042
return None
4143
obj = Object.from_dict(object_dict, AssociatedObject())
42-
obj.association_type_ = object_dict.get('association_type', None)
43-
return obj
44-
45-
46-
#@classmethod
47-
#def object_from_dict(cls, associated_object_dict):
48-
# """Create the Associated Object Python object representation from an input dictionary"""
49-
# associated_obj = Object.object_from_dict(associated_object_dict,core_binding.AssociatedObjectType())
50-
# for key, value in associated_object_dict.items():
51-
# if key == 'association_type' and utils.test_value(value): associated_obj.set_association_type(value)
52-
# return associated_obj
53-
54-
#@classmethod
55-
#def dict_from_object(cls, associated_obj):
56-
# """Parse and return a dictionary for an Associated Object"""
57-
# associated_object_dict = Object.dict_from_object(associated_obj)
58-
# if associated_obj.get_association_type() is not None: associated_object_dict['association_type'] = associated_obj.get_association_type()
59-
# return associated_object_dict
44+
obj.association_type_ = VocabString.from_dict(object_dict.get('association_type', None))
45+
return obj

0 commit comments

Comments
 (0)