From 2938d71998f8f9910b20ef46b445cf018b28188d Mon Sep 17 00:00:00 2001 From: Greg Back Date: Wed, 22 Jan 2014 16:13:03 -0500 Subject: [PATCH 1/6] Add CHANGES.txt up to 2.0.0b2 [ci skip] --- CHANGES.txt | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 CHANGES.txt diff --git a/CHANGES.txt b/CHANGES.txt new file mode 100644 index 00000000..566663e6 --- /dev/null +++ b/CHANGES.txt @@ -0,0 +1,84 @@ +Version 2.0.0b2 +2013-05-16 +- Add HTTPSession, WhoisEntry objects. +- Add Double, Float, Long, NonNegativeInteger, Date, Time properties. +- Update Personnel, Contributor, DateRange, MeasureSource, AssociatedObject + types for CybOX 2.0. +- Update WinFile, WinExecutableFile, WinDriver, WinEvent, WinHandle, WinMutex, + WinKernelHook, WinProcess, WinRegistryKey, WinService, Library, Pipe, + WinPipe, NetworkSocket, System, WinSystem, and WinNetworkShare objects for + CybOX 2.0. +- Add ActionReference type. +- Update ToolInformation, ToolInformationList, ByteRun(s) types. +- Convert DNSResourceRecords, StreamList, EnvironmentVariableList types + to EntityList. +- Allow subclass instantiation in to_obj/from_obj functions. +- Fix datatype on Property classes +- Add initial TypedField implementation to reduce repetitive code. +- Convert File object to use TypedFields +- Add support for caches when reading a file that contains idrefs. +- Don't print anything to STDOUT. +- Add copyright statement to all files. +- Improve namespace parsing and output code. +- Improve automated tests. +- [#19] [#20] [#21] [#22] [#24] Typo fixes. +- Bugfixes in [#23] Memory and [#25] Process types. +- Various bug and style fixes. + + +Version 2.0.0b1 +2013-04-29 +- Add DNSQuery, DNSRecord, SocketAddress objects. +- Add 'title' and 'description' to Observables. +- Update StructuredText type with simpler structure. +- Update ExtractedString(s) and EnvironmentVariable(s) types. +- Update EmailMessage, File, Port, and Process objects. +- Extract PatternFieldGroup attributes into a separate class. +- Support lists of values within Properties. +- Support ControlledVocabularyStrings. +- Wrap content in CDATA where appropriate. +- Allow EntityList to enforce the type of objects that are added to it. +- Make XML output more readable. Don't output default attributes. +- Use proper prefixes in auto-generated IDs. +- Update helper.py. +- Improve automated tests. +- Various bugfixes, typo corrections, and style fixes. + + +Version 2.0.0a1 +2013-04-18 +- Major updates to support new language features and changes. + - Rename "Attributes" to "Properties". + - Rename "DefinedObject" to "ObjectProperties". + - Remove "StatefulMeasure". +- Update File, Mutex, Address, EmailMessage, and Artifact objects. +- Add EntityList type to handle collections of a single type. +- Properly handle xsi:type to determine Object type. +- Add proper object namespaces to XML output. +- Correctly test whether properties are equal. +- Recreated GenerateDS bindings to support CybOX 2.0. +- Various tweaks to bindings. + + +CybOX 1.0 branch +---------------- + +Version 1.0.0b3 +2013-04-19 +- Add Packer_List and Peak_Entropy attribute to FileObject. +- [#14] Fixed typo. + + +Version 1.0.0b2 +2013-04-17 +- Improve handling of list-style elements (those with maxOccurs>1). +- Improve ToolInformation, ToolInformationList, and Hash types. +- Make WinDriver object easier to use. +- Add support for DomainSpecificObjectAttributes on Objects. +- Various bugfixes and typo corrections. + + +Version 1.0.0b1 +2013-04-12 +- First (beta) release on PyPI +- Compatible with CybOX 1.0 From be5dbff85b3b32a8a64fd8b801241bdd9debedeb Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 23 Jan 2014 10:02:17 -0500 Subject: [PATCH 2/6] Update CHANGES.txt through 2.0.1.3 [ci skip] --- CHANGES.txt | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 566663e6..11828d3d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,128 @@ +Version 2.0.1.3 +2013-12-24 +- Fix bug the prevented removing objects from an EntityList. +- Explicitly set some 'datatype' attributes on output. +- Format Action timestamps correctly on XML output. +- Handle imports for duplicate "Time" classes. + + +Version 2.0.1.2 +2013-11-06 +- Use tox for cross-version automated testing. +- Convert Action and related types to use TypedField implementation. +- Convert DateRange type to use TypedField implementation. +- Add Frequency type. +- Register concrete implementations of Account-related classes in the + parent bindings. +- Add support for Events. +- Allow recursive definition of Events in bindings. +- Improve output of date strings. +- Improve JSON handling of empty lists (for input and output). +- Improve namespace handling for XML output. +- Fix errors where incorrect types were being used in the bindings. +- [#16] Use correct binding class. +- Fix typos. + + +Version 2.0.1.1 +2013-10-07 +- Minor bugfixes and documentation updates. + + +Version 2.0.1.0 +2013-09-20 +- Updated to support Version 2.0.1 of the CybOX language. +- Add support for language "update" versions (in addition to "major" and + "minor" versions). +- Update how delimiter-separated lists within Properties are handled. +- Correct errors in auto-generated bindings. + + +Version 2.0.0.1 +2013-09-13 +- Add API object. +- Improve Python 2.6 support +- Standardize Object test functions. +- Use Version 4 UUIDs rather than Version 1 UUIDs when creating random IDs. +- Include ID namespace by default on export. +- Allow new namespaces to be added to metadata. +- Various typo/bug fixes. + + +Version 2.0.0 +2013-08-27 +- First non-beta release! +- Convert MeasureSource, DigitalSignature, Contributor, Personnel types to use + TypedField implementation. +- Convert all existing objects to use TypedField implementation. +- Add Account, UserAccount, GUIObject, GUIWindow, GUIDialogBox, WinEventLog, + Volume, WinVolume, Disk, DiskPartition objects. +- Add Base64Binary and Name object property types. +- Add DataSegment type. +- Add equality checks using TypedFields. +- Clean up Entity and EntityList classes. +- Allow TypedFields to have multiplicity >1. +- Simplify implementation of BaseObjectPropertyType subclasses. +- Add default to_obj, to_dict, from_obj, and from_dict functions on the base + Entity class. +- Allow custom callbacks to be run after setting a TypedField on a type. +- Allow specifying which TypedFields should be used in comparisons. +- Restructure imports to collapse the cybox.common and cybox.core packages. +- Expand examples. +- [#46] [#48] [#49] [#51] Typo/bug fixes. +- Various other typo corrections, bug fixes, and style fixes. + + +Version 2.0.0b6 +2013-07-29 +- Add DomainSpecificObjectProperties. +- Set huge_tree=True in ETCompatXMLParser. +- More tweaks to XML output options. +- Typo fixes + + +Version 2.0.0b5 +2013-07-12 +- Add functionality to import an implementation class from an outside library. +- Improve handling of comma-delimited lists in properties. +- More namespace handling improvements. +- Simplify EntityLists. +- Tweaks to XML output. +- Various typo fixes. + + +Version 2.0.0b4 +2013-06-25 +- Add support for CustomProperties in ObjectProperties +- Update Observable to properly handle ID and IDREFs. +- Improve namespace handling (again). +- Improve unicode support. +- Add X509Certificate object. + + +Version 2.0.0b3 +2013-06-17 +- Update how RelatedObjects are created and handle. +- Update Observable type. +- Update Action and related types. +- Add PlatformSpecification, ExtractedFeatures type. +- Add Packer and PackerList types. +- Add VersionInfoResource to PEResourceList type. +- Add Record_Data to DNSRecord object. +- Update File, HTTPSession, Pipe, Port, WinDriver objects. +- Convert ExtractStringList to an EntityList. +- Allow Properties to specify when to output their datatype. +- Properly escape XML-reserved characters. +- Convert several "is None" checks to empty-list checks. +- Standardize how superclass functions are called. +- Handle Unicode strings correctly, always output UTF-8. +- Make each class responsible for its own namespace. +- Allow adding arbitrary namespaces when outputting XML. +- Extract namespaces from object metadata dictionary. +- Add and expand automated tests. +- Various bugfixes and typo corrections. + + Version 2.0.0b2 2013-05-16 - Add HTTPSession, WhoisEntry objects. From 175f11eaf69858240b4bc358c8c65eec78dfb70d Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 23 Jan 2014 10:13:11 -0500 Subject: [PATCH 3/6] Update CHANGES.txt for 2.0.1.4 --- CHANGES.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 11828d3d..1c5f7973 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ +Version 2.0.1.4 +2014-01-23 +- Add support for Encryption packaging on Artifact objects. +- [#70] Improve and consolidate parsing of numeric types. + + Version 2.0.1.3 2013-12-24 - Fix bug the prevented removing objects from an EntityList. From dcb30ef515b3af347204143f6fb31fd47f13dd66 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 23 Jan 2014 10:13:31 -0500 Subject: [PATCH 4/6] Bump version to 2.0.1.4 --- cybox/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cybox/__init__.py b/cybox/__init__.py index c5749c10..95ba00a0 100644 --- a/cybox/__init__.py +++ b/cybox/__init__.py @@ -1,7 +1,7 @@ # Copyright (c) 2013, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. -__version__ = "2.0.1.3" +__version__ = "2.0.1.4" import collections import inspect From ab0b9d3a5643ef33a071d252c6bad46f949ad1a9 Mon Sep 17 00:00:00 2001 From: Ivan Kirillov Date: Wed, 22 Jan 2014 11:01:16 -0500 Subject: [PATCH 5/6] Fixed typo in type_ property of WinExecutableFile class --- cybox/objects/win_executable_file_object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cybox/objects/win_executable_file_object.py b/cybox/objects/win_executable_file_object.py index dc8c2ac3..dba271ad 100644 --- a/cybox/objects/win_executable_file_object.py +++ b/cybox/objects/win_executable_file_object.py @@ -329,6 +329,6 @@ class WinExecutableFile(WinFile): pe_checksum = cybox.TypedField("PE_Checksum", PEChecksum) resources = cybox.TypedField("Resources", PEResourceList) sections = cybox.TypedField("Sections", PESectionList) - type = cybox.TypedField("Type", String) + type_ = cybox.TypedField("Type", String) From 3c5e4f676385b1efd1703879b29fc30b150bb08b Mon Sep 17 00:00:00 2001 From: Greg Back Date: Wed, 2 Jul 2014 17:46:43 -0500 Subject: [PATCH 6/6] Add a from_json() function. --- cybox/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cybox/__init__.py b/cybox/__init__.py index 95ba00a0..41747faa 100644 --- a/cybox/__init__.py +++ b/cybox/__init__.py @@ -226,6 +226,7 @@ def to_xml(self, include_namespaces=True, namespace_dict=None, return s.getvalue() def to_json(self): + """Export an object as a JSON String.""" return json.dumps(self.to_dict()) def _get_namespace_def(self, additional_ns_dict=None): @@ -293,6 +294,16 @@ def istypeof(cls, obj): """ return isinstance(obj, cls) + @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."""