diff --git a/README.md b/README.md index 90cde04a..72517d30 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# python-cybox [![Build Status](https://travis-ci.org/CybOXProject/python-cybox.png?branch=master)](https://travis-ci.org/CybOXProject/python-cybox) +# python-cybox [![Build Status](https://travis-ci.org/CybOXProject/python-cybox.png?branch=cybox1.0)](https://travis-ci.org/CybOXProject/python-cybox) A Python library for parsing, manipulating, and generating CybOX content. For more information about CybOX, see http://cybox.mitre.org. diff --git a/cybox/__init__.py b/cybox/__init__.py index 03352acb..9cc0af0d 100644 --- a/cybox/__init__.py +++ b/cybox/__init__.py @@ -15,8 +15,19 @@ def to_xml(self): return s.getvalue() def to_json(self): + """Export an object as a JSON String.""" return json.dumps(self.to_dict()) + @classmethod + def from_json(cls, json_doc): + """Parse a JSON string and build an entity.""" + try: + d = json.load(json_doc) + except AttributeError: # catch the read() error + d = json.loads(json_doc) + + return cls.from_dict(d) + @classmethod def object_from_dict(cls, entity_dict): """Convert from dict representation to object representation.""" diff --git a/cybox/common/__init__.py b/cybox/common/__init__.py index 78ef6cb6..aa9e2da8 100644 --- a/cybox/common/__init__.py +++ b/cybox/common/__init__.py @@ -6,3 +6,4 @@ from personnel import Personnel from time import Time from structured_text import StructuredText, Block, StructuredGroup +from toolinformation import ToolInformationList diff --git a/cybox/common/toolinformation.py b/cybox/common/toolinformation.py index 9ead6f73..a63ba419 100644 --- a/cybox/common/toolinformation.py +++ b/cybox/common/toolinformation.py @@ -24,6 +24,7 @@ def to_obj(self): if self.idref is not None : tool_information_obj.set_idref(self.idref) if self.description is not None : pass if self.name is not None : tool_information_obj.set_Name(self.name) + if self.vendor is not None : tool_information_obj.set_Vendor(self.vendor) if self.version is not None : tool_information_obj.set_Version(self.version) if self.service_pack is not None : tool_information_obj.set_Service_Pack(self.service_pack) if self.tool_specific_data is not None : pass diff --git a/cybox/objects/win_registry_key_object.py b/cybox/objects/win_registry_key_object.py index c65177e5..af348654 100644 --- a/cybox/objects/win_registry_key_object.py +++ b/cybox/objects/win_registry_key_object.py @@ -165,9 +165,9 @@ def from_dict(registry_value_dict): return None registry_value_ = RegistryValue() - if 'name' in registry_value_dict: registry_value_.name = String.from_dict(registry_value_dict.get('name')) - if 'data' in registry_value_dict: registry_value_.data = String.from_dict(registry_value_dict.get('data')) - if 'datatype' in registry_value_dict: registry_value_.datatype = String.from_dict(registry_value_dict.get('datatype')) + registry_value_.name = String.from_dict(registry_value_dict.get('name')) + registry_value_.data = String.from_dict(registry_value_dict.get('data')) + registry_value_.datatype = String.from_dict(registry_value_dict.get('datatype')) #registry_value_.byte_runs = ByteRuns.from_dict(registry_value_dict.get('byte_runs')) return registry_value_ \ No newline at end of file