From ce549b8de55a098cc0b3eadaf3db73248c710c0a Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 12 Feb 2015 08:17:44 -0600 Subject: [PATCH 01/17] Initial Python3 support Create compat.py module to deal with Python2/Python3 dependencies --- cybox/__init__.py | 26 ++- cybox/bindings/__init__.py | 45 ++-- cybox/bindings/account_object.py | 6 +- cybox/bindings/address_object.py | 8 +- cybox/bindings/api_object.py | 8 +- cybox/bindings/archive_file_object.py | 9 +- cybox/bindings/arp_cache_object.py | 11 +- cybox/bindings/artifact_object.py | 18 +- cybox/bindings/as_object.py | 6 +- cybox/bindings/code_object.py | 20 +- cybox/bindings/custom_object.py | 6 +- cybox/bindings/cybox_common.py | 124 +++++------ cybox/bindings/cybox_core.py | 106 +++++----- cybox/bindings/device_object.py | 8 +- cybox/bindings/disk_object.py | 15 +- cybox/bindings/disk_partition_object.py | 10 +- cybox/bindings/dns_cache_object.py | 13 +- cybox/bindings/dns_query_object.py | 19 +- cybox/bindings/dns_record_object.py | 13 +- cybox/bindings/domain_name_object.py | 6 +- cybox/bindings/email_message_object.py | 37 ++-- .../extensions/location/ciq_address_3_0.py | 4 +- cybox/bindings/file_object.py | 28 +-- cybox/bindings/gui_dialogbox_object.py | 11 +- cybox/bindings/gui_object.py | 8 +- cybox/bindings/gui_window_object.py | 11 +- cybox/bindings/hostname_object.py | 6 +- cybox/bindings/http_session_object.py | 43 ++-- cybox/bindings/image_file_object.py | 9 +- cybox/bindings/library_object.py | 8 +- cybox/bindings/link_object.py | 11 +- cybox/bindings/linux_package_object.py | 8 +- cybox/bindings/memory_object.py | 6 +- cybox/bindings/mutex_object.py | 8 +- cybox/bindings/network_connection_object.py | 21 +- cybox/bindings/network_flow_object.py | 109 +++++----- cybox/bindings/network_packet_object.py | 193 +++++++++--------- cybox/bindings/network_route_entry_object.py | 13 +- cybox/bindings/network_route_object.py | 13 +- cybox/bindings/network_socket_object.py | 21 +- cybox/bindings/network_subnet_object.py | 15 +- cybox/bindings/pdf_file_object.py | 53 +++-- cybox/bindings/pipe_object.py | 8 +- cybox/bindings/port_object.py | 10 +- cybox/bindings/process_object.py | 25 ++- cybox/bindings/product_object.py | 8 +- cybox/bindings/semaphore_object.py | 8 +- cybox/bindings/sms_message_object.py | 6 +- cybox/bindings/socket_address_object.py | 15 +- cybox/bindings/system_object.py | 31 ++- cybox/bindings/unix_file_object.py | 15 +- .../unix_network_route_entry_object.py | 11 +- cybox/bindings/unix_pipe_object.py | 11 +- cybox/bindings/unix_process_object.py | 17 +- cybox/bindings/unix_user_account_object.py | 15 +- cybox/bindings/unix_volume_object.py | 11 +- cybox/bindings/uri_object.py | 8 +- cybox/bindings/url_history_object.py | 11 +- cybox/bindings/user_account_object.py | 19 +- cybox/bindings/user_session_object.py | 8 +- cybox/bindings/volume_object.py | 14 +- cybox/bindings/whois_object.py | 31 ++- cybox/bindings/win_computer_account_object.py | 21 +- cybox/bindings/win_critical_section_object.py | 8 +- cybox/bindings/win_driver_object.py | 15 +- cybox/bindings/win_event_log_object.py | 10 +- cybox/bindings/win_event_object.py | 13 +- cybox/bindings/win_executable_file_object.py | 59 +++--- cybox/bindings/win_file_object.py | 21 +- cybox/bindings/win_filemapping_object.py | 11 +- cybox/bindings/win_handle_object.py | 12 +- cybox/bindings/win_hook_object.py | 11 +- cybox/bindings/win_kernel_hook_object.py | 10 +- cybox/bindings/win_kernel_object.py | 16 +- cybox/bindings/win_mailslot_object.py | 11 +- .../bindings/win_memory_page_region_object.py | 17 +- cybox/bindings/win_mutex_object.py | 13 +- .../win_network_route_entry_object.py | 17 +- cybox/bindings/win_network_share_object.py | 6 +- cybox/bindings/win_pipe_object.py | 13 +- cybox/bindings/win_prefetch_object.py | 19 +- cybox/bindings/win_process_object.py | 23 +-- cybox/bindings/win_registry_key_object.py | 21 +- cybox/bindings/win_semaphore_object.py | 13 +- cybox/bindings/win_service_object.py | 19 +- cybox/bindings/win_system_object.py | 17 +- cybox/bindings/win_system_restore_object.py | 12 +- cybox/bindings/win_task_object.py | 39 ++-- cybox/bindings/win_thread_object.py | 13 +- cybox/bindings/win_user_account_object.py | 15 +- cybox/bindings/win_volume_object.py | 17 +- cybox/bindings/win_waitable_timer_object.py | 13 +- cybox/bindings/x509_certificate_object.py | 22 +- cybox/common/hashes.py | 1 + cybox/common/properties.py | 6 +- cybox/compat.py | 23 +++ cybox/objects/artifact_object.py | 2 +- cybox/test/__init__.py | 12 +- cybox/test/common/hash_test.py | 4 +- cybox/test/core/object_test.py | 2 +- cybox/test/core/observable_test.py | 2 +- cybox/test/dev.py | 8 +- cybox/test/objects/email_message_test.py | 4 +- cybox/utils/__init__.py | 7 +- cybox/utils/normalize.py | 50 ++--- examples/artifact_instance.py | 2 +- examples/convert_samples.py | 10 +- examples/parse_xml.py | 4 +- examples/simple_email_instance.py | 2 +- examples/simple_email_pattern.py | 2 +- examples/simple_file_instance.py | 2 +- examples/url_instance.py | 2 +- examples/url_pattern.py | 2 +- examples/xml_to_json.py | 4 +- 114 files changed, 1034 insertions(+), 1039 deletions(-) create mode 100644 cybox/compat.py diff --git a/cybox/__init__.py b/cybox/__init__.py index 4bab20a6..7c11ead8 100644 --- a/cybox/__init__.py +++ b/cybox/__init__.py @@ -4,7 +4,8 @@ import collections import inspect import json -from StringIO import StringIO + +from .compat import StringIO, basestring, str import cybox.bindings as bindings import cybox.utils.idgen @@ -131,13 +132,13 @@ def to_obj(self, return_obj=None, ns_info=None): entity_obj = self._binding_class() - vars = {} + members = {} for klass in self.__class__.__mro__: if klass is Entity: break - vars.update(klass.__dict__.iteritems()) + members.update(vars(klass)) - for name, field in vars.iteritems(): + for name, field in members.items(): if isinstance(field, TypedField): val = getattr(self, field.attr_name) @@ -170,13 +171,13 @@ def to_dict(self): Python dict with keys set from this Entity. """ entity_dict = {} - vars = {} + members = {} for klass in self.__class__.__mro__: if klass is Entity: break - vars.update(klass.__dict__.iteritems()) + members.update(vars(klass)) - for name, field in vars.iteritems(): + for name, field in members.items(): if isinstance(field, TypedField): val = getattr(self, field.attr_name) @@ -299,7 +300,7 @@ def to_xml(self, include_namespaces=True, namespace_dict=None, pretty_print=pretty ) - s = unicode(sio.getvalue()).strip() + s = str(sio.getvalue()).strip() if encoding: return s.encode(encoding) @@ -368,7 +369,12 @@ def _get_namespaces(self, recurse=True): def _get_children(self): #TODO: eventually everything should be in _fields, not the top level # of vars() - for k, v in vars(self).items() + self._fields.items(): + + members = {} + members.update(vars(self)) + members.update(self._fields) + + for k, v in members.items(): if isinstance(v, Entity): yield v elif isinstance(v, list): @@ -411,7 +417,7 @@ def value(self): @value.setter def value(self, value): - self._value = unicode(value) + self._value = str(value) def to_obj(self, return_obj=None, ns_info=None): self._collect_ns_info(ns_info) diff --git a/cybox/bindings/__init__.py b/cybox/bindings/__init__.py index 4e7da4f0..0b2cd388 100644 --- a/cybox/bindings/__init__.py +++ b/cybox/bindings/__init__.py @@ -9,6 +9,8 @@ from xml.sax import saxutils from lxml import etree as etree_ +from cybox.compat import basestring, str + CDATA_START = "" @@ -86,7 +88,7 @@ def gds_validate_integer_list(self, input_data, node, input_name=''): for value in values: try: fvalue = float(value) - except (TypeError, ValueError), exp: + except (TypeError, ValueError) as exp: raise_parse_error(node, 'Requires sequence of integers') return input_data @@ -104,7 +106,7 @@ def gds_validate_float_list(self, input_data, node, input_name=''): for value in values: try: fvalue = float(value) - except (TypeError, ValueError), exp: + except (TypeError, ValueError) as exp: raise_parse_error(node, 'Requires sequence of floats') return input_data @@ -122,7 +124,7 @@ def gds_validate_double_list(self, input_data, node, input_name=''): for value in values: try: fvalue = float(value) - except (TypeError, ValueError), exp: + except (TypeError, ValueError) as exp: raise_parse_error(node, 'Requires sequence of doubles') return input_data @@ -271,17 +273,33 @@ def showIndent(lwrite, level, pretty_print=True): lwrite(' ' * level) -def quote_xml(text): +def _coerce_unicode(text): + # Convert `text` to Unicode string. + if text is None: - return u'' + text = "" + + if isinstance(text, str): + return text - # Convert `text` to unicode string. This is mainly a catch-all for non + # This is mainly a catch-all for non # string/unicode types like bool and int. try: - text = unicode(text) + text = str(text) except UnicodeDecodeError: text = text.decode(ExternalEncoding) + return text + + +def quote_xml(text): + """Format a value for display as an XML text node. + + Returns: + Unicode string (str on Python 3, unicode on Python 2) + """ + text = _coerce_unicode(text) + # If it's a CDATA block, return the text as is. if text.startswith(CDATA_START): return text @@ -292,15 +310,12 @@ def quote_xml(text): def quote_attrib(text): - if text is None: - return u'""' + """Format a value for display as an XML attribute. - # Convert `text` to unicode string. This is mainly a catch-all for non - # string/unicode types like bool and int. - try: - text = unicode(text) - except UnicodeDecodeError: - text = text.decode(ExternalEncoding) + Returns: + Unicode string (str on Python 3, unicode on Python 2) + """ + text = _coerce_unicode(text) # Return the escaped the value of text. # Note: This wraps the escaped text in quotation marks. diff --git a/cybox/bindings/account_object.py b/cybox/bindings/account_object.py index 3d009080..4578cd5d 100644 --- a/cybox/bindings/account_object.py +++ b/cybox/bindings/account_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class AuthenticationType(GeneratedsSuper): @@ -426,7 +426,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -472,7 +472,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/address_object.py b/cybox/bindings/address_object.py index df69bdd2..2846b4af 100644 --- a/cybox/bindings/address_object.py +++ b/cybox/bindings/address_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class AddressObjectType(cybox_common.ObjectPropertiesType): @@ -13,7 +13,7 @@ class AddressObjectType(cybox_common.ObjectPropertiesType): is being defined. The is_source field specifies if this is a "Source" addressThe is_destination field specifies if this is a "Destination" address""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, category='ipv4-addr', is_source=None, is_destination=None, is_spoofed=None, Address_Value=None, VLAN_Name=None, VLAN_Num=None): @@ -259,7 +259,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -305,7 +305,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/api_object.py b/cybox/bindings/api_object.py index 217988ef..51e88148 100644 --- a/cybox/bindings/api_object.py +++ b/cybox/bindings/api_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class APIObjectType(cybox_common.ObjectPropertiesType): """The APIObjectType type is intended to characterize a specific Application Programming Interface.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Description=None, Function_Name=None, Normalized_Function_Name=None, Platform=None, Address=None): @@ -220,7 +220,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -266,7 +266,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/archive_file_object.py b/cybox/bindings/archive_file_object.py index 8d5db73e..afe32da4 100644 --- a/cybox/bindings/archive_file_object.py +++ b/cybox/bindings/archive_file_object.py @@ -4,9 +4,8 @@ import sys from cybox.bindings import * -import cybox_common - -import file_object +from . import cybox_common +from . import file_object class ArchiveFileFormatType(cybox_common.BaseObjectPropertyType): @@ -363,7 +362,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -409,7 +408,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/arp_cache_object.py b/cybox/bindings/arp_cache_object.py index b3b6f2a3..a8ce5edf 100644 --- a/cybox/bindings/arp_cache_object.py +++ b/cybox/bindings/arp_cache_object.py @@ -4,10 +4,9 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object -import system_object +from . import cybox_common +from . import address_object +from . import system_object class ARPCacheEntryType(GeneratedsSuper): @@ -404,7 +403,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -450,7 +449,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/artifact_object.py b/cybox/bindings/artifact_object.py index c75dbfb4..cf32d345 100644 --- a/cybox/bindings/artifact_object.py +++ b/cybox/bindings/artifact_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class RawArtifactType(cybox_common.StringObjectPropertyType): """The RawArtifactType is intended to convey, with minimal characterization, the content of the Raw Artifact itself.""" - + subclass = None superclass = None def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, byte_order=None, valueOf_=None): @@ -79,7 +79,7 @@ class PackagingType(GeneratedsSuper): whether the Raw_Artifact content is protected/encrypted.The is_compressed field is optional and specifies whether the Raw_Artifact content is compressed.""" - + subclass = None superclass = None def __init__(self, is_compressed=None, is_encrypted=None, Compression=None, Encryption=None, Encoding=None): @@ -210,7 +210,7 @@ class CompressionType(GeneratedsSuper): optional and conveys a reference to a description of the compression algorithm utilized to protect the Raw_Artifact content.""" - + subclass = None superclass = None def __init__(self, compression_mechanism=None, compression_mechanism_ref=None): @@ -289,7 +289,7 @@ class EncryptionType(GeneratedsSuper): Raw_Artifact content. The encryption_key_ref field is optional and specifies a reference to a remote specification of the password for unprotecting/decrypting the Raw_Artifact content.""" - + subclass = None superclass = None def __init__(self, encryption_mechanism=None, encryption_key_ref=None, encryption_key=None, encryption_mechanism_ref=None): @@ -385,7 +385,7 @@ class EncodingType(GeneratedsSuper): custom_character_set_ref field is optional and conveys a reference to a specification of the custom character set used to encode the Raw_Artifact.""" - + subclass = None superclass = None def __init__(self, custom_character_set_ref=None, character_set=None, algorithm='Base64'): @@ -473,7 +473,7 @@ class ArtifactObjectType(cybox_common.ObjectPropertiesType): Defined Object.The suspected_malicious field is optional and conveys whether the content of the Raw_Artifact is believed to be malicoius.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, suspected_malicious=None, content_type_version=None, type_=None, content_type=None, Hashes=None, Packaging=None, Raw_Artifact=None, Raw_Artifact_Reference=None): @@ -716,7 +716,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -762,7 +762,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/as_object.py b/cybox/bindings/as_object.py index 88398777..95ef7412 100644 --- a/cybox/bindings/as_object.py +++ b/cybox/bindings/as_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class ASObjectType(cybox_common.ObjectPropertiesType): @@ -224,7 +224,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -270,7 +270,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/code_object.py b/cybox/bindings/code_object.py index 28a65a37..ea932c86 100644 --- a/cybox/bindings/code_object.py +++ b/cybox/bindings/code_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class CodeSegmentXORType(cybox_common.StringObjectPropertyType): @@ -15,7 +15,7 @@ class CodeSegmentXORType(cybox_common.StringObjectPropertyType): field should be XORed with in order to recover the actual code. The default value is 55AA55AA55AA55BB, as specified by IETF RFC 5901.""" - + subclass = None superclass = cybox_common.StringObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, xor_pattern='55AA55AA55AA55BB', valueOf_=None): @@ -83,7 +83,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class TargetedPlatformsType(GeneratedsSuper): """A list of targeted platforms""" - + subclass = None superclass = None def __init__(self, Targeted_Platform=None): @@ -155,7 +155,7 @@ class ProcessorTypeType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -228,7 +228,7 @@ class CodeLanguageType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This field is optional and specifies the expected type for the value of the specified field.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -301,7 +301,7 @@ class CodePurposeType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This field is optional and specifies the expected type for the value of the specified field.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -374,7 +374,7 @@ class CodeTypeType(cybox_common.BaseObjectPropertyType): (i.e. regular-expression based) specifications.This field is optional and specifies the expected type for the value of the specified field.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -443,7 +443,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class CodeObjectType(cybox_common.ObjectPropertiesType): """The CodeObjectType type is intended to characterize a body of computer code.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Description=None, Type=None, Purpose=None, Code_Language=None, Targeted_Platforms=None, Processor_Family=None, Discovery_Method=None, Start_Address=None, Code_Segment=None, Code_Segment_XOR=None, Digital_Signatures=None, Extracted_Features=None): @@ -743,7 +743,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -789,7 +789,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/custom_object.py b/cybox/bindings/custom_object.py index 2bc2b5ea..c13e5273 100644 --- a/cybox/bindings/custom_object.py +++ b/cybox/bindings/custom_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class CustomObjectType(cybox_common.ObjectPropertiesType): @@ -194,7 +194,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -240,7 +240,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/cybox_common.py b/cybox/bindings/cybox_common.py index 72ddaac4..fcf01009 100644 --- a/cybox/bindings/cybox_common.py +++ b/cybox/bindings/cybox_common.py @@ -392,7 +392,7 @@ def buildAttributes(self, node, attrs, already_processed): try: self.sighting_count = int(value) - except ValueError, exp: + except ValueError as exp: raise_parse_error(node, 'Bad integer attribute: %s' % exp) if self.sighting_count <= 0: raise_parse_error(node, 'Invalid PositiveInteger') @@ -435,13 +435,13 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): type_name_ = type_names_[0] else: type_name_ = type_names_[1] - + if type_name_ == "CIQAddress3.0InstanceType": import cybox.bindings.extensions.location.ciq_address_3_0 as ciq_address_binding obj_ = ciq_address_binding.CIQAddress3_0InstanceType.factory() else: - obj_ = LocationType.factory() - + obj_ = LocationType.factory() + obj_.build(child_) self.set_Observation_Location(obj_) elif nodeName_ == 'Tools': @@ -498,13 +498,13 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): type_name_ = type_names_[0] else: type_name_ = type_names_[1] - + if type_name_ == "CIQAddress3.0InstanceType": import cybox.bindings.extensions.location.ciq_address_3_0 as ciq_address_binding obj_ = ciq_address_binding.CIQAddress3_0InstanceType.factory() else: - obj_ = LocationType.factory() - + obj_ = LocationType.factory() + obj_.build(child_) self.set_Observable_Location(obj_) # end class MeasureSourceType @@ -512,7 +512,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ContributorType(GeneratedsSuper): """The ContributorType represents a description of an individual who contributed as a source of cyber observation data.""" - + subclass = None superclass = None def __init__(self, Role=None, Name=None, Email=None, Phone=None, Organization=None, Date=None, Contribution_Location=None): @@ -712,7 +712,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PersonnelType(GeneratedsSuper): """The PersonnelType is an abstracted data type to standardize the description of sets of personnel.""" - + subclass = None superclass = None def __init__(self, Contributor=None): @@ -873,7 +873,7 @@ class ToolSpecificDataType(GeneratedsSuper): CybOX schema enabling the inclusion of metadata for a specific type of tool through the use of a custom type defined as an extension of this base Abstract type.""" - + subclass = None superclass = None def __init__(self): @@ -925,7 +925,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ToolsInformationType(GeneratedsSuper): """The ToolsInformationType represents a description of a set of automated tools.""" - + subclass = None superclass = None def __init__(self, Tool=None): @@ -995,7 +995,7 @@ class ToolInformationType(GeneratedsSuper): automated tool.The id field specifies a unique ID for this Tool.The idref field specifies reference to a unique ID for this Tool.""" - + subclass = None superclass = None def __init__(self, idref=None, id=None, Name=None, Type=None, Description=None, References=None, Vendor=None, Version=None, Service_Pack=None, Tool_Specific_Data=None, Tool_Hashes=None, Tool_Configuration=None, Execution_Environment=None, Errors=None, Metadata=None, Compensation_Model=None): @@ -1234,7 +1234,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ToolReferencesType(GeneratedsSuper): """Used to indicate one or more references to tool instances and information""" - + subclass = None superclass = None def __init__(self, Reference=None): @@ -1303,7 +1303,7 @@ class ToolReferenceType(GeneratedsSuper): """Contains one reference to information or instances of a given toolIndicates the nature of the referenced material (documentation, source, executable, etc.)""" - + subclass = None superclass = None def __init__(self, reference_type=None, valueOf_=None): @@ -1470,7 +1470,7 @@ class ConfigurationSettingsType(GeneratedsSuper): """The ConfigurationSettingsType is a modularized data type used to provide a consistent approach to describing configuration settings for a tool, application or other cyber object""" - + subclass = None superclass = None def __init__(self, Configuration_Setting=None): @@ -1540,7 +1540,7 @@ class ConfigurationSettingType(GeneratedsSuper): provide a consistent approach to describing a particular configuration setting for a tool, application or other cyber object""" - + subclass = None superclass = None def __init__(self, Item_Name=None, Item_Value=None, Item_Type=None, Item_Description=None): @@ -1637,7 +1637,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class DependenciesType(GeneratedsSuper): """The DependenciesType contains information describing a set of dependencies for this tool.""" - + subclass = None superclass = None def __init__(self, Dependency=None): @@ -1705,7 +1705,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class DependencyType(GeneratedsSuper): """The DependencyType contains information describing a single dependency for this tool.""" - + subclass = None superclass = None def __init__(self, Dependency_Type=None, Dependency_Description=None): @@ -1779,7 +1779,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class UsageContextAssumptionsType(GeneratedsSuper): """The UsageContextAssumptionsType contains descriptions of the various relevant usage context assumptions for this tool""" - + subclass = None superclass = None def __init__(self, Usage_Context_Assumption=None): @@ -1847,7 +1847,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class InternationalizationSettingsType(GeneratedsSuper): """The InternationalizationSettingsType contains information describing relevant internationalization setting for this tool""" - + subclass = None superclass = None def __init__(self, Internal_Strings=None): @@ -1915,7 +1915,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class InternalStringsType(GeneratedsSuper): """The InternalStringsType contains a single internal string instance for this internationalization setting instance.""" - + subclass = None superclass = None def __init__(self, Key=None, Content=None): @@ -2158,7 +2158,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class BuildUtilityType(GeneratedsSuper): """The BuildUtilityType contains information identifying the utility used to build this application.""" - + subclass = None superclass = None def __init__(self, Build_Utility_Name=None, Build_Utility_Platform_Specification=None): @@ -2232,7 +2232,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class CompilersType(GeneratedsSuper): """The CompilersType describes the compilers utilized during this build of this application.""" - + subclass = None superclass = None def __init__(self, Compiler=None): @@ -2300,7 +2300,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class CompilerType(GeneratedsSuper): """The CompilerType describes a single compiler utilized during this build of this application.""" - + subclass = None superclass = None def __init__(self, Compiler_Informal_Description=None, Compiler_Platform_Specification=None): @@ -2373,7 +2373,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class CompilerInformalDescriptionType(GeneratedsSuper): """The CompilerInformalDescriptionType contains the informal description of this compiler instance.""" - + subclass = None superclass = None def __init__(self, Compiler_Name=None, Compiler_Version=None): @@ -2448,7 +2448,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class BuildConfigurationType(GeneratedsSuper): """The BuildConfigurationType describes how the build utility was configured for this build of this application.""" - + subclass = None superclass = None def __init__(self, Configuration_Setting_Description=None, Configuration_Settings=None): @@ -2522,7 +2522,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class LibrariesType(GeneratedsSuper): """The LibrariesType identifies the libraries incorporated into the build of the tool.""" - + subclass = None superclass = None def __init__(self, Library=None): @@ -2586,7 +2586,7 @@ class LibraryType(GeneratedsSuper): """The LibraryType identifies a single library incorporated into the build of the tool.This field identifies the name of the library.This field identifies the version of the library.""" - + subclass = None superclass = None def __init__(self, version=None, name=None): @@ -2777,7 +2777,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ErrorsType(GeneratedsSuper): """The ErrorsType captures any errors generated during the run of the tool.""" - + subclass = None superclass = None def __init__(self, Error=None): @@ -2845,7 +2845,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ErrorType(GeneratedsSuper): """The ErrorType captures a single error generated during the run of the tool.""" - + subclass = None superclass = None def __init__(self, Error_Type=None, Error_Count=None, Error_Instances=None): @@ -2921,7 +2921,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): sval_ = child_.text try: ival_ = int(sval_) - except (TypeError, ValueError), exp: + except (TypeError, ValueError) as exp: raise_parse_error(child_, 'requires integer: %s' % exp) ival_ = self.gds_validate_integer(ival_, node, 'Error_Count') self.Error_Count = ival_ @@ -2934,7 +2934,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ErrorInstancesType(GeneratedsSuper): """The ErrorInstancesType captures the actual error output for each instance of this type of error.""" - + subclass = None superclass = None def __init__(self, Error_Instance=None): @@ -3021,7 +3021,7 @@ class ObjectPropertiesType(GeneratedsSuper): location from which it is being referenced. Thus, this ID reference is intended to resolve to the Properties of the Object that it points to.""" - + subclass = None superclass = None def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None): @@ -3105,7 +3105,7 @@ class CustomPropertiesType(GeneratedsSuper): """The CustomPropertiesType enables the specification of a set of custom Object Properties that may not be defined in existing Properties schemas.""" - + subclass = None superclass = None def __init__(self, Property=None): @@ -5150,7 +5150,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ExtractedStringsType(GeneratedsSuper): """The ExtractedStringsType type is intended as container for strings extracted from CybOX objects.""" - + subclass = None superclass = None def __init__(self, String=None): @@ -5218,7 +5218,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ExtractedStringType(GeneratedsSuper): """The ExtractedStringType type is intended as container a single string extracted from a CybOX object.""" - + subclass = None superclass = None def __init__(self, Encoding=None, String_Value=None, Byte_String_Value=None, Hashes=None, Address=None, Length=None, Language=None, English_Translation=None): @@ -5360,7 +5360,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ImportsType(GeneratedsSuper): """The ImportsType is intended to represent an extracted list of imports specified within a CybOX object.""" - + subclass = None superclass = None def __init__(self, Import=None): @@ -5431,7 +5431,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class FunctionsType(GeneratedsSuper): """The FunctionsType is intended to represent an extracted list of functions leveraged within a CybOX object.""" - + subclass = None superclass = None def __init__(self, Function=None): @@ -5502,7 +5502,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class CodeSnippetsType(GeneratedsSuper): """The CodeSnippetsType is intended to represent an set of code snippets extracted from within a CybOX object.""" - + subclass = None superclass = None def __init__(self, Code_Snippet=None): @@ -5584,7 +5584,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ByteRunsType(GeneratedsSuper): """The ByteRunsType is used for representing a list of byte runs from within a raw object.""" - + subclass = None superclass = None def __init__(self, Byte_Run=None): @@ -5781,7 +5781,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HashListType(GeneratedsSuper): """The HashListType type is used for representing a list of hash values.""" - + subclass = None superclass = None def __init__(self, Hash=None): @@ -5849,7 +5849,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HashValueType(GeneratedsSuper): """The HashValueType is used for specifying the resulting value from a hash calculation.""" - + subclass = None superclass = None def __init__(self, Simple_Hash_Value=None, Fuzzy_Hash_Value=None): @@ -5923,7 +5923,7 @@ class SimpleHashValueType(HexBinaryObjectPropertyType): """The SimpleHashValueType is used for characterizing the output of basic cryptograhic hash functions outputing a single hexbinary hash value.""" - + subclass = None superclass = HexBinaryObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='hexBinary', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None, extensiontype_=None): @@ -5981,7 +5981,7 @@ class FuzzyHashValueType(StringObjectPropertyType): """The FuzzyHashValueType is used for characterizing the output of cryptograhic fuzzy hash functions outputing a single complex string based hash value.""" - + subclass = None superclass = StringObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None, extensiontype_=None): @@ -6038,7 +6038,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class FuzzyHashStructureType(GeneratedsSuper): """The FuzzyHashStructureType is used for characterizing the internal components of a cryptograhic fuzzy hash algorithmic calculation.""" - + subclass = None superclass = None def __init__(self, Block_Size=None, Block_Hash=None): @@ -6115,7 +6115,7 @@ class FuzzyHashBlockType(GeneratedsSuper): """The FuzzyHashBlockType is used for characterizing the internal components of a single block in a cryptograhic fuzzy hash algorithmic calculation.""" - + subclass = None superclass = None def __init__(self, Block_Hash_Value=None, Segment_Count=None, Segments=None): @@ -6202,7 +6202,7 @@ class HashSegmentsType(GeneratedsSuper): """The HashSegmentsType is used for characterizing the internal components of a set of trigger point-delimited segments in a cryptograhic fuzzy hash algorithmic calculation.""" - + subclass = None superclass = None def __init__(self, Segment=None): @@ -6271,7 +6271,7 @@ class HashSegmentType(GeneratedsSuper): """The HashSegmentType is used for characterizing the internal components of a single trigger point-delimited segment in a cryptograhic fuzzy hash algorithmic calculation.""" - + subclass = None superclass = None def __init__(self, Trigger_Point=None, Segment_Hash=None, Raw_Segment_Content=None): @@ -6357,7 +6357,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HashType(GeneratedsSuper): """The HashType type is intended to characterize hash values.""" - + subclass = None superclass = None def __init__(self, Type=None, Simple_Hash_Value=None, Fuzzy_Hash_Value=None, Fuzzy_Hash_Structure=None): @@ -6464,7 +6464,7 @@ class StructuredTextType(GeneratedsSuper): interferring with XML validation of the CybOX document. If this attribute is absent, the implication is that no markup is being used.""" - + subclass = None superclass = None def __init__(self, structuring_format=None, valueOf_=None): @@ -6675,7 +6675,7 @@ class DataSizeType(StringObjectPropertyType): """The DataSizeType specifies the size of the data segment.This field represents the Units used in the object size element. Possible values are: Bytes, Kilobytes, Megabytes.""" - + subclass = None superclass = StringObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None, extensiontype_=None, units=None): @@ -6751,7 +6751,7 @@ class PlatformSpecificationType(GeneratedsSuper): CPE23PlatformSpecificationType in the http://cybox.mitre.org/extensions/platform#CPE2.3-1 namespace. This type is defined in the extensions/platform/cpe2.3.xsd file.""" - + subclass = None superclass = None def __init__(self, Description=None, Identifier=None): @@ -6837,7 +6837,7 @@ class PlatformIdentifierType(StringObjectPropertyType): system from which the indicated name was drawn.A reference to information about the naming system from which the indicated name was drawn.""" - + subclass = None superclass = StringObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None, extensiontype_=None, system_ref=None, system=None): @@ -6915,7 +6915,7 @@ class MetadataType(GeneratedsSuper): """The MetadataType is intended as mechanism to capture any non- context-specific metadataThis field specifies the type of name of a single metadata field.""" - + subclass = None superclass = None def __init__(self, type_=None, Value=None, SubDatum=None): @@ -7001,7 +7001,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class EnvironmentVariableListType(GeneratedsSuper): """The EnvironmentVariableListType type is used for representing a list of environment variables.""" - + subclass = None superclass = None def __init__(self, Environment_Variable=None): @@ -7069,7 +7069,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class EnvironmentVariableType(GeneratedsSuper): """The EnvironmentVariableType type is used for representing environment variables using a name/value pair.""" - + subclass = None superclass = None def __init__(self, Name=None, Value=None): @@ -7145,7 +7145,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class DigitalSignaturesType(GeneratedsSuper): """The DigitalSignaturesType is used for representing a list of digital signatures.""" - + subclass = None superclass = None def __init__(self, Digital_Signature=None): @@ -7215,7 +7215,7 @@ class DigitalSignatureInfoType(GeneratedsSuper): of the basic information about a digital signature.Specifies whether the digital signature exists.Specifies if the digital signature is verified.""" - + subclass = None superclass = None def __init__(self, signature_verified=None, signature_exists=None, Certificate_Issuer=None, Certificate_Subject=None, Signature_Description=None): @@ -7329,7 +7329,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PatternableFieldType(GeneratedsSuper): """The PatternableFieldType is a grouping of attributes applicable to defining patterns on a specific field.""" - + subclass = None superclass = None def __init__(self, pattern_type=None, has_changed=None, trend=None, apply_condition='ANY', bit_mask=None, regex_syntax=None, condition=None, is_case_sensitive=True, delimiter='##comma##', valueOf_=None, extensiontype_=None): @@ -7505,7 +7505,7 @@ class ControlledVocabularyStringType(PatternableFieldType): of the controlled vocabulary.The vocab_reference field specifies the URI to the location of where the controlled vocabulary is defined, e.g., in an externally located XML schema file.""" - + subclass = None superclass = PatternableFieldType def __init__(self, pattern_type=None, has_changed=None, trend=None, apply_condition='ANY', bit_mask=None, regex_syntax=None, condition=None, is_case_sensitive=True, delimiter='##comma##', vocab_reference=None, vocab_name=None, valueOf_=None, xsi_type=None): @@ -7794,7 +7794,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -7821,7 +7821,7 @@ def parse(inFileName): def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/cybox_core.py b/cybox/bindings/cybox_core.py index 7d2548f9..9954da06 100644 --- a/cybox/bindings/cybox_core.py +++ b/cybox/bindings/cybox_core.py @@ -4,9 +4,7 @@ import sys from cybox.bindings import * -import cybox_common - -from cybox_common import ControlledVocabularyStringType +from . import cybox_common #Object Imports from cybox.bindings.account_object import AccountObjectType @@ -227,7 +225,7 @@ class ObservableType(GeneratedsSuper): Observable defined elsewhere.The negate field, when set to true, indicates the absence (rather than the presence) of the given Observable in a CybOX pattern.""" - + subclass = None superclass = None def __init__(self, negate=False, idref=None, id=None, sighting_count=None, Title=None, Description=None, Keywords=None, Observable_Source=None, Object=None, Event=None, Observable_Composition=None, Pattern_Fidelity=None): @@ -238,10 +236,10 @@ def __init__(self, negate=False, idref=None, id=None, sighting_count=None, Title self.Title = Title self.Description = Description self.Keywords = Keywords - - if Observable_Source is None: + + if Observable_Source is None: self.Observable_Source = [] - else: + else: self.Observable_Source = Observable_Source self.Object = Object @@ -348,7 +346,7 @@ def exportChildren(self, lwrite, level, namespace_='cybox:', name_='ObservableTy self.Observable_Composition.export(lwrite, level, 'cybox:', name_='Observable_Composition', pretty_print=pretty_print) if self.Pattern_Fidelity is not None: self.Pattern_Fidelity.export(lwrite, level, 'cybox:', name_='Pattern_Fidelity', pretty_print=pretty_print) - + def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -378,7 +376,7 @@ def buildAttributes(self, node, attrs, already_processed): try: self.sighting_count = int(value) - except ValueError, exp: + except ValueError as exp: raise_parse_error(node, 'Bad integer attribute: %s' % exp) if self.sighting_count <= 0: raise_parse_error(node, 'Invalid PositiveInteger') @@ -426,7 +424,7 @@ class EventType(GeneratedsSuper): received).The id field specifies a unique id for this Event.The idref field specifies a unique id reference to an Event defined elsewhere.""" - + subclass = None superclass = None def __init__(self, idref=None, id=None, Type=None, Description=None, Observation_Method=None, Actions=None, Location=None, Frequency=None, Event=None): @@ -522,7 +520,7 @@ def exportChildren(self, lwrite, level, namespace_='cybox:', name_='EventType', self.Frequency.export(lwrite, level, 'cybox:', name_='Frequency', pretty_print=pretty_print) for Event_ in self.Event: Event_.export(lwrite, level, 'cybox:', name_='Event', pretty_print=pretty_print) - + def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -565,13 +563,13 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): type_name_ = type_names_[0] else: type_name_ = type_names_[1] - + if type_name_ == "CIQAddress3.0InstanceType": import cybox.bindings.extensions.location.ciq_address_3_0 as ciq_address_binding obj_ = ciq_address_binding.CIQAddress3_0InstanceType.factory() else: obj_ = cybox_common.LocationType.factory() # IdentityType is not abstract - + obj_.build(child_) self.set_Location(obj_) elif nodeName_ == 'Frequency': @@ -595,7 +593,7 @@ class FrequencyType(GeneratedsSuper): leveraged within an event or action pattern observable triggering on the matching of a specified trend in the frequency of an event or action.""" - + subclass = None superclass = None def __init__(self, units=None, trend=None, rate=None, scale=None): @@ -675,7 +673,7 @@ def buildAttributes(self, node, attrs, already_processed): try: self.rate = float(value) - except ValueError, exp: + except ValueError as exp: raise ValueError('Bad float/double attribute (rate): %s' % exp) value = find_attr_value_('scale', node) if value is not None: @@ -688,7 +686,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ActionsType(GeneratedsSuper): """The ActionsType is a complex type representing a set of cyber observable actions.""" - + subclass = None superclass = None def __init__(self, Action=None): @@ -765,7 +763,7 @@ class ActionType(GeneratedsSuper): operational context in which the Action is relevantThe timestamp field represents the local or relative time at which the action occurred or was observed.""" - + subclass = None superclass = None def __init__(self, timestamp_precision='second', timestamp=None, action_status=None, ordinal_position=None, context=None, idref=None, id=None, Type=None, Name=None, Description=None, Action_Aliases=None, Action_Arguments=None, Location=None, Discovery_Method=None, Associated_Objects=None, Relationships=None, Frequency=None): @@ -904,7 +902,7 @@ def exportChildren(self, lwrite, level, namespace_='cybox:', name_='ActionType', self.Relationships.export(lwrite, level, 'cybox:', name_='Relationships', pretty_print=pretty_print) if self.Frequency is not None: self.Frequency.export(lwrite, level, 'cybox:', name_='Frequency', pretty_print=pretty_print) - + def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -917,7 +915,7 @@ def buildAttributes(self, node, attrs, already_processed): try: self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') - except ValueError, exp: + except ValueError as exp: raise ValueError('Bad date-time attribute (timestamp): %s' % exp) value = find_attr_value_('action_status', node) if value is not None: @@ -928,7 +926,7 @@ def buildAttributes(self, node, attrs, already_processed): try: self.ordinal_position = int(value) - except ValueError, exp: + except ValueError as exp: raise_parse_error(node, 'Bad integer attribute: %s' % exp) if self.ordinal_position <= 0: raise_parse_error(node, 'Invalid PositiveInteger') @@ -975,13 +973,13 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): type_name_ = type_names_[0] else: type_name_ = type_names_[1] - + if type_name_ == "CIQAddress3.0InstanceType": import cybox.bindings.extensions.location.ciq_address_3_0 as ciq_address_binding obj_ = ciq_address_binding.CIQAddress3_0InstanceType.factory() else: obj_ = cybox_common.LocationType.factory() # IdentityType is not abstract - + obj_.build(child_) self.set_Location(obj_) elif nodeName_ == 'Discovery_Method': @@ -1005,7 +1003,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ActionAliasesType(GeneratedsSuper): """The ActionAliasesType enables identification of other potentially used names for this Action.""" - + subclass = None superclass = None def __init__(self, Action_Alias=None): @@ -1074,7 +1072,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ActionArgumentsType(GeneratedsSuper): """The ActionArgumentsType enables the specification of relevant arguments/parameters for this Action.""" - + subclass = None superclass = None def __init__(self, Action_Argument=None): @@ -1215,7 +1213,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class AssociatedObjectsType(GeneratedsSuper): """The AssociatedObjectsType enables the description/specification of cyber Objects relevant to an Action.""" - + subclass = None superclass = None def __init__(self, Associated_Object=None): @@ -1284,7 +1282,7 @@ class ActionPertinentObjectPropertiesType(GeneratedsSuper): """The ActionPertinentObjectPropertiesType identifies which of the Properties of this Object are specifically pertinent to this Action.""" - + subclass = None superclass = None def __init__(self, Property=None): @@ -1425,7 +1423,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ActionRelationshipsType(GeneratedsSuper): """The ActionRelationshipsType enables description of other cyber observable actions that are related to this Action.""" - + subclass = None superclass = None def __init__(self, Relationship=None): @@ -1572,7 +1570,7 @@ class ActionReferenceType(GeneratedsSuper): """ActionReferenceType is intended to serve as a method for linking to actions.The action_id field refers to the id of the action being referenced.""" - + subclass = None superclass = None def __init__(self, action_id=None): @@ -1826,13 +1824,13 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): type_name_ = type_names_[0] else: type_name_ = type_names_[1] - + if type_name_ == "CIQAddress3.0InstanceType": import cybox.bindings.extensions.location.ciq_address_3_0 as ciq_address_binding obj_ = ciq_address_binding.CIQAddress3_0InstanceType.factory() else: obj_ = cybox_common.LocationType.factory() # IdentityType is not abstract - + obj_.build(child_) self.set_Location(obj_) elif nodeName_ == 'Related_Objects': @@ -1871,7 +1869,7 @@ class DomainSpecificObjectPropertiesType(GeneratedsSuper): This enables domains utilizing CybOX such as malware analysis or forensics to incorporate non-generalized object metadata from their domains into CybOX objects.""" - + subclass = None superclass = None def __init__(self, xsi_type = None): @@ -1931,7 +1929,7 @@ class RelatedObjectsType(GeneratedsSuper): """The RelatedObjectsType enables the identification and/or specification of Objects with relevant relationships with this Object.""" - + subclass = None superclass = None def __init__(self, Related_Object=None): @@ -2000,7 +1998,7 @@ class RelatedObjectType(ObjectType): """The RelatedObjectType enables the identification and/or specification of an Object with a relevant relationship with this Object.""" - + subclass = None superclass = ObjectType def __init__(self, has_changed=None, idref=None, id=None, State=None, Description=None, Properties=None, Domain_Specific_Object_Properties=None, Location=None, Related_Objects=None, Defined_Effect=None, Discovery_Method=None, Relationship=None): @@ -2058,7 +2056,7 @@ def buildAttributes(self, node, attrs, already_processed): super(RelatedObjectType, self).buildAttributes(node, attrs, already_processed) def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): if nodeName_ == 'Relationship': - obj_ = ControlledVocabularyStringType.factory() + obj_ = cybox_common.ControlledVocabularyStringType.factory() obj_.build(child_) self.set_Relationship(obj_) super(RelatedObjectType, self).buildChildren(child_, node, nodeName_, True) @@ -2075,7 +2073,7 @@ class DefinedEffectType(GeneratedsSuper): DefinedEffectType) are maintained as part of the core CybOX schema.The effect_type field specifies the nature of the Defined Effect instantiated in the place of the Defined_Effect element.""" - + subclass = None superclass = None def __init__(self, effect_type=None, extensiontype_=None): @@ -2223,7 +2221,7 @@ class DataReadEffectType(DefinedEffectType): """The DataReadEffectType type is intended to characterize the effects of actions upon objects where some data is read, such as from a file or a pipe.""" - + subclass = None superclass = DefinedEffectType def __init__(self, effect_type=None, Data=None): @@ -2291,7 +2289,7 @@ class DataWrittenEffectType(DefinedEffectType): """The DataWrittenEffectType type is intended to characterize the effects of actions upon objects where some data is written, such as to a file or a pipe.""" - + subclass = None superclass = DefinedEffectType def __init__(self, effect_type=None, Data=None): @@ -2359,7 +2357,7 @@ class DataSentEffectType(DefinedEffectType): """The DataSentEffectType type is intended to characterize the effects of actions upon objects where some data is sent, such as a byte sequence on a socket.""" - + subclass = None superclass = DefinedEffectType def __init__(self, effect_type=None, Data=None): @@ -2427,7 +2425,7 @@ class DataReceivedEffectType(DefinedEffectType): """The DataReceivedEffectType type is intended to characterize the effects of actions upon objects where some data is received, such as a byte sequence on a socket.""" - + subclass = None superclass = DefinedEffectType def __init__(self, effect_type=None, Data=None): @@ -2575,7 +2573,7 @@ class PropertiesEnumeratedEffectType(DefinedEffectType): the effects of actions upon objects where some properties of the object are enumerated, such as the startup parameters for a process.""" - + subclass = None superclass = DefinedEffectType def __init__(self, effect_type=None, Properties=None): @@ -2642,7 +2640,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PropertiesType(GeneratedsSuper): """The PropertiesType specifies the properties that were enumerated as a result of the action on the object.""" - + subclass = None superclass = None def __init__(self, Property=None): @@ -2711,7 +2709,7 @@ class ValuesEnumeratedEffectType(DefinedEffectType): """The ValuesEnumeratedEffectType type is intended to characterize the effects of actions upon objects where some values of the object are enumerated, such as the values of a registry key.""" - + subclass = None superclass = DefinedEffectType def __init__(self, effect_type=None, Values=None): @@ -2778,7 +2776,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ValuesType(GeneratedsSuper): """The ValuesType specifies the values that were enumerated as a result of the action on the object.""" - + subclass = None superclass = None def __init__(self, Value=None): @@ -2850,7 +2848,7 @@ class SendControlCodeEffectType(DefinedEffectType): other control-oriented communication signal, is sent to the object. For example, an action may send a control code to change the running state of a process.""" - + subclass = None superclass = DefinedEffectType def __init__(self, effect_type=None, Control_Code=None): @@ -3098,7 +3096,7 @@ class EventPoolType(GeneratedsSuper): the pooled Event elements. This reduces redundancy caused when identical Events occur multiple times within a set of defined Observables.""" - + subclass = None superclass = None def __init__(self, Event=None): @@ -3170,7 +3168,7 @@ class ActionPoolType(GeneratedsSuper): the pooled Action elements. This reduces redundancy caused when identical Actions occur multiple times within a set of defined Observables.""" - + subclass = None superclass = None def __init__(self, Action=None): @@ -3242,7 +3240,7 @@ class ObjectPoolType(GeneratedsSuper): the pooled Object elements. This reduces redundancy caused when identical Objects occur multiple times within a set of defined Observables.""" - + subclass = None superclass = None def __init__(self, Object=None): @@ -3314,7 +3312,7 @@ class PropertyPoolType(GeneratedsSuper): the pooled Properties elements. This reduces redundancy caused when identical Properties occur multiple times within a set of defined Observables.""" - + subclass = None superclass = None def __init__(self, Property=None): @@ -3383,7 +3381,7 @@ class ObfuscationTechniquesType(GeneratedsSuper): """The ObfuscationTechniquesType enables the description of a set of potential techniques an attacker could leverage to obfuscate the observability of this Observable.""" - + subclass = None superclass = None def __init__(self, Obfuscation_Technique=None): @@ -3522,7 +3520,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): # end class ObfuscationTechniqueType class KeywordsType(GeneratedsSuper): - + subclass = None superclass = None def __init__(self, Keyword=None): @@ -3589,7 +3587,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): # end class KeywordsType class PatternFidelityType(GeneratedsSuper): - + subclass = None superclass = None def __init__(self, Noisiness=None, Ease_of_Evasion=None, Evasion_Techniques=None): @@ -3679,7 +3677,7 @@ class AssociatedObjectType(ObjectType): """The AssociatedObjectType is a complex type representing the characterization of a cyber observable Object associated with a given cyber observable Action.""" - + subclass = None superclass = ObjectType def __init__(self, has_changed=None, idref=None, id=None, State=None, Description=None, Properties=None, Domain_Specific_Object_Properties=None, Location=None, Related_Objects=None, Defined_Effect=None, Discovery_Method=None, Association_Type=None, Action_Pertinent_Object_Properties=None): @@ -3893,7 +3891,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -3939,7 +3937,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/device_object.py b/cybox/bindings/device_object.py index 899a5435..f47773d3 100644 --- a/cybox/bindings/device_object.py +++ b/cybox/bindings/device_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class DeviceObjectType(cybox_common.ObjectPropertiesType): """The DeviceObjectType type is intended to characterize a specific Device.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Description=None, Device_Type=None, Manufacturer=None, Model=None, Serial_Number=None, Firmware_Version=None, System_Details=None): @@ -253,7 +253,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -299,7 +299,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/disk_object.py b/cybox/bindings/disk_object.py index fb7d6457..f965c632 100644 --- a/cybox/bindings/disk_object.py +++ b/cybox/bindings/disk_object.py @@ -4,14 +4,13 @@ import sys from cybox.bindings import * -import cybox_common - -import disk_partition_object +from . import cybox_common +from . import disk_partition_object class PartitionListType(GeneratedsSuper): """The PartionListType type specifies a list of partitions.""" - + subclass = None superclass = None def __init__(self, Partition=None): @@ -83,7 +82,7 @@ class DiskType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -151,7 +150,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class DiskObjectType(cybox_common.ObjectPropertiesType): """The DiskObjectType type is intended to characterize disk drives.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Disk_Name=None, Disk_Size=None, Free_Space=None, Partition_List=None, Type=None): @@ -376,7 +375,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -422,7 +421,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/disk_partition_object.py b/cybox/bindings/disk_partition_object.py index 11be6a84..8ad781f7 100644 --- a/cybox/bindings/disk_partition_object.py +++ b/cybox/bindings/disk_partition_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class PartitionType(cybox_common.BaseObjectPropertyType): @@ -14,7 +14,7 @@ class PartitionType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -83,7 +83,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class DiskPartitionObjectType(cybox_common.ObjectPropertiesType): """The DiskPartitionType type is intended to characterize partitions of disk drives.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Created=None, Device_Name=None, Mount_Point=None, Partition_ID=None, Partition_Length=None, Partition_Offset=None, Space_Left=None, Space_Used=None, Total_Space=None, Type=None): @@ -362,7 +362,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -408,7 +408,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/dns_cache_object.py b/cybox/bindings/dns_cache_object.py index 5bbffbab..3659f328 100644 --- a/cybox/bindings/dns_cache_object.py +++ b/cybox/bindings/dns_cache_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import dns_record_object +from . import cybox_common +from . import dns_record_object class DNSCacheEntryType(GeneratedsSuper): """The DNSCacheEntryType type is intended to characterize a single entry in a system's DNS cache.""" - + subclass = None superclass = None def __init__(self, DNS_Entry=None, TTL=None): @@ -88,7 +87,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class DNSCacheObjectType(cybox_common.ObjectPropertiesType): """The DNSCacheObjectType type is intended to characterize entries in a system's DNS cache.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, DNS_Cache_Entry=None): @@ -266,7 +265,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -312,7 +311,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/dns_query_object.py b/cybox/bindings/dns_query_object.py index 28e6eefa..6b40595f 100644 --- a/cybox/bindings/dns_query_object.py +++ b/cybox/bindings/dns_query_object.py @@ -4,16 +4,15 @@ import sys from cybox.bindings import * -import cybox_common - -import dns_record_object -import uri_object +from . import cybox_common +from . import dns_record_object +from . import uri_object class DNSQuestionType(GeneratedsSuper): """The DNSQuestionType specifies the components of a DNS Question, including the domain name queried, type, and class.""" - + subclass = None superclass = None def __init__(self, QName=None, QType=None, QClass=None): @@ -102,7 +101,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class DNSResourceRecordsType(GeneratedsSuper): """The DNSAnswersType encompasses one or more resource records returned for a DNS query.""" - + subclass = None superclass = None def __init__(self, Resource_Record=None): @@ -174,7 +173,7 @@ class DNSRecordType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -244,7 +243,7 @@ class DNSQueryObjectType(cybox_common.ObjectPropertiesType): """The DNSQueryType is intended to characterize a single DNS query and its components.The successful field specifies whether or not the DNS Query was successful.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, successful=None, Transaction_ID=None, Question=None, Answer_Resource_Records=None, Authority_Resource_Records=None, Additional_Records=None, Date_Ran=None, Service_Used=None): @@ -504,7 +503,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -550,7 +549,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/dns_record_object.py b/cybox/bindings/dns_record_object.py index b738d103..ec706d2e 100644 --- a/cybox/bindings/dns_record_object.py +++ b/cybox/bindings/dns_record_object.py @@ -4,16 +4,15 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object -import uri_object +from . import cybox_common +from . import address_object +from . import uri_object class DNSRecordObjectType(cybox_common.ObjectPropertiesType): """The DNSRecordObjectType type is intended to characterize an individual DNS record.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Description=None, Queried_Date=None, Domain_Name=None, IP_Address=None, Address_Class=None, Entry_Type=None, Record_Name=None, Record_Type=None, TTL=None, Flags=None, Data_Length=None, Record_Data=None): @@ -308,7 +307,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -354,7 +353,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/domain_name_object.py b/cybox/bindings/domain_name_object.py index 984304ae..e6d6f004 100644 --- a/cybox/bindings/domain_name_object.py +++ b/cybox/bindings/domain_name_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class DomainNameObjectType(cybox_common.ObjectPropertiesType): @@ -197,7 +197,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -243,7 +243,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/email_message_object.py b/cybox/bindings/email_message_object.py index 35940e8f..b22c3020 100644 --- a/cybox/bindings/email_message_object.py +++ b/cybox/bindings/email_message_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object +from . import cybox_common +from . import address_object class AttachmentsType(GeneratedsSuper): """The AttachmenstType captures a list of attachments for an email message.""" - + subclass = None superclass = None def __init__(self, File=None): @@ -80,7 +79,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class EmailHeaderType(GeneratedsSuper): """The EmailHeaderType captures a representation of a standard email header.""" - + subclass = None superclass = None def __init__(self, Received_Lines=None, To=None, CC=None, BCC=None, From=None, Subject=None, In_Reply_To=None, Date=None, Message_ID=None, Sender=None, Reply_To=None, Errors_To=None, Boundary=None, Content_Type=None, MIME_Version=None, Precedence=None, User_Agent=None, X_Mailer=None, X_Originating_IP=None, X_Priority=None): @@ -342,7 +341,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class EmailRecipientsType(GeneratedsSuper): """The EmailRecipientsType captures a list of recipients for an email message.""" - + subclass = None superclass = None def __init__(self, Recipient=None): @@ -410,7 +409,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class LinksType(GeneratedsSuper): """The LinksType captures a list of URIs, representing the links contained in the message.""" - + subclass = None superclass = None def __init__(self, Link=None): @@ -603,7 +602,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class EmailReceivedLineListType(GeneratedsSuper): """The EmailReceivedLineListType captures a list of 'Received' lines in an email message header.""" - + subclass = None superclass = None def __init__(self, Received=None): @@ -675,7 +674,7 @@ class AttachmentReferenceType(GeneratedsSuper): field specifies a reference to an file-oriented (i.e., the File Object or one its derivations such as the Windows File Object) Object defined elsewhere in the document, via its id.""" - + subclass = None superclass = None def __init__(self, object_reference=None): @@ -738,7 +737,7 @@ class LinkReferenceType(GeneratedsSuper): embedded in the body of the email message.The object_reference field specifies a reference to a URI Object defined elsewhere in the document, via its id.""" - + subclass = None superclass = None def __init__(self, object_reference=None): @@ -798,7 +797,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class EmailMessageObjectType(cybox_common.ObjectPropertiesType): """The EmailMessageObjectType type is intended to characterize an individual email message.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Header=None, Email_Server=None, Raw_Body=None, Raw_Header=None, Attachments=None, Links=None): @@ -876,14 +875,14 @@ def exportChildren(self, lwrite, level, namespace_='EmailMessageObj:', name_='Em value = self.Raw_Body.get_valueOf_() if not value.startswith('' - self.Raw_Body.set_valueOf_(value) + self.Raw_Body.set_valueOf_(value) self.Raw_Body.export(lwrite, level, 'EmailMessageObj:', name_='Raw_Body', pretty_print=pretty_print) if self.Raw_Header is not None: if self.Raw_Header.get_valueOf_() is not None: value = self.Raw_Header.get_valueOf_() if not value.startswith('' - self.Raw_Header.set_valueOf_(value) + self.Raw_Header.set_valueOf_(value) self.Raw_Header.export(lwrite, level, 'EmailMessageObj:', name_='Raw_Header', pretty_print=pretty_print) if self.Attachments is not None: self.Attachments.export(lwrite, level, 'EmailMessageObj:', name_='Attachments', pretty_print=pretty_print) @@ -1050,7 +1049,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -1065,7 +1064,7 @@ def parse(inFileName): rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) if rootClass is None: - rootTag = 'Email_Message' + rootTag = 'email_message' rootClass = EmailMessageObjectType rootObj = rootClass.factory() rootObj.build(rootNode) @@ -1082,7 +1081,7 @@ def parseEtree(inFileName): rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) if rootClass is None: - rootTag = 'Email_Message' + rootTag = 'email_message' rootClass = EmailMessageObjectType rootObj = rootClass.factory() rootObj.build(rootNode) @@ -1096,19 +1095,19 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) if rootClass is None: - rootTag = 'Email_Message' + rootTag = 'email_message' rootClass = EmailMessageObjectType rootObj = rootClass.factory() rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None # sys.stdout.write('\n') -# rootObj.export(sys.stdout.write, 0, name_="Email_Message", +# rootObj.export(sys.stdout.write, 0, name_="email_message", # namespacedef_='') return rootObj diff --git a/cybox/bindings/extensions/location/ciq_address_3_0.py b/cybox/bindings/extensions/location/ciq_address_3_0.py index afcf5bf8..e2470f03 100644 --- a/cybox/bindings/extensions/location/ciq_address_3_0.py +++ b/cybox/bindings/extensions/location/ciq_address_3_0.py @@ -201,7 +201,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -247,7 +247,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/file_object.py b/cybox/bindings/file_object.py index 5d4782f5..64ee2741 100644 --- a/cybox/bindings/file_object.py +++ b/cybox/bindings/file_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class FilePathType(cybox_common.StringObjectPropertyType): @@ -13,7 +13,7 @@ class FilePathType(cybox_common.StringObjectPropertyType): be specified via the 'fully_qualified' attribute.The fully_qualified field specifies whether the path is fully qualified.""" - + subclass = None superclass = None def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None, extensiontype_=None, fully_qualified=None): @@ -86,7 +86,7 @@ class FileAttributeType(GeneratedsSuper): """The FileAttributeType type specifies attribute(s) of a file. Since this Object property(ies) is platform-specific, it is defined here as an abstract type.""" - + subclass = None superclass = None def __init__(self, xsi_type = None): @@ -145,7 +145,7 @@ class FilePermissionsType(GeneratedsSuper): this is a platform-specific Object property, it is defined here as an abstract type and then implemented in any platform specific derived file objects.""" - + subclass = None superclass = None def __init__(self): @@ -196,7 +196,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PackerListType(GeneratedsSuper): """The PackerListType type specifies a list of file packers.""" - + subclass = None superclass = None def __init__(self, Packer=None): @@ -264,7 +264,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PackerType(GeneratedsSuper): """The PackerType specifies the fields that characterize a particular file packer, such as name and version.""" - + subclass = None superclass = None def __init__(self, Name=None, Version=None, Entry_Point=None, Signature=None, Type=None, Detected_Entrypoint_Signatures=None, EP_Jump_Codes=None): @@ -395,7 +395,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class EPJumpCodeType(GeneratedsSuper): """Specifies an entry-point jump code used by a packer.""" - + subclass = None superclass = None def __init__(self, Depth=None, Opcodes=None): @@ -473,7 +473,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class EntryPointSignatureType(GeneratedsSuper): """Specifies an entry point signature for a packer.""" - + subclass = None superclass = None def __init__(self, Name=None, Type=None): @@ -551,7 +551,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class EntryPointSignatureListType(GeneratedsSuper): """Species a list of entry point signatures for a packer.""" - + subclass = None superclass = None def __init__(self, Entry_Point_Signature=None): @@ -618,7 +618,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class SymLinksListType(GeneratedsSuper): """The SymLinksListType specifies a list of symbolic links.""" - + subclass = None superclass = None def __init__(self, Sym_Link=None): @@ -693,7 +693,7 @@ class PackerClassType(cybox_common.BaseObjectPropertyType): (i.e. regular-expression based) specifications.This field is optional and specifies the expected type for the value of the specified field.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, pattern_type=None, datatype='string', refanging_transform=None, bit_mask=None, appears_random=None, trend=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -763,7 +763,7 @@ class FileObjectType(cybox_common.ObjectPropertiesType): """The File_ObjectType type is intended to characterize generic files.The ispacked field is used to indicate whether the file is packed or not.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_packed=None, is_masqueraded=None, File_Name=None, File_Path=None, Device_Path=None, Full_Path=None, File_Extension=None, Size_In_Bytes=None, Magic_Number=None, File_Format=None, Hashes=None, Digital_Signatures=None, Modified_Time=None, Accessed_Time=None, Created_Time=None, File_Attributes_List=None, Permissions=None, User_Owner=None, Packer_List=None, Peak_Entropy=None, Sym_Links=None, Byte_Runs=None, Extracted_Features=None, Encryption_Algorithm=None, Decryption_Key=None, Compression_Method=None, Compression_Version=None, Compression_Comment=None): @@ -1269,7 +1269,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -1315,7 +1315,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/gui_dialogbox_object.py b/cybox/bindings/gui_dialogbox_object.py index 246a41c9..f3258c1f 100644 --- a/cybox/bindings/gui_dialogbox_object.py +++ b/cybox/bindings/gui_dialogbox_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import gui_object +from . import cybox_common +from . import gui_object class GUIDialogboxObjectType(gui_object.GUIObjectType): """The GUIDialogboxObjectType type is intended to characterize GUI dialog boxes.""" - + subclass = None superclass = gui_object.GUIObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Height=None, Width=None, Box_Caption=None, Box_Text=None): @@ -192,7 +191,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -238,7 +237,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/gui_object.py b/cybox/bindings/gui_object.py index 4c88793f..3ee6ab22 100644 --- a/cybox/bindings/gui_object.py +++ b/cybox/bindings/gui_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class GUIObjectType(cybox_common.ObjectPropertiesType): """The GUIObjectType type is intended to characterize generic GUI objects.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Height=None, Width=None): @@ -187,7 +187,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -233,7 +233,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/gui_window_object.py b/cybox/bindings/gui_window_object.py index 19b4a7a4..789c0f4b 100644 --- a/cybox/bindings/gui_window_object.py +++ b/cybox/bindings/gui_window_object.py @@ -4,14 +4,13 @@ import sys from cybox.bindings import * -import cybox_common - -import gui_object +from . import cybox_common +from . import gui_object class GUIWindowObjectType(gui_object.GUIObjectType): """The GUIWindowObjectType is intended to characterize GUI windows.""" - + subclass = None superclass = gui_object.GUIObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Height=None, Width=None, Owner_Window=None, Parent_Window=None, Window_Display_Name=None): @@ -202,7 +201,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -248,7 +247,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/hostname_object.py b/cybox/bindings/hostname_object.py index 0fdd10b3..4dccdf32 100644 --- a/cybox/bindings/hostname_object.py +++ b/cybox/bindings/hostname_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class HostnameObjectType(cybox_common.ObjectPropertiesType): @@ -214,7 +214,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -260,7 +260,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/http_session_object.py b/cybox/bindings/http_session_object.py index 14a89763..3bea34d9 100644 --- a/cybox/bindings/http_session_object.py +++ b/cybox/bindings/http_session_object.py @@ -4,11 +4,10 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object -import port_object -import uri_object +from . import cybox_common +from . import address_object +from . import port_object +from . import uri_object class HTTPRequestResponseType(GeneratedsSuper): @@ -90,7 +89,7 @@ def buildAttributes(self, node, attrs, already_processed): try: self.ordinal_position = int(value) - except ValueError, exp: + except ValueError as exp: raise_parse_error(node, 'Bad integer attribute: %s' % exp) if self.ordinal_position < 0: raise_parse_error(node, 'Invalid NonNegativeInteger') @@ -111,7 +110,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HTTPClientRequestType(GeneratedsSuper): """The HTTPClientRequestType field captures the details of an HTTP client request.""" - + subclass = None superclass = None def __init__(self, HTTP_Request_Line=None, HTTP_Request_Header=None, HTTP_Message_Body=None): @@ -194,7 +193,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HTTPServerResponseType(GeneratedsSuper): """The HTTPServerResponseType captures the details of an HTTP server response.""" - + subclass = None superclass = None def __init__(self, HTTP_Status_Line=None, HTTP_Response_Header=None, HTTP_Message_Body=None): @@ -276,7 +275,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HTTPRequestLineType(GeneratedsSuper): """The HTTPRequestLineType captures a single HTTP request line.""" - + subclass = None superclass = None def __init__(self, HTTP_Method=None, Value=None, Version=None): @@ -367,7 +366,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HTTPRequestHeaderType(GeneratedsSuper): """The HTTPRequestHeaderType captures the raw or parsed header of an HTTP request.""" - + subclass = None superclass = None def __init__(self, Raw_Header=None, Parsed_Header=None): @@ -422,7 +421,7 @@ def exportChildren(self, lwrite, level, namespace_='HTTPSessionObj:', name_='HTT value = self.Raw_Header.get_valueOf_() if not value.startswith('' - self.Raw_Header.set_valueOf_(value) + self.Raw_Header.set_valueOf_(value) self.Raw_Header.export(lwrite, level, 'HTTPSessionObj:', name_='Raw_Header', pretty_print=pretty_print) if self.Parsed_Header is not None: self.Parsed_Header.export(lwrite, level, 'HTTPSessionObj:', name_='Parsed_Header', pretty_print=pretty_print) @@ -448,7 +447,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HTTPRequestHeaderFieldsType(GeneratedsSuper): """The HTTPRequestHeaderFieldsType captures parsed HTTP request header fields.""" - + subclass = None superclass = None def __init__(self, Accept=None, Accept_Charset=None, Accept_Language=None, Accept_Datetime=None, Accept_Encoding=None, Authorization=None, Cache_Control=None, Connection=None, Cookie=None, Content_Length=None, Content_MD5=None, Content_Type=None, Date=None, Expect=None, From=None, Host=None, If_Match=None, If_Modified_Since=None, If_None_Match=None, If_Range=None, If_Unmodified_Since=None, Max_Forwards=None, Pragma=None, Proxy_Authorization=None, Range=None, Referer=None, TE=None, User_Agent=None, Via=None, Warning=None, DNT=None, X_Requested_With=None, X_Forwarded_For=None, X_Forwarded_Proto=None, X_ATT_DeviceId=None, X_Wap_Profile=None): @@ -870,7 +869,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HTTPResponseHeaderType(GeneratedsSuper): """The HTTPResponseHeaderType captures the raw or parsed header of an HTTP response.""" - + subclass = None superclass = None def __init__(self, Raw_Header=None, Parsed_Header=None): @@ -925,7 +924,7 @@ def exportChildren(self, lwrite, level, namespace_='HTTPSessionObj:', name_='HTT value = self.Raw_Header.get_valueOf_() if not value.startswith('' - self.Raw_Header.set_valueOf_(value) + self.Raw_Header.set_valueOf_(value) self.Raw_Header.export(lwrite, level, 'HTTPSessionObj:', name_='Raw_Header', pretty_print=pretty_print) if self.Parsed_Header is not None: self.Parsed_Header.export(lwrite, level, 'HTTPSessionObj:', name_='Parsed_Header', pretty_print=pretty_print) @@ -951,7 +950,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HTTPResponseHeaderFieldsType(GeneratedsSuper): """The HTTPRequestHeaderFieldsType captures parsed HTTP request header fields.""" - + subclass = None superclass = None def __init__(self, Access_Control_Allow_Origin=None, Accept_Ranges=None, Age=None, Cache_Control=None, Connection=None, Content_Encoding=None, Content_Language=None, Content_Length=None, Content_Location=None, Content_MD5=None, Content_Disposition=None, Content_Range=None, Content_Type=None, Date=None, ETag=None, Expires=None, Last_Modified=None, Link=None, Location=None, P3P=None, Pragma=None, Proxy_Authenticate=None, Refresh=None, Retry_After=None, Server=None, Set_Cookie=None, Strict_Transport_Security=None, Trailer=None, Transfer_Encoding=None, Vary=None, Via=None, Warning=None, WWW_Authenticate=None, X_Frame_Options=None, X_XSS_Protection=None, X_Content_Type_Options=None, X_Powered_By=None, X_UA_Compatible=None): @@ -1393,7 +1392,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HTTPMessageType(GeneratedsSuper): """The HTTPMessageType captures a single HTTP message body and its length.""" - + subclass = None superclass = None def __init__(self, Length=None, Message_Body=None): @@ -1471,7 +1470,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HTTPStatusLineType(GeneratedsSuper): """The HTTPStatusLineType captures a single HTTP response status line.""" - + subclass = None superclass = None def __init__(self, Version=None, Status_Code=None, Reason_Phrase=None): @@ -1560,7 +1559,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HostFieldType(GeneratedsSuper): """The HostFieldType captures the details of the HTTP request Host header field.""" - + subclass = None superclass = None def __init__(self, Domain_Name=None, Port=None): @@ -1637,7 +1636,7 @@ class HTTPMethodType(cybox_common.BaseObjectPropertyType): (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -1706,7 +1705,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class HTTPSessionObjectType(cybox_common.ObjectPropertiesType): """The HTTPSessionObjectType is intended to capture the details of an HTTP session.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, HTTP_Request_Response=None): @@ -1949,7 +1948,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -1995,7 +1994,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/image_file_object.py b/cybox/bindings/image_file_object.py index 7cec5e69..054435cd 100644 --- a/cybox/bindings/image_file_object.py +++ b/cybox/bindings/image_file_object.py @@ -4,9 +4,8 @@ import sys from cybox.bindings import * -import cybox_common - -import file_object +from . import cybox_common +from . import file_object class ImageFileFormatType(cybox_common.BaseObjectPropertyType): @@ -355,7 +354,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -401,7 +400,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/library_object.py b/cybox/bindings/library_object.py index c417f0bd..56187583 100644 --- a/cybox/bindings/library_object.py +++ b/cybox/bindings/library_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class LibraryType(cybox_common.BaseObjectPropertyType): @@ -77,7 +77,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class LibraryObjectType(cybox_common.ObjectPropertiesType): """The LibraryObjectType type is intended to characterize software libraries.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Name=None, Path=None, Size=None, Type=None, Version=None, Base_Address=None, Extracted_Features=None): @@ -316,7 +316,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -362,7 +362,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/link_object.py b/cybox/bindings/link_object.py index 77fc6510..4caafec5 100644 --- a/cybox/bindings/link_object.py +++ b/cybox/bindings/link_object.py @@ -4,13 +4,12 @@ import sys from cybox.bindings import * -import cybox_common - -import uri_object +from . import cybox_common +from . import uri_object class URLLabelType(cybox_common.StringObjectPropertyType): - + subclass = None superclass = None def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, pattern_type=None, datatype='string', refanging_transform=None, bit_mask=None, appears_random=None, trend=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', idref=None, is_defanged=None, id=None, condition=None, valueOf_=None, extensiontype_=None): @@ -144,7 +143,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -190,7 +189,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/linux_package_object.py b/cybox/bindings/linux_package_object.py index 4fa53a62..fe49040a 100644 --- a/cybox/bindings/linux_package_object.py +++ b/cybox/bindings/linux_package_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class LinuxPackageObjectType(cybox_common.ObjectPropertiesType): """The LinuxPackageObjectType type is intended to characterize Linux packages.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Architecture=None, Category=None, Description=None, Epoch=None, EVR=None, Name=None, Release=None, Vendor=None, Version=None): @@ -264,7 +264,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -310,7 +310,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/memory_object.py b/cybox/bindings/memory_object.py index ff5bc488..e7f866d1 100644 --- a/cybox/bindings/memory_object.py +++ b/cybox/bindings/memory_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class BlockType(cybox_common.BaseObjectPropertyType): @@ -396,7 +396,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -442,7 +442,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/mutex_object.py b/cybox/bindings/mutex_object.py index 144f65c8..bfed3e83 100644 --- a/cybox/bindings/mutex_object.py +++ b/cybox/bindings/mutex_object.py @@ -4,14 +4,14 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class MutexObjectType(cybox_common.ObjectPropertiesType): """The MutexObjectType type is intended to characterize generic mutual exclusion (mutex) objects.The named field specifies whether the Mutex is named.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, named=None, Name=None): @@ -191,7 +191,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -237,7 +237,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_connection_object.py b/cybox/bindings/network_connection_object.py index 1ea83832..97f504b6 100644 --- a/cybox/bindings/network_connection_object.py +++ b/cybox/bindings/network_connection_object.py @@ -4,18 +4,17 @@ import sys from cybox.bindings import * -import cybox_common - -import dns_query_object -import http_session_object -import socket_address_object +from . import cybox_common +from . import dns_query_object +from . import http_session_object +from . import socket_address_object class Layer7ConnectionsType(GeneratedsSuper): """The Layer7ConnectionsType specifies the different types of application (layer 7 in the OSI model) connections that may be initiated as part of the network connection.""" - + subclass = None superclass = None def __init__(self, HTTP_Session=None, DNS_Query=None): @@ -97,7 +96,7 @@ class Layer7ProtocolType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -170,7 +169,7 @@ class Layer3ProtocolType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -242,7 +241,7 @@ class NetworkConnectionObjectType(cybox_common.ObjectPropertiesType): connections.The tls_used field specifies whether or not Transport Layer Security (TLS) is used in the network connection.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, tls_used=None, Creation_Time=None, Layer3_Protocol=None, Layer4_Protocol=None, Layer7_Protocol=None, Source_Socket_Address=None, Source_TCP_State=None, Destination_Socket_Address=None, Destination_TCP_State=None, Layer7_Connections=None): @@ -613,7 +612,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -659,7 +658,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_flow_object.py b/cybox/bindings/network_flow_object.py index 6afdeefa..002a7e4c 100644 --- a/cybox/bindings/network_flow_object.py +++ b/cybox/bindings/network_flow_object.py @@ -4,17 +4,16 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object -import network_packet_object -import socket_address_object +from . import cybox_common +from . import address_object +from . import network_packet_object +from . import socket_address_object class NetworkLayerInfoType(GeneratedsSuper): """Network layer information (relative to the OSI network model) which is typically captured in all types of network flow records.""" - + subclass = None superclass = None def __init__(self, Src_Socket_Address=None, Dest_Socket_Address=None, IP_Protocol=None, extensiontype_=None): @@ -117,7 +116,7 @@ class NetworkFlowLabelType(NetworkLayerInfoType): include it for organizational purposes. Because these fields are defined here, they are excluded from the fields associated directly with each different flow record format type.""" - + subclass = None superclass = NetworkLayerInfoType def __init__(self, Src_Socket_Address=None, Dest_Socket_Address=None, IP_Protocol=None, Ingress_Interface_Index=None, Egress_Interface_Index=None, IP_Type_Of_Service=None): @@ -209,7 +208,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class UnidirectionalRecordType(GeneratedsSuper): """Netflow record formats that capture traffic in one direction.""" - + subclass = None superclass = None def __init__(self, IPFIX_Message=None, NetflowV9_Export_Packet=None, NetflowV5_Packet=None, SiLK_Record=None): @@ -305,7 +304,7 @@ class BidirectionalRecordType(GeneratedsSuper): supports bidirectional flows, and as such, is usually used as an alternative to NetFlow v5 analysis via SiLK (http://www.qosient.com/argus/).""" - + subclass = None superclass = None def __init__(self, YAF_Record=None): @@ -368,7 +367,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPFIXMessageType(GeneratedsSuper): """The IPFIX protocol provides IP flow information. http://tools.ietf.org/html/rfc5101""" - + subclass = None superclass = None def __init__(self, Message_Header=None, Set=None): @@ -449,7 +448,7 @@ class IPFIXMessageHeaderType(GeneratedsSuper): 5101 (http://tools.ietf.org/html/rfc5101) under the heading, "Message Header Field Descriptions." Note that common elements are included in the Network_Flow_Label.""" - + subclass = None superclass = None def __init__(self, Version=None, Byte_Length=None, Export_Timestamp=None, Sequence_Number=None, Observation_Domain_ID=None): @@ -560,7 +559,7 @@ class IPFIXSetType(GeneratedsSuper): an IPFIX message. See RFC 5101 and look for the terms "Template Set", "Options Template Set", and "Data Set", for more information.""" - + subclass = None superclass = None def __init__(self, Template_Set=None, Options_Template_Set=None, Data_Set=None): @@ -645,7 +644,7 @@ class IPFIXTemplateSetType(GeneratedsSuper): the Set Header, the collection of Template Records, and the optional padding at the end of the Template Set. See RFC 5101 under Set Format, which is section 3.3.1, for more information.""" - + subclass = None superclass = None def __init__(self, Set_Header=None, Template_Record=None, Padding=None): @@ -739,7 +738,7 @@ class IPFIXOptionsTemplateSetType(GeneratedsSuper): Records, and the optional padding at the end of the Options Template Set. See RFC 5101 under Set Format, which is section 3.3.1, for more information.""" - + subclass = None superclass = None def __init__(self, Set_Header=None, Options_Template_Record=None, Padding=None): @@ -832,7 +831,7 @@ class IPFIXDataSetType(GeneratedsSuper): Set Header, the collection of Data Records, and the optional padding at the end of the Data Set. See RFC 5101 under Set Format, which is section 3.3.1, for more information.""" - + subclass = None superclass = None def __init__(self, Set_Header=None, Data_Record=None, Padding=None): @@ -922,7 +921,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPFIXSetHeaderType(GeneratedsSuper): """Defines the elements of the IPFIX set header.""" - + subclass = None superclass = None def __init__(self, Set_ID=None, Length=None): @@ -1000,7 +999,7 @@ class IPFIXTemplateRecordType(GeneratedsSuper): the Template Record Header, and the Field Specifiers. See RFC 5101 under Template Record Format, section 3.4.1, for more information.""" - + subclass = None superclass = None def __init__(self, Template_Record_Header=None, Field_Specifier=None): @@ -1078,7 +1077,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPFIXTemplateRecordHeaderType(GeneratedsSuper): """Specifies the fields in a Template Record Header, Template_ID and Field_Count, as explained in RFC 5101, section 3.4.1.""" - + subclass = None superclass = None def __init__(self, Template_ID=None, Field_Count=None): @@ -1157,7 +1156,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPFIXTemplateRecordFieldSpecifiersType(GeneratedsSuper): """Specifies the fields in a Template Record Field Specifier, as explained in RFC 5101, section 3.2.""" - + subclass = None superclass = None def __init__(self, Enterprise_Bit=None, Information_Element_ID=None, Field_Length=None, Enterprise_Number=None): @@ -1262,7 +1261,7 @@ class IPFIXOptionsTemplateRecordType(GeneratedsSuper): are two: the Options Template Record Header, and the Field Specifiers. See RFC 5101 under Options Template Record Format, section 3.4.2.2, for more information.""" - + subclass = None superclass = None def __init__(self, Options_Template_Record_Header=None, Field_Specifier=None): @@ -1339,7 +1338,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPFIXOptionsTemplateRecordHeaderType(GeneratedsSuper): """Defines the ehader of an options template record.""" - + subclass = None superclass = None def __init__(self, Template_ID=None, Field_Count=None, Scope_Field_Count=None): @@ -1433,7 +1432,7 @@ class IPFIXOptionsTemplateRecordFieldSpecifiersType(GeneratedsSuper): as explained in RFC 5101, sections 3.2 and 3.4.2.2. It consists of two sequences: Scope Fields and Option Fields, appended together.""" - + subclass = None superclass = None def __init__(self, Scope_Enterprise_Bit=None, Scope_Information_Element_ID=None, Scope_Field_Length=None, Scope_Enterprise_Number=None, Option_Enterprise_Bit=None, Option_Information_Element_ID=None, Option_Field_Length=None, Option_Enterprise_Number=None): @@ -1586,7 +1585,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPFIXDataRecordType(GeneratedsSuper): """Data records are sent in data sets. A data record consists of only one more more Field values.""" - + subclass = None superclass = None def __init__(self, Field_Value=None): @@ -1657,7 +1656,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class NetflowV9ExportPacketType(GeneratedsSuper): """Netflow v9 was developed by Cisco and provides acess to IP flow information. http://www.ietf.org/rfc/rfc3954.txt""" - + subclass = None superclass = None def __init__(self, Packet_Header=None, Flow_Set=None): @@ -1736,7 +1735,7 @@ class NetflowV9PacketHeaderType(GeneratedsSuper): """Header fields defined for Netflow v9. Note that common elements are included in the Network_Flow_Label. http://www.ietf.org/rfc/rfc3954.txt""" - + subclass = None superclass = None def __init__(self, Version=None, Record_Count=None, Sys_Up_Time=None, Unix_Secs=None, Sequence_Number=None, Source_ID=None): @@ -1857,7 +1856,7 @@ class NetflowV9FlowSetType(GeneratedsSuper): There are three differnet types of FlowSets, as defined in RFC 3954: a Template FlowSet, Options Template FlowSet and Data FlowSet.""" - + subclass = None superclass = None def __init__(self, Template_Flow_Set=None, Options_Template_Flow_Set=None, Data_Flow_Set=None): @@ -1939,7 +1938,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class NetflowV9TemplateFlowSetType(GeneratedsSuper): """Provides the format of the Template FlowSet.""" - + subclass = None superclass = None def __init__(self, Flow_Set_ID=None, Length=None, Template_Record=None): @@ -2034,7 +2033,7 @@ class NetflowV9TemplateRecordType(GeneratedsSuper): """Specifies the Template Record region, which includes the template ID, field count, field type, and field length.Number of fields corresponds to Count field.""" - + subclass = None superclass = None def __init__(self, Template_ID=None, Field_Count=None, Field_Type=None, Field_Length=None): @@ -2137,7 +2136,7 @@ class NetflowV9OptionsTemplateFlowSetType(GeneratedsSuper): """Specifies an Options Template FlowSet, which is one or more Options Template Records that have been grouped together in an Export Packet.""" - + subclass = None superclass = None def __init__(self, Flow_Set_ID=None, Length=None, Options_Template_Record=None, Padding=None): @@ -2242,7 +2241,7 @@ class NetflowV9OptionsTemplateRecordType(GeneratedsSuper): """Specifies the Options Template Record region, which includes the Option Scope Length, Option Length, and fields specifying the Scope field type and Scope field length.""" - + subclass = None superclass = None def __init__(self, Template_ID=None, Option_Scope_Length=None, Option_Length=None, Scope_Field_Type=None, Scope_Field_Length=None, Option_Field_Type=None, Option_Field_Length=None): @@ -2380,7 +2379,7 @@ class NetflowV9DataFlowSetType(GeneratedsSuper): is either a Flow Data Record or an Options Data Record previously defined by a Template Record or an Options Template Record. http://www.ietf.org/rfc/rfc3954.txt""" - + subclass = None superclass = None def __init__(self, Flow_Set_ID_Template_ID=None, Length=None, Data_Record=None, Padding=None): @@ -2487,7 +2486,7 @@ class NetflowV9DataRecordType(GeneratedsSuper): Flow Data Record or an Options Data Record previously defined by a Template Record or an Options Template Record. http://www.ietf.org/rfc/rfc3954.txt""" - + subclass = None superclass = None def __init__(self, Flow_Data_Record=None, Options_Data_Record=None): @@ -2570,7 +2569,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class FlowDataRecordType(GeneratedsSuper): """A Flow Data Record is a data record that contains values of the Flow parameters corresponding to a Template Record.""" - + subclass = None superclass = None def __init__(self, Flow_Record_Collection_Element=None): @@ -2638,7 +2637,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class FlowCollectionElementType(GeneratedsSuper): """Field values are associated with each record in the collection of a flow data record.""" - + subclass = None superclass = None def __init__(self, Flow_Record_Field_Value=None): @@ -2710,7 +2709,7 @@ class OptionsDataRecordType(GeneratedsSuper): """The data record that contains values and scope information of the Flow measurement parameters, corresponding to an Options Template Record.""" - + subclass = None superclass = None def __init__(self, Scope_Field_Value=None, Option_Record_Collection_Element=None): @@ -2791,7 +2790,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class OptionCollectionElementType(GeneratedsSuper): """Field values are associatedwith each option in the collection of an option data record.""" - + subclass = None superclass = None def __init__(self, Option_Record_Field_Value=None): @@ -2864,7 +2863,7 @@ class NetflowV5PacketType(GeneratedsSuper): is still the most commonly used network flow format. Netflow v5 was developed by Cisco. http://netflow.caligare.com/netflow_v5.htm""" - + subclass = None superclass = None def __init__(self, Flow_Header=None, Flow_Record=None): @@ -2942,7 +2941,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class NetflowV5FlowHeaderType(GeneratedsSuper): """Defines elements of a netflow v5 header. http://netflow.caligare.com/netflow_v5.htm""" - + subclass = None superclass = None def __init__(self, Version=None, Count=None, Sys_Up_Time=None, Unix_Secs=None, Unix_Nsecs=None, Flow_Sequence=None, Engine_Type=None, Engine_ID=None, Sampling_Interval=None): @@ -3099,7 +3098,7 @@ class NetflowV5FlowRecordType(GeneratedsSuper): elements that define the flow itself (e.g., source IP address) are provided in NetworkFlowLabelType. https://bto.bluecoat.com/p acketguide/8.6/info/netflow5-records.htm""" - + subclass = None superclass = None def __init__(self, Nexthop_IPv4_Addr=None, Packet_Count=None, Byte_Count=None, SysUpTime_Start=None, SysUpTime_End=None, Padding1=None, TCP_Flags=None, Src_Autonomous_System=None, Dest_Autonomous_System=None, Src_IP_Mask_Bit_Count=None, Dest_IP_Mask_Bit_Count=None, Padding2=None): @@ -3286,7 +3285,7 @@ class SiLKRecordType(GeneratedsSuper): source IP, SNMP ingress, etc.). For additional references, see http://tools.netsa.cert.org/silk/analysis-handbook.pdf, http://tools.netsa.cert.org/silk/faq.html#ipfix-fields.""" - + subclass = None superclass = None def __init__(self, Packet_Count=None, Byte_Count=None, TCP_Flags=None, Start_Time=None, Duration=None, End_Time=None, Sensor_Info=None, ICMP_Type=None, ICMP_Code=None, Router_Next_Hop_IP=None, Initial_TCP_Flags=None, Session_TCP_Flags=None, Flow_Attributes=None, Flow_Application=None, Src_IP_Type=None, Dest_IP_Type=None, Src_Country_Code=None, Dest_Country_Code=None, Src_MAPNAME=None, Dest_MAPNAME=None): @@ -3559,7 +3558,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class SiLKSensorInfoType(GeneratedsSuper): """Defines elements associated with a SiLK sensor.""" - + subclass = None superclass = None def __init__(self, Sensor_ID=None, Class=None, Type=None): @@ -3655,7 +3654,7 @@ class YAFRecordType(GeneratedsSuper): into bidirectional flows, then exports those flows to IPFIX. (REF: http://www.usenix.org/event/lisa10/tech/full_papers/Inacio.pdf)""" - + subclass = None superclass = None def __init__(self, Flow=None, Reverse_Flow=None): @@ -3730,7 +3729,7 @@ class YAFFlowType(GeneratedsSuper): to the forward portion of the flow. Elements common to all network flow objects are defined in the NetworkFlowLabelType (src ip address, ingress/egress interface).""" - + subclass = None superclass = None def __init__(self, Flow_Start_Milliseconds=None, Flow_End_Milliseconds=None, Octet_Total_Count=None, Packet_Total_Count=None, Flow_End_Reason=None, SiLK_App_Label=None, Payload_Entropy=None, ML_App_Label=None, TCP_Flow=None, Vlan_ID_MAC_Addr=None, Passive_OS_Fingerprinting=None, First_Packet_Banner=None, Second_Packet_Banner=None, N_Bytes_Payload=None): @@ -3929,7 +3928,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class YAFReverseFlowType(GeneratedsSuper): """These elements correspond to the reverse flow captured by in YAF record.""" - + subclass = None superclass = None def __init__(self, Reverse_Octet_Total_Count=None, Reverse_Packet_Total_Count=None, Reverse_Payload_Entropy=None, Reverse_Flow_Delta_Milliseconds=None, TCP_Reverse_Flow=None, Reverse_Vlan_ID_MAC_Addr=None, Reverse_Passive_OS_Fingerprinting=None, Reverse_First_Packet=None, Reverse_N_Bytes_Payload=None): @@ -4077,7 +4076,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class YAFTCPFlowType(GeneratedsSuper): """Contains TCP-related information of the network flow.""" - + subclass = None superclass = None def __init__(self, TCP_Sequence_Number=None, Initial_TCP_Flags=None, Union_TCP_Flags=None): @@ -4170,7 +4169,7 @@ class SiLKSensorClassType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -4243,7 +4242,7 @@ class SiLKDirectionType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -4317,7 +4316,7 @@ class SiLKCountryCodeType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -4390,7 +4389,7 @@ class SiLKAddressType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -4463,7 +4462,7 @@ class SiLKFlowAttributesType(cybox_common.BaseObjectPropertyType): for permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -4537,7 +4536,7 @@ class NetflowV9ScopeFieldType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -4611,7 +4610,7 @@ class NetflowV9FieldType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -4683,7 +4682,7 @@ class NetworkFlowObjectType(cybox_common.ObjectPropertiesType): payload data (i.e. the actual data that was uploaded/downloaded to and from the Dest IP to Source IP as included in packet monitoring tools, such as Wireshark).""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Network_Flow_Label=None, Unidirectional_Flow_Record=None, Bidirectional_Flow_Record=None): @@ -5110,7 +5109,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -5156,7 +5155,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_packet_object.py b/cybox/bindings/network_packet_object.py index 549c8330..1863f015 100644 --- a/cybox/bindings/network_packet_object.py +++ b/cybox/bindings/network_packet_object.py @@ -4,16 +4,15 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object -import port_object +from . import cybox_common +from . import address_object +from . import port_object class LinkLayerType(GeneratedsSuper): """A link layer protocol is a hardware interface protocol, such as Ethernet, or a logical link routing protocol, such as ARP.""" - + subclass = None superclass = None def __init__(self, Physical_Interface=None, Logical_Protocols=None): @@ -86,7 +85,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PhysicalInterfaceType(GeneratedsSuper): """Multiple interface types exist - only most common (Ethernet) included now. Others will be added later as needed.""" - + subclass = None superclass = None def __init__(self, Ethernet=None): @@ -149,7 +148,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class LogicalProtocolType(GeneratedsSuper): """Logical Protocols characterizes the logical protocol of a link layer connection. One example of a logical protocol is ARP.""" - + subclass = None superclass = None def __init__(self, ARP_RARP=None, NDP=None): @@ -223,7 +222,7 @@ class EthernetInterfaceType(GeneratedsSuper): """Ethernet sends network packets from the sending host to one or more receiving hosts. (REF: IEEE 802.3; http://wiki.wireshark.org/Ethernet)""" - + subclass = None superclass = None def __init__(self, Ethernet_Header=None): @@ -287,7 +286,7 @@ class EthernetHeaderType(GeneratedsSuper): """Ethernet header characterizes and ethernet header and includes information such as source MAC address, destination MAC address, and more.""" - + subclass = None superclass = None def __init__(self, Destination_MAC_Addr=None, Source_MAC_Addr=None, Type_Or_Length=None, Checksum=None): @@ -383,7 +382,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class TypeLengthType(GeneratedsSuper): """0-1500 then it is a length field. Otherwise, it defines the protocol type of the Internet layer.""" - + subclass = None superclass = None def __init__(self, Length=None, Internet_Layer_Type=None): @@ -466,7 +465,7 @@ class ARPType(GeneratedsSuper): internetwork nodes. This property places ARP into the Link Layer. It is encapsulated. REF: http://www.comptechdoc.org/indep endent/networking/guide/netarp.html""" - + subclass = None superclass = None def __init__(self, Hardware_Addr_Type=None, Proto_Addr_Type=None, Hardware_Addr_Size=None, Proto_Addr_Size=None, Op_Type=None, Sender_Hardware_Addr=None, Sender_Protocol_Addr=None, Recip_Hardware_Addr=None, Recip_Protocol_Addr=None): @@ -622,7 +621,7 @@ class NDPType(GeneratedsSuper): """NDP Type characterizes NDP (Neighbor Discover Protocol) IPv6 packets. NDP defines five ICMPv6 packet types. RFC 2461: http://tools.ietf.org/html/rfc4861""" - + subclass = None superclass = None def __init__(self, ICMPv6_Header=None, Router_Solicitation=None, Router_Advertisement=None, Neighbor_Solicitation=None, Neighbor_Advertisement=None, Redirect=None): @@ -735,7 +734,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class RouterSolicitationType(GeneratedsSuper): """Hosts send Router Solicitations in order to prompt routers to generate Router Advertisements quickly.(type=133; code=0)""" - + subclass = None superclass = None def __init__(self, Options=None): @@ -803,7 +802,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class RouterSolicitationOptionsType(GeneratedsSuper): """Neighbor Discovery messages include zero or more options, some of which may appear multiple times in the same message.""" - + subclass = None superclass = None def __init__(self, Src_Link_Addr=None): @@ -875,7 +874,7 @@ class RouterAdvertisementType(GeneratedsSuper): available via DHCPv6. Examples of such information are DNS- related information or information on other servers within the network.""" - + subclass = None superclass = None def __init__(self, other_config_flag=None, managed_address_config_flag=None, Cur_Hop_Limit=None, Router_Lifetime=None, Reachable_Time=None, Retrans_Timer=None, Options=None): @@ -1009,7 +1008,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class RouterAdvertisementOptionsType(GeneratedsSuper): """Router Advertisement messages include zero or more options, some of which may appear multiple times in the same message.""" - + subclass = None superclass = None def __init__(self, Src_Link_Addr=None, MTU=None, Prefix_Info=None): @@ -1096,7 +1095,7 @@ class NeighborSolicitationType(GeneratedsSuper): the node needs to resolve an address and unicast when the node seeks to verify the reachability of a neighbor. (type=135; code=0)""" - + subclass = None superclass = None def __init__(self, Target_IPv6_Addr=None, Options=None): @@ -1169,7 +1168,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class NeighborSolicitationOptionsType(GeneratedsSuper): """Neighbor Solicitation messages include zero or more options, some of which may appear multiple times in the same message.""" - + subclass = None superclass = None def __init__(self, Src_Link_Addr=None): @@ -1243,7 +1242,7 @@ class NeighborAdvertisementType(GeneratedsSuper): Detection.Override flag. When set, the O-bit indicates that the advertisement should override an existing cache entry and update the cached link-layer address.""" - + subclass = None superclass = None def __init__(self, override_flag=None, router_flag=None, solicited_flag=None, Target_IPv6_Addr=None, Options=None): @@ -1359,7 +1358,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class NeighborOptionsType(GeneratedsSuper): """Neighbor Advertisement messages include zero or more options, some of which may appear multiple times in the same message.""" - + subclass = None superclass = None def __init__(self, Target_Link_Addr=None): @@ -1426,7 +1425,7 @@ class RedirectType(GeneratedsSuper): that the destination is in fact a neighbor. The latter is accomplished by setting the ICMP Target Address equal to the ICMP Destination Address. (type=137; code=0)""" - + subclass = None superclass = None def __init__(self, Target_IPv6_Addr=None, Dest_IPv6_Addr=None, Options=None): @@ -1509,7 +1508,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class RedirectOptionsType(GeneratedsSuper): """Redirect messages include zero or more options, some of which may appear multiple times in the same message.""" - + subclass = None superclass = None def __init__(self, Target_Link_Addr=None, Redirected_Header=None): @@ -1662,7 +1661,7 @@ class NDPPrefixInfoType(GeneratedsSuper): properties of the prefix.1-bit autonomous address-configuration flag. When set indicates that this prefix can be usd for stateless address configuration.""" - + subclass = None superclass = None def __init__(self, addr_config_flag=None, link_flag=None, Length=None, Prefix_Length=None, Valid_Lifetime=None, Preferred_Lifetime=None, Prefix=None): @@ -1797,7 +1796,7 @@ class NDPRedirectedHeaderType(GeneratedsSuper): """The redirected header option is used in redirect messages and contains all or part of the packet that is being redirected. (type=4)""" - + subclass = None superclass = None def __init__(self, Length=None, IPHeader_And_Data=None): @@ -1877,7 +1876,7 @@ class NDPMTUType(GeneratedsSuper): """The MTU option is used in Router Advertisement messages to ensure that all nodes on a link use the same MTU value in those cases where the link MTU is not well known. (type=5).""" - + subclass = None superclass = None def __init__(self, Length=None, MTU=None): @@ -1957,7 +1956,7 @@ class InternetLayerType(GeneratedsSuper): currently defined, just those most commonly used: IPv4, ICMPv4, IPv6, ICMPv6. Other protocols will be added as needed. (http://en.wikipedia.org/wiki/Internet_layer)""" - + subclass = None superclass = None def __init__(self, IPv4=None, ICMPv4=None, IPv6=None, ICMPv6=None): @@ -2051,7 +2050,7 @@ class IPv4PacketType(GeneratedsSuper): """Internet Protocol version 4 (IPv4) is a connectionless protocol for use on packet-switched link layer networks (e.g., Ethernet). REF: RFC 791; http://en.wikipedia.org/wiki/IPv4.""" - + subclass = None superclass = None def __init__(self, IPv4_Header=None, Data=None): @@ -2129,7 +2128,7 @@ class IPv4HeaderType(GeneratedsSuper): in the header to fragment and reassemble internet datagrams when necessary for transmission through small packet networks. REF: RFC 791.""" - + subclass = None superclass = None def __init__(self, IP_Version=None, Header_Length=None, DSCP=None, ECN=None, Total_Length=None, Identification=None, Flags=None, Fragment_Offset=None, TTL=None, Protocol=None, Checksum=None, Src_IPv4_Addr=None, Dest_IPv4_Addr=None, Option=None): @@ -2344,7 +2343,7 @@ class IPv4FlagsType(GeneratedsSuper): packet. It is a three-bit field, each of the three bits are defined by a field with a string value that indicates the meaning of whether or not the bit is set.""" - + subclass = None superclass = None def __init__(self, Reserved=None, Do_Not_Fragment=None, More_Fragments=None): @@ -2436,7 +2435,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPv4OptionType(GeneratedsSuper): """The IPv4 option field is variable in length with zero or more options.""" - + subclass = None superclass = None def __init__(self, Copy_Flag=None, Class=None, Option=None): @@ -2530,7 +2529,7 @@ class IPv6PacketType(GeneratedsSuper): like IPv4 it is a connectionless protocol for use on packet- switched link layer networks. RFC 3513, RFC 2460, http://en.wikipedia.org/wiki/IPv6.""" - + subclass = None superclass = None def __init__(self, IPv6_Header=None, Data=None, Ext_Headers=None): @@ -2617,7 +2616,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPv6HeaderType(GeneratedsSuper): """The IPv6 header is a simplification of the IPv4 header.""" - + subclass = None superclass = None def __init__(self, IP_Version=None, Traffic_Class=None, Flow_Label=None, Payload_Length=None, Next_Header=None, TTL=None, Src_IPv6_Addr=None, Dest_IPv6_Addr=None): @@ -2766,7 +2765,7 @@ class IPv6ExtHeaderType(GeneratedsSuper): one, or more extension headers, each identified by the Next Header field of the preceding header. http://tools.ietf.org/html/rfc2460""" - + subclass = None superclass = None def __init__(self, Hop_by_Hop_Options=None, Routing=None, Fragment=None, Destination_Options=None, Authentication_Header=None, Encapsulating_Security_Payload=None): @@ -2883,7 +2882,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPv6OptionType(GeneratedsSuper): """Specifies the meaning of each bit of the 8-bit IPv6OptionType type.""" - + subclass = None superclass = None def __init__(self, Do_Not_Recogn_Action=None, Packet_Change=None, Option_Byte=None): @@ -2975,7 +2974,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class TransportLayerType(GeneratedsSuper): """only UDP and TCP defined to begin. Other protocols will be defined as necessary.""" - + subclass = None superclass = None def __init__(self, TCP=None, UDP=None): @@ -3049,7 +3048,7 @@ class TCPType(GeneratedsSuper): """TCP provides reliable, ordered delivery of a stream of bytes from a prograom on one computer to another program on another computer. http://en.wikipedia.org/wiki/Transmission_Control_Protocol""" - + subclass = None superclass = None def __init__(self, TCP_Header=None, Options=None, Data=None): @@ -3139,7 +3138,7 @@ class UDPType(GeneratedsSuper): datagrams may arrive out of order, appear duplicated, or go missing without notice. http://en.wikipedia.org/wiki/User_Datagram_Protocol""" - + subclass = None superclass = None def __init__(self, UDP_Header=None, Data=None): @@ -3213,7 +3212,7 @@ class TCPHeaderType(GeneratedsSuper): """The TCP header contains 10 mandatory fields and an optional extension field. http://en.wikipedia.org/wiki/Transmission_Control_Protocol""" - + subclass = None superclass = None def __init__(self, Src_Port=None, Dest_Port=None, Seq_Num=None, ACK_Num=None, Data_Offset=None, Reserved=None, TCP_Flags=None, Window=None, Checksum=None, Urg_Ptr=None): @@ -3388,7 +3387,7 @@ class TCPFlagsType(GeneratedsSuper): packet sent from each end should have this flag set. http://en.wikipedia.org/wiki/Transmission_Control_ProtocolIf this flag is set, it means there is no more data from sender.""" - + subclass = None superclass = None def __init__(self, ece=None, urg=None, ack=None, cwr=None, psh=None, syn=None, rst=None, ns=None, fin=None): @@ -3572,7 +3571,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class UDPHeaderType(GeneratedsSuper): """The UDP header type defines the four fields in the UDP header.""" - + subclass = None superclass = None def __init__(self, SrcPort=None, DestPort=None, Length=None, Checksum=None): @@ -3673,7 +3672,7 @@ class ICMPv4PacketType(GeneratedsSuper): its destination), informational messages ( e.g., timestamp information), or a traceroute message. REF: http://www.networksorcery.com/enp/protocol/icmp.htm""" - + subclass = None superclass = None def __init__(self, ICMPv4_Header=None, Error_Msg=None, Info_Msg=None, Traceroute=None): @@ -3766,7 +3765,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4HeaderType(GeneratedsSuper): """Actual ICMP header bytes are defined, corresponding to the ICMP type, ICMP code, and to the checksum.""" - + subclass = None superclass = None def __init__(self, Type=None, Code=None, Checksum=None): @@ -3852,7 +3851,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4ErrorMessageType(GeneratedsSuper): """ICMP error messages include destination unreachable messages, source quench messages, redirect messages, and time exceeded messages.""" - + subclass = None superclass = None def __init__(self, Destination_Unreachable=None, Source_Quench=None, Redirect_Message=None, Time_Exceeded=None, Error_Msg_Content=None): @@ -3955,7 +3954,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4ErrorMessageContentType(GeneratedsSuper): """Elements associated with ICMPv4 error messages (as opposed to ICMP informational messages or ICMP traceroute message).""" - + subclass = None superclass = None def __init__(self, IP_Header=None, First_Eight_Bytes=None): @@ -4031,7 +4030,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4InfoMessageType(GeneratedsSuper): """ICMP informational messages include echo request/reply, timestamp request/reply, and address mask request/reply.""" - + subclass = None superclass = None def __init__(self, Echo_Reply=None, Echo_Request=None, Timestamp_Request=None, Timestamp_Reply=None, Address_Mask_Request=None, Address_Mask_Reply=None, Info_Msg_Content=None): @@ -4154,7 +4153,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4InfoMessageContentType(GeneratedsSuper): """Elements associated with ICMPv4 informational messages (as opposed to ICMP error messages or ICMP traceroute message).""" - + subclass = None superclass = None def __init__(self, Identifier=None, Sequence_Number=None): @@ -4232,7 +4231,7 @@ class ICMPv4TracerouteType(GeneratedsSuper): ICMP error messages or ICMP informational messages); corresponds to ICMP type =30. (http://www.networksorcery.com/enp/protocol/icmp/msg30.htm)""" - + subclass = None superclass = None def __init__(self, Outbound_Packet_Forward_Success=None, Outbound_Packet_no_Route=None, Identifier=None, Outbound_Hop_Count=None, Return_Hop_Count=None, Output_Link_Speed=None, Output_Link_MTU=None): @@ -4377,7 +4376,7 @@ class ICMPv6PacketType(GeneratedsSuper): http://tools.ietf.org/html/rfc4443 and http://www.networksorcery.com/enp/protocol/icmpv6.htm and http://en.wikipedia.org/wiki/ICMPv6.""" - + subclass = None superclass = None def __init__(self, ICMPv6_Header=None, Error_Msg=None, Info_Msg=None): @@ -4463,7 +4462,7 @@ class ICMPv6HeaderType(GeneratedsSuper): and code byte are defined in text by using boolean values associated with corresponding elements in the informational and error message type elements.""" - + subclass = None superclass = None def __init__(self, Type=None, Code=None, Checksum=None): @@ -4551,7 +4550,7 @@ class ICMPv6ErrorMessageType(GeneratedsSuper): packet too big messages, and time exceeded messages, and parameter problem messages, as defined in RFC 2463. Type values of ICMP v6 error messages range from 1 to 127.""" - + subclass = None superclass = None def __init__(self, Destination_Unreachable=None, Packet_Too_Big=None, Time_Exceeded=None, Parameter_Problem=None, Invoking_Packet=None): @@ -4659,7 +4658,7 @@ class ICMPv6InfoMessageType(GeneratedsSuper): informational message types will be added in the future as they are more commonly used (only echo request/reply are defined in RFC 4443).""" - + subclass = None superclass = None def __init__(self, Echo_Request=None, Echo_Reply=None, Info_Msg_Content=None): @@ -4742,7 +4741,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv6InfoMessageContentType(GeneratedsSuper): """Elements associated with ICMPv6 informational messages (as opposed to ICMP v6 error messages).""" - + subclass = None superclass = None def __init__(self, Identifier=None, Sequence_Number=None): @@ -4817,7 +4816,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4EchoReplyType(GeneratedsSuper): """Echo reply v4 informational message (used to ping); ICMP type=0.""" - + subclass = None superclass = None def __init__(self, Echo_Reply=None, Data=None): @@ -4898,7 +4897,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4DestinationUnreachableType(GeneratedsSuper): """Destination Unreachable error message; ICMP type=3.""" - + subclass = None superclass = None def __init__(self, Destination_Network_Unreachable=None, Destination_Host_Unreachable=None, Destination_Protocol_Unreachable=None, Destination_Port_Unreachable=None, Fragmentation_Required=None, Source_Route_Failed=None, Destination_Network_Unknown=None, Destination_Host_Unknown=None, Source_Host_Isolated=None, Network_Administratively_Prohibited=None, Host_Administratively_Prohibited=None, Network_Unreachable_For_TOS=None, Host_Unreachable_For_TOS=None, Communication_Administratively_Prohibited=None, Host_Precedence_Violation=None, Precedence_Cutoff_In_Effect=None): @@ -5217,7 +5216,7 @@ class FragmentationRequiredType(GeneratedsSuper): """This further specifies an ICMP destination unreachable (type=3) message of code=4 (fragmentation required) message by providing a Next-Hop MTU field.""" - + subclass = None superclass = None def __init__(self, Fragmentation_Required=None, Next_Hop_MTU=None): @@ -5298,7 +5297,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4SourceQuenchType(GeneratedsSuper): """Source Quench (congestion control) error message; ICMP type=4.""" - + subclass = None superclass = None def __init__(self, Source_Quench=None): @@ -5366,7 +5365,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4RedirectMessageType(GeneratedsSuper): """Redirect Message error message; ICMP type=5.""" - + subclass = None superclass = None def __init__(self, Network_Redirect=None, Host_Redirect=None, ToS_Network_Redirect=None, ToS_Host_Redirect=None, IP_Address=None): @@ -5496,7 +5495,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4EchoRequestType(GeneratedsSuper): """Echo Request informational message (used to ping); ICMP type=8.""" - + subclass = None superclass = None def __init__(self, Echo_Request=None, Data=None): @@ -5577,7 +5576,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4TimeExceededType(GeneratedsSuper): """Time Exceeded error message; ICMP type=11.""" - + subclass = None superclass = None def __init__(self, TTL_Exceeded_In_Transit=None, Frag_Reassembly_Time_Exceeded=None): @@ -5663,7 +5662,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4TimestampRequestType(GeneratedsSuper): """Time Stamp Request informational message; ICMP type=13.""" - + subclass = None superclass = None def __init__(self, Timestamp=None, Originate_Timestamp=None): @@ -5742,7 +5741,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4TimestampReplyType(GeneratedsSuper): """Time Stamp Reply informational message; ICMP type=14.""" - + subclass = None superclass = None def __init__(self, Timestamp_Reply=None, Originate_Timestamp=None, Receive_Timestamp=None, Transmit_Timestamp=None): @@ -5840,7 +5839,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4AddressMaskRequestType(GeneratedsSuper): """Address Mask Request informational message; ICMP type=17.""" - + subclass = None superclass = None def __init__(self, Address_Mask_Request=None, Address_Mask=None): @@ -5918,7 +5917,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv4AddressMaskReplyType(GeneratedsSuper): """Address Mask informational message; ICMP type=18.""" - + subclass = None superclass = None def __init__(self, Address_Mask_Reply=None, Address_Mask=None): @@ -5996,7 +5995,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv6DestinationUnreachableType(GeneratedsSuper): """Destination unreachable error message; ICMP v6 type=1.""" - + subclass = None superclass = None def __init__(self, No_Route=None, Comm_Prohibited=None, Beyond_Scope=None, Address_Unreachable=None, Port_Unreachable=None, Src_Addr_Failed_Policy=None, Reject_Route=None): @@ -6167,7 +6166,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv6PacketTooBigType(GeneratedsSuper): """Packet too big error message; ICMP v6 type=2.""" - + subclass = None superclass = None def __init__(self, Packet_Too_Big=None, MTU=None): @@ -6248,7 +6247,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv6TimeExceededType(GeneratedsSuper): """Time exceeded error message; ICMP v6 type=3.""" - + subclass = None superclass = None def __init__(self, Hop_Limit_Exceeded=None, Fragment_Reassem_Time_Exceeded=None): @@ -6334,7 +6333,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv6ParameterProblemType(GeneratedsSuper): """Parameter problem error message; ICMP v6 type=4.""" - + subclass = None superclass = None def __init__(self, Erroneous_Header_Field=None, Unrecognized_Next_Header_Type=None, Unrecognized_IPv6_Option=None, Pointer=None): @@ -6450,7 +6449,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv6EchoRequestType(GeneratedsSuper): """Echo request informational ICMP v6 message; type=128.""" - + subclass = None superclass = None def __init__(self, Echo_Request=None, Data=None): @@ -6531,7 +6530,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ICMPv6EchoReplyType(GeneratedsSuper): """Echo reply informational ICMP v6 message; type=129.""" - + subclass = None superclass = None def __init__(self, Echo_Reply=None, Data=None): @@ -6613,7 +6612,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PrefixType(GeneratedsSuper): """Provides an IP address or a prefix of an IP address for NDP for IPv6.""" - + subclass = None superclass = None def __init__(self, IPv6_Addr=None, IP_Addr_Prefix=None): @@ -6687,7 +6686,7 @@ class HopByHopOptionsType(GeneratedsSuper): """Defines fields for the IPv6 Hop-by-Hop Options header which is used to carry optional information that must be examined by every node along a packet's delivery path.""" - + subclass = None superclass = None def __init__(self, Next_Header=None, Header_Ext_Len=None, Option_Data=None): @@ -6783,7 +6782,7 @@ class OptionDataType(GeneratedsSuper): headers (the Hop-by-Hop Options header and the Destination Options header). Contains one or more type-length-value (TLV)-encoded options.""" - + subclass = None superclass = None def __init__(self, Option_Type=None, Option_Data_Len=None, Pad1=None, PadN=None): @@ -6881,7 +6880,7 @@ class RoutingType(GeneratedsSuper): source to list one or more intermediate nodes to be "visited" on the way to a packet's destination. http://tools.ietf.org/html/rfc2460""" - + subclass = None superclass = None def __init__(self, Next_Header=None, Header_Ext_Len=None, Routing_Type=None, Segments_Left=None, Type_Specific_Data=None): @@ -6997,7 +6996,7 @@ class FragmentType(GeneratedsSuper): """Specifies the fields of the Fragment header, which is used by an IPv6 source to send a packet larger than would fit in the path MTU. http://tools.ietf.org/html/rfc2460""" - + subclass = None superclass = None def __init__(self, Fragment_Header=None, Fragment=None): @@ -7074,7 +7073,7 @@ class DestinationOptionsType(GeneratedsSuper): """Defines fields for the IPv6 Destination Options header which is used to carry optional information that needs to be examined only by a packet's destination node(s).""" - + subclass = None superclass = None def __init__(self, Next_Header=None, Header_Ext_Len=None, Option_Data=None): @@ -7170,7 +7169,7 @@ class AuthenticationHeaderType(GeneratedsSuper): integrity and data origin authentication for IP datagrams and to provide protection against replays. http://www.ietf.org/rfc/rfc2402.txt""" - + subclass = None superclass = None def __init__(self, Next_Header=None, Header_Ext_Len=None, Security_Parameters_Index=None, Sequence_Number=None, Authentication_Data=None): @@ -7281,7 +7280,7 @@ class EncapsulatingSecurityPayloadType(GeneratedsSuper): connectionless integrity, an anti-replay service (a form of partial sequence integrity), and limited traffic flow confidentiality. http://www.ietf.org/rfc/rfc2406.txt""" - + subclass = None superclass = None def __init__(self, Security_Parameters_Index=None, Sequence_Number=None, Payload_Data=None, Padding=None, Padding_Len=None, Next_Header=None, Authentication_Data=None): @@ -7411,7 +7410,7 @@ class Pad1Type(GeneratedsSuper): """The Pad1 type specifies how one octet of padding is inserted into the Options area of a header. The Pad1 option type does not have length and value fields.""" - + subclass = None superclass = None def __init__(self, Octet=None): @@ -7477,7 +7476,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PadNType(GeneratedsSuper): """The PadN type specifies how two or more octets of padding are inserted into the Options area of a header.""" - + subclass = None superclass = None def __init__(self, Octet=None, Option_Data_Length=None, Option_Data=None): @@ -7567,7 +7566,7 @@ class FragmentHeaderType(GeneratedsSuper): """Each fragment has a header containing next header information, the offset of the fragment, an M flag specifying whether or not it is the last fragment, and an identification value.""" - + subclass = None superclass = None def __init__(self, Next_Header=None, Fragment_Offset=None, M_Flag=None, Identification=None): @@ -7670,7 +7669,7 @@ class MFlagType(cybox_common.BaseObjectPropertyType): regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -7743,7 +7742,7 @@ class IANAPortNumberRegistryType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -7816,7 +7815,7 @@ class IANAAssignedIPNumbersType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, pattern_type=None, datatype='string', refanging_transform=None, bit_mask=None, appears_random=None, trend=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -7889,7 +7888,7 @@ class IANAEtherType(cybox_common.BaseObjectPropertyType): (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -7962,7 +7961,7 @@ class IANAHardwareType(cybox_common.BaseObjectPropertyType): (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -8037,7 +8036,7 @@ class IPVersionType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -8110,7 +8109,7 @@ class IPv6PacketChangeType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -8184,7 +8183,7 @@ class IPv6DoNotRecogActionType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -8257,7 +8256,7 @@ class IPv4OptionsType(cybox_common.BaseObjectPropertyType): regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -8330,7 +8329,7 @@ class IPv4ClassType(cybox_common.BaseObjectPropertyType): regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -8403,7 +8402,7 @@ class IPv4CopyFlagType(cybox_common.BaseObjectPropertyType): (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -8476,7 +8475,7 @@ class MoreFragmentsType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -8549,7 +8548,7 @@ class DoNotFragmentType(cybox_common.BaseObjectPropertyType): (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, pattern_type=None, datatype='string', refanging_transform=None, bit_mask=None, appears_random=None, trend=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -8622,7 +8621,7 @@ class ARPOpType(cybox_common.BaseObjectPropertyType): regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -8696,7 +8695,7 @@ class NetworkPacketObjectType(cybox_common.ObjectPropertiesType): defines the physical network interfaces and routing protocols. Protocol fields are provided but requirements are not enforced/captured; all fields are optional.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Link_Layer=None, Internet_Layer=None, Transport_Layer=None): @@ -8963,7 +8962,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -9009,7 +9008,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_route_entry_object.py b/cybox/bindings/network_route_entry_object.py index 400a9c29..5aa77043 100644 --- a/cybox/bindings/network_route_entry_object.py +++ b/cybox/bindings/network_route_entry_object.py @@ -4,9 +4,8 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object +from . import cybox_common +from . import address_object class RouteType(cybox_common.BaseObjectPropertyType): @@ -16,7 +15,7 @@ class RouteType(cybox_common.BaseObjectPropertyType): regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -93,7 +92,7 @@ class NetworkRouteEntryObjectType(cybox_common.ObjectPropertiesType): the route is the default for all packets sent to local network addresses.The is_publish field specifies whether the route is published.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_publish=None, is_autoconfigure_address=None, is_loopback=None, is_immortal=None, is_ipv6=None, Destination_Address=None, Origin=None, Netmask=None, Gateway_Address=None, Metric=None, Type=None, Protocol=None, Interface=None, Preferred_Lifetime=None, Valid_Lifetime=None, Route_Age=None): @@ -455,7 +454,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -501,7 +500,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_route_object.py b/cybox/bindings/network_route_object.py index cac5d50f..ec7c4918 100644 --- a/cybox/bindings/network_route_object.py +++ b/cybox/bindings/network_route_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import network_route_entry_object +from . import cybox_common +from . import network_route_entry_object class NetworkRouteEntriesType(GeneratedsSuper): """The NetworkRouteEntriesType type is intended to characterize the set of network route segments for this route.""" - + subclass = None superclass = None def __init__(self, Network_Route_Entry=None): @@ -86,7 +85,7 @@ class NetRouteObjectType(cybox_common.ObjectPropertiesType): specifies if the route is a loopback route (the gateway is on the local host).The is_publish field specifies if the route is published.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_publish=None, is_autoconfigure_address=None, is_loopback=None, is_immortal=None, is_ipv6=None, Description=None, Network_Route_Entries=None, Preferred_Lifetime=None, Valid_Lifetime=None, Route_Age=None): @@ -375,7 +374,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -421,7 +420,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_socket_object.py b/cybox/bindings/network_socket_object.py index 5d71ce5e..4543acc9 100644 --- a/cybox/bindings/network_socket_object.py +++ b/cybox/bindings/network_socket_object.py @@ -4,16 +4,15 @@ import sys from cybox.bindings import * -import cybox_common - -import socket_address_object +from . import cybox_common +from . import socket_address_object class SocketOptionsType(GeneratedsSuper): """The SocketOptionsType specifies any particular options used by the socket. If an options is supported only by specific address families or socket types, that's indicated in parentheses.""" - + subclass = None superclass = None def __init__(self, IP_MULTICAST_IF=None, IP_MULTICAST_IF2=None, IP_MULTICAST_LOOP=None, IP_TOS=None, SO_BROADCAST=None, SO_CONDITIONAL_ACCEPT=None, SO_KEEPALIVE=None, SO_DONTROUTE=None, SO_LINGER=None, SO_DONTLINGER=None, SO_OOBINLINE=None, SO_RCVBUF=None, SO_GROUP_PRIORITY=None, SO_REUSEADDR=None, SO_DEBUG=None, SO_RCVTIMEO=None, SO_SNDBUF=None, SO_SNDTIMEO=None, SO_UPDATE_ACCEPT_CONTEXT=None, SO_TIMEOUT=None, TCP_NODELAY=None): @@ -356,7 +355,7 @@ class ProtocolType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -429,7 +428,7 @@ class SocketType(cybox_common.BaseObjectPropertyType): regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -502,7 +501,7 @@ class DomainFamilyType(cybox_common.BaseObjectPropertyType): (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -575,7 +574,7 @@ class AddressFamilyType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -646,7 +645,7 @@ class NetworkSocketObjectType(cybox_common.ObjectPropertiesType): sockets.The is_blocking field specifies whether or not the socket is in blocking mode. The is_listening field specifies whether or not the socket is in listening mode.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_blocking=None, is_listening=None, Address_Family=None, Domain=None, Local_Address=None, Options=None, Protocol=None, Remote_Address=None, Type=None, Socket_Descriptor=None): @@ -937,7 +936,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -983,7 +982,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_subnet_object.py b/cybox/bindings/network_subnet_object.py index e705a0f1..6ed1f2fc 100644 --- a/cybox/bindings/network_subnet_object.py +++ b/cybox/bindings/network_subnet_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object -import network_route_entry_object +from . import cybox_common +from . import address_object +from . import network_route_entry_object class RoutesType(GeneratedsSuper): """The RoutesType is intended to characterize a set network routes.""" - + subclass = None superclass = None def __init__(self, Route=None): @@ -80,7 +79,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class NetworkSubnetObjectType(cybox_common.ObjectPropertiesType): """The NetworkSubnetObjectType type is intended to characterize a generic system network subnet.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Name=None, Description=None, Number_Of_IP_Addresses=None, Routes=None): @@ -294,7 +293,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -340,7 +339,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/pdf_file_object.py b/cybox/bindings/pdf_file_object.py index 4519ff4a..417b7cf2 100644 --- a/cybox/bindings/pdf_file_object.py +++ b/cybox/bindings/pdf_file_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import file_object +from . import cybox_common +from . import file_object class PDFXRefTableListType(GeneratedsSuper): """The PDFXrefTableListType captures a list of PDF cross-reference tables.""" - + subclass = None superclass = None def __init__(self, Cross_Reference_Table=None): @@ -81,7 +80,7 @@ class PDFXRefTableType(GeneratedsSuper): """The PDFXRefTableType captures the details of a PDF cross-reference table, which provides a capability for the random access of indirect objects contained in the file.""" - + subclass = None superclass = None def __init__(self, Subsections=None, Offset=None, Hashes=None): @@ -167,7 +166,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFXrefTableSubsectionListType(GeneratedsSuper): """The PDFXrefTableSubsectionListType captures a list of cross- reference table subsections.""" - + subclass = None superclass = None def __init__(self, Subsection=None): @@ -235,7 +234,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFXrefTableSubsectionType(GeneratedsSuper): """The PDFXrefTableSubsectionType captures details of subsections contained within a PDF cross-reference table.""" - + subclass = None superclass = None def __init__(self, First_Object_Number=None, Number_Of_Objects=None, Cross_Reference_Entries=None): @@ -320,7 +319,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFTrailerListType(GeneratedsSuper): """The PDFTrailerListType captures a list of PDF trailers.""" - + subclass = None superclass = None def __init__(self, Trailer=None): @@ -387,7 +386,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFTrailerType(GeneratedsSuper): """The PDFTrailerType captures the details of a PDF trailer.""" - + subclass = None superclass = None def __init__(self, Size=None, Prev=None, Root=None, Encrypt=None, Info=None, ID=None, Last_Cross_Reference_Offset=None, Offset=None, Hashes=None): @@ -533,7 +532,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFFileIDType(GeneratedsSuper): """The PDFTrailerIDType captures the details of a PDF ID value stored in a trailer.""" - + subclass = None superclass = None def __init__(self, ID_String=None): @@ -604,7 +603,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFIndirectObjectListType(GeneratedsSuper): """The PDFIndirectObjectListType captures a list of PDF indirect objects.""" - + subclass = None superclass = None def __init__(self, Indirect_Object=None): @@ -674,7 +673,7 @@ class PDFIndirectObjectType(GeneratedsSuper): object, used in constructing and storing data associated with the PDF document.The type field specifies the basic type of the PDF indirect object.""" - + subclass = None superclass = None def __init__(self, type_=None, ID=None, Contents=None, Offset=None, Hashes=None): @@ -778,7 +777,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFIndirectObjectIDType(GeneratedsSuper): """The PDFIndirectObjectIDType captures the details of PDF indirect object IDs.""" - + subclass = None superclass = None def __init__(self, Object_Number=None, Generation_Number=None): @@ -857,7 +856,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFIndirectObjectContentsType(GeneratedsSuper): """The PDFIndirectObjectContentsType captures the contents of a PDF indirect object, including both stream and non-stream portions.""" - + subclass = None superclass = None def __init__(self, Non_Stream_Contents=None, Stream_Contents=None): @@ -912,7 +911,7 @@ def exportChildren(self, lwrite, level, namespace_='PDFFileObj:', name_='PDFIndi value = self.Non_Stream_Contents.get_valueOf_() if not value.startswith('' - self.Non_Stream_Contents.set_valueOf_(value) + self.Non_Stream_Contents.set_valueOf_(value) self.Non_Stream_Contents.export(lwrite, level, 'PDFFileObj:', name_='Non_Stream_Contents', pretty_print=pretty_print) if self.Stream_Contents is not None: self.Stream_Contents.export(lwrite, level, 'PDFFileObj:', name_='Stream_Contents', pretty_print=pretty_print) @@ -938,7 +937,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFStreamType(GeneratedsSuper): """The PDFStreamType element captures details of PDF document stream objects, which represent arbitrary sequences of bytes.""" - + subclass = None superclass = None def __init__(self, Raw_Stream=None, Raw_Stream_Hashes=None, Decoded_Stream=None, Decoded_Stream_Hashes=None): @@ -1038,7 +1037,7 @@ class PDFDocumentInformationDictionaryType(GeneratedsSuper): """The PDFDocumentInformationDictionaryType captures details of the PDF Document Information Dictionary, used for storing metadata associated with the PDF document.""" - + subclass = None superclass = None def __init__(self, Title=None, Author=None, Subject=None, Keywords=None, Creator=None, Producer=None, CreationDate=None, ModDate=None, Trapped=None): @@ -1187,7 +1186,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFXrefEntryListType(GeneratedsSuper): """The PDFXrefEntryListType captures a list of cross-reference table subsection entries.""" - + subclass = None superclass = None def __init__(self, Cross_Reference_Entry=None): @@ -1256,7 +1255,7 @@ class PDFXrefEntryType(GeneratedsSuper): """The PDFXrefEntryType captures details of a cross-reference table subsection entry.The type field specifies the type of the cross- reference entry.""" - + subclass = None superclass = None def __init__(self, type_=None, Byte_Offset=None, Object_Number=None, Generation_Number=None): @@ -1354,7 +1353,7 @@ class PDFDictionaryType(GeneratedsSuper): """The PDFDictionaryType captures a PDF dictionary as a set of key value pairs, or as a reference to an indirect object that contains.""" - + subclass = None superclass = None def __init__(self, Object_Reference=None, Raw_Contents=None): @@ -1411,7 +1410,7 @@ def exportChildren(self, lwrite, level, namespace_='PDFFileObj:', name_='PDFDict value = self.Raw_Contents.get_valueOf_() if not value.startswith('' - self.Raw_Contents.set_valueOf_(value) + self.Raw_Contents.set_valueOf_(value) self.Raw_Contents.export(lwrite, level, 'PDFFileObj:', name_='Raw_Contents', pretty_print=pretty_print) def build(self, node): already_processed = set() @@ -1437,7 +1436,7 @@ class PDFFileMetadataType(GeneratedsSuper): object.The encrypted field specifies whether the PDF file is encrypted.The optimized field specifies whether the PDF file has been optimized.""" - + subclass = None superclass = None def __init__(self, encrypted=None, optimized=None, Document_Information_Dictionary=None, Number_Of_Indirect_Objects=None, Number_Of_Trailers=None, Number_Of_Cross_Reference_Tables=None, Keyword_Counts=None): @@ -1571,7 +1570,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFKeywordCountsType(GeneratedsSuper): """The PDFKeywordCountsType captures the occurrences of various keywords in a PDF file.""" - + subclass = None superclass = None def __init__(self, Page_Count=None, Encrypt_Count=None, ObjStm_Count=None, JS_Count=None, JavaScript_Count=None, AA_Count=None, OpenAction_Count=None, ASCIIHexDecode_Count=None, ASCII85Decode_Count=None, LZWDecode_Count=None, FlateDecode_Count=None, RunLengthDecode_Count=None, JBIG2Decode_Count=None, DCTDecode_Count=None, RichMedia_Count=None, CCITTFaxDecode_Count=None, Launch_Count=None, XFA_Count=None): @@ -1804,7 +1803,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFKeywordCountType(GeneratedsSuper): """The PDFKeywordCountType captures the obfuscated and non-obfuscated occurrences of a keyword.""" - + subclass = None superclass = None def __init__(self, Non_Obfuscated_Count=None, Obfuscated_Count=None): @@ -1880,7 +1879,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PDFFileObjectType(file_object.FileObjectType): """The PDFFileObjectType type is intended to characterize the structural makeup of PDF files.""" - + subclass = None superclass = file_object.FileObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_packed=None, File_Name=None, File_Path=None, Device_Path=None, Full_Path=None, File_Extension=None, Size_In_Bytes=None, Magic_Number=None, File_Format=None, Hashes=None, Digital_Signatures=None, Modified_Time=None, Accessed_Time=None, Created_Time=None, File_Attributes_List=None, Permissions=None, User_Owner=None, Packer_List=None, Peak_Entropy=None, Sym_Links=None, Byte_Runs=None, Extracted_Features=None, Metadata=None, Version=None, Indirect_Objects=None, Cross_Reference_Tables=None, Trailers=None): @@ -2145,7 +2144,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -2191,7 +2190,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/pipe_object.py b/cybox/bindings/pipe_object.py index b9f2a6bf..f800ff0f 100644 --- a/cybox/bindings/pipe_object.py +++ b/cybox/bindings/pipe_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class PipeObjectType(cybox_common.ObjectPropertiesType): """The PipeObjectType type is intended to characterize generic system pipes.The named field specifies whether the pipe is named.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, named=None, Name=None): @@ -190,7 +190,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -236,7 +236,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/port_object.py b/cybox/bindings/port_object.py index 2daf19a9..a87b51e0 100644 --- a/cybox/bindings/port_object.py +++ b/cybox/bindings/port_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class Layer4ProtocolType(cybox_common.BaseObjectPropertyType): @@ -14,7 +14,7 @@ class Layer4ProtocolType(cybox_common.BaseObjectPropertyType): for permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, pattern_type=None, datatype='string', refanging_transform=None, bit_mask=None, appears_random=None, trend=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -83,7 +83,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PortObjectType(cybox_common.ObjectPropertiesType): """The PortObjectType type is intended to characterize networking ports.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Port_Value=None, Layer4_Protocol=None): @@ -262,7 +262,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -308,7 +308,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/process_object.py b/cybox/bindings/process_object.py index e1aa5786..61e1712d 100644 --- a/cybox/bindings/process_object.py +++ b/cybox/bindings/process_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import network_connection_object -import port_object +from . import cybox_common +from . import network_connection_object +from . import port_object class NetworkConnectionListType(GeneratedsSuper): """The NetworkConnectionListType type is a list of network connections.""" - + subclass = None superclass = None def __init__(self, Network_Connection=None): @@ -79,7 +78,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ImageInfoType(GeneratedsSuper): """The ImageInfoType type captures information about the process image.""" - + subclass = None superclass = None def __init__(self, File_Name=None, Command_Line=None, Current_Directory=None, Path=None): @@ -177,7 +176,7 @@ class ProcessStatusType(GeneratedsSuper): or terminated process. Since this property is platform-specific, it is created here as an abstract type and then used in the platform-specific process CybOX objects.""" - + subclass = None superclass = None def __init__(self): @@ -229,7 +228,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ChildPIDListType(GeneratedsSuper): """The ChildPIDListType type captures the PID's of the children of the process in a list format.""" - + subclass = None superclass = None def __init__(self, Child_PID=None): @@ -300,7 +299,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class ArgumentListType(GeneratedsSuper): """The ArgumentListType is intended to specify a list of arguments utlized in intiating the process.""" - + subclass = None superclass = None def __init__(self, Argument=None): @@ -370,7 +369,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PortListType(GeneratedsSuper): """The PortListType is intended to specify a list of network ports.""" - + subclass = None superclass = None def __init__(self, Port=None): @@ -439,7 +438,7 @@ class ProcessObjectType(cybox_common.ObjectPropertiesType): """The ProcessObjectType type is intended to characterize system processes.The is_hidden field specifies whether the process is hidden or not.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_hidden=None, PID=None, Name=None, Creation_Time=None, Parent_PID=None, Child_PID_List=None, Image_Info=None, Argument_List=None, Environment_Variable_List=None, Kernel_Time=None, Port_List=None, Network_Connection_List=None, Start_Time=None, Status=None, Username=None, User_Time=None, Extracted_Features=None): @@ -888,7 +887,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -934,7 +933,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/product_object.py b/cybox/bindings/product_object.py index d7a3f1ed..feee270d 100644 --- a/cybox/bindings/product_object.py +++ b/cybox/bindings/product_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class ProductObjectType(cybox_common.ObjectPropertiesType): """The ProductObjectType type is intended to characterize software or hardware products.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Edition=None, Language=None, Product=None, Update=None, Vendor=None, Version=None): @@ -230,7 +230,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -276,7 +276,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/semaphore_object.py b/cybox/bindings/semaphore_object.py index 05228df1..dd096541 100644 --- a/cybox/bindings/semaphore_object.py +++ b/cybox/bindings/semaphore_object.py @@ -4,14 +4,14 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class SemaphoreObjectType(cybox_common.ObjectPropertiesType): """The SemaphoreObjectType type is intended to characterize generic semaphore objects.The named field specifies whether the Semaphore is named.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, named=None, Current_Count=None, Maximum_Count=None, Name=None): @@ -219,7 +219,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -265,7 +265,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/sms_message_object.py b/cybox/bindings/sms_message_object.py index 7882a64d..9c7a24ed 100644 --- a/cybox/bindings/sms_message_object.py +++ b/cybox/bindings/sms_message_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class SMSMessageObjectType(cybox_common.ObjectPropertiesType): @@ -298,7 +298,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -344,7 +344,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/socket_address_object.py b/cybox/bindings/socket_address_object.py index 80545e8d..fc9127f8 100644 --- a/cybox/bindings/socket_address_object.py +++ b/cybox/bindings/socket_address_object.py @@ -4,17 +4,16 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object -import hostname_object -import port_object +from . import cybox_common +from . import address_object +from . import hostname_object +from . import port_object class SocketAddressObjectType(cybox_common.ObjectPropertiesType): """The SocketAddressObjectType specifies an IP address/port number pair.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, IP_Address=None, Hostname=None, Port=None): @@ -203,7 +202,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -249,7 +248,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/system_object.py b/cybox/bindings/system_object.py index 9f166b74..3693c0f3 100644 --- a/cybox/bindings/system_object.py +++ b/cybox/bindings/system_object.py @@ -4,14 +4,13 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object +from . import cybox_common +from . import address_object class BIOSInfoType(GeneratedsSuper): """The BIOSInfoType type specifies information about a system's BIOS.""" - + subclass = None superclass = None def __init__(self, BIOS_Date=None, BIOS_Version=None, BIOS_Manufacturer=None, BIOS_Release_Date=None, BIOS_Serial_Number=None): @@ -120,7 +119,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class NetworkInterfaceListType(GeneratedsSuper): """The NetworkInterfaceListType type specifies information about the network interfaces present on the system.""" - + subclass = None superclass = None def __init__(self, Network_Interface=None): @@ -188,7 +187,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPGatewayListType(GeneratedsSuper): """The IPGatewayListType type specifies the IP Addresses of the gateways used by the system.""" - + subclass = None superclass = None def __init__(self, IP_Gateway_Address=None): @@ -256,7 +255,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class NetworkInterfaceType(GeneratedsSuper): """The NetworkInterfaceType type specifies information about a network interface, such as its MAC address.""" - + subclass = None superclass = None def __init__(self, Adapter=None, Description=None, DHCP_Lease_Expires=None, DHCP_Lease_Obtained=None, DHCP_Server_List=None, IP_Gateway_List=None, IP_List=None, MAC=None): @@ -395,7 +394,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPInfoListType(GeneratedsSuper): """The IPInfoListType type specifies a list of IP address/subnet mask pairs associated with a network interface.""" - + subclass = None superclass = None def __init__(self, IP_Info=None): @@ -463,7 +462,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IPInfoType(GeneratedsSuper): """The IP_Info type specifies information about the IP address and its associated subnet mask used by a network interface.""" - + subclass = None superclass = None def __init__(self, IP_Address=None, Subnet_Mask=None): @@ -536,7 +535,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class DHCPServerListType(GeneratedsSuper): """The DHCPServerListType type specifies a list of DHCP Servers, via their IP addresses.""" - + subclass = None superclass = None def __init__(self, DHCP_Server_Address=None): @@ -608,7 +607,7 @@ class BitnessType(cybox_common.BaseObjectPropertyType): (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -681,7 +680,7 @@ class ProcessorArchType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -751,7 +750,7 @@ class OSType(cybox_common.PlatformSpecificationType): """The OSType type specifies information about an operating system. It imports and extends the cybox_common.PlatformSpecificationType from the CybOX Common Types.""" - + subclass = None superclass = cybox_common.PlatformSpecificationType def __init__(self, Description=None, Identifier=None, Bitness=None, Build_Number=None, Environment_Variable_List=None, Install_Date=None, Patch_Level=None, Platform=None): @@ -877,7 +876,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class SystemObjectType(cybox_common.ObjectPropertiesType): """The SystemObjectType type is intended to characterize computer systems (as a combination of both software and hardware).""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Available_Physical_Memory=None, BIOS_Info=None, Date=None, Hostname=None, Local_Time=None, Network_Interface_List=None, OS=None, Processor=None, Processor_Architecture=None, System_Time=None, Timezone_DST=None, Timezone_Standard=None, Total_Physical_Memory=None, Uptime=None, Username=None): @@ -1227,7 +1226,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -1273,7 +1272,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_file_object.py b/cybox/bindings/unix_file_object.py index 1cd4d129..03b41efb 100644 --- a/cybox/bindings/unix_file_object.py +++ b/cybox/bindings/unix_file_object.py @@ -4,9 +4,8 @@ import sys from cybox.bindings import * -import cybox_common - -import file_object +from . import cybox_common +from . import file_object class UnixFileType(cybox_common.BaseObjectPropertyType): @@ -16,7 +15,7 @@ class UnixFileType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -101,7 +100,7 @@ class UnixFilePermissionsType(file_object.FilePermissionsType): field specifies whether or not all other users can write to the file.The oexec field specifies whether or not all other users can execute the file.""" - + subclass = None superclass = file_object.FilePermissionsType def __init__(self, gwrite=None, suid=None, oexec=None, owrite=None, uwrite=None, gexec=None, gread=None, uexec=None, uread=None, sgid=None, oread=None): @@ -320,7 +319,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class UnixFileObjectType(file_object.FileObjectType): """The UnixFileObjectType type is intended to characterize Unix files.""" - + subclass = None superclass = file_object.FileObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_packed=None, File_Name=None, File_Path=None, Device_Path=None, Full_Path=None, File_Extension=None, Size_In_Bytes=None, Magic_Number=None, File_Format=None, Hashes=None, Digital_Signatures=None, Modified_Time=None, Accessed_Time=None, Created_Time=None, File_Attributes_List=None, Permissions=None, User_Owner=None, Packer_List=None, Peak_Entropy=None, Sym_Links=None, Byte_Runs=None, Extracted_Features=None, Group_Owner=None, INode=None, Type=None): @@ -544,7 +543,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -590,7 +589,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_network_route_entry_object.py b/cybox/bindings/unix_network_route_entry_object.py index 2e8c958c..a54b3b37 100644 --- a/cybox/bindings/unix_network_route_entry_object.py +++ b/cybox/bindings/unix_network_route_entry_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import network_route_entry_object +from . import cybox_common +from . import network_route_entry_object class UnixNetworkRouteEntryObjectType(network_route_entry_object.NetworkRouteEntryObjectType): """The UnixNetworkRouteEntryObjectType type is intended to characterize entries in the network routing table of a Unix system.""" - + subclass = None superclass = network_route_entry_object.NetworkRouteEntryObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_publish=None, is_autoconfigure_address=None, is_loopback=None, is_immortal=None, is_ipv6=None, Destination_Address=None, Origin=None, Netmask=None, Gateway_Address=None, Metric=None, Type=None, Protocol=None, Interface=None, Preferred_Lifetime=None, Valid_Lifetime=None, Route_Age=None, Flags=None, MSS=None, Ref=None, Use=None, Window=None): @@ -237,7 +236,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -283,7 +282,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_pipe_object.py b/cybox/bindings/unix_pipe_object.py index 57fb6c4b..8bc3d622 100644 --- a/cybox/bindings/unix_pipe_object.py +++ b/cybox/bindings/unix_pipe_object.py @@ -4,14 +4,13 @@ import sys from cybox.bindings import * -import cybox_common - -import pipe_object +from . import cybox_common +from . import pipe_object class UnixPipeObjectType(pipe_object.PipeObjectType): """The UnixPipeObjectType type is intended to characterize Unix pipes.""" - + subclass = None superclass = pipe_object.PipeObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, named=None, Name=None, Permission_Mode=None): @@ -178,7 +177,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -224,7 +223,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_process_object.py b/cybox/bindings/unix_process_object.py index 613a5186..87404ec3 100644 --- a/cybox/bindings/unix_process_object.py +++ b/cybox/bindings/unix_process_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import process_object +from . import cybox_common +from . import process_object class FileDescriptorListType(GeneratedsSuper): """The FileDescriptorListType type specifies a list of Unix file descriptors.""" - + subclass = None superclass = None def __init__(self, File_Descriptor=None): @@ -88,7 +87,7 @@ class UnixProcessStateType(cybox_common.BaseObjectPropertyType): specifications. See "man ps" for more information.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -158,7 +157,7 @@ class UnixProcessStatusType(process_object.ProcessStatusType): """The UnixProcessStatusType field specifies the current status of the running Unix process. It extends the abstract process_object.ProcessStatusType from the CybOX Process Object.""" - + subclass = None superclass = process_object.ProcessStatusType def __init__(self, Current_Status=None, Timestamp=None): @@ -241,7 +240,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class UnixProcessObjectType(process_object.ProcessObjectType): """The UnixProcessObjectType type is intended to characterize Unix processes.""" - + subclass = None superclass = process_object.ProcessObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_hidden=None, PID=None, Name=None, Creation_Time=None, Parent_PID=None, Child_PID_List=None, Image_Info=None, Argument_List=None, Environment_Variable_List=None, Kernel_Time=None, Port_List=None, Network_Connection_List=None, Start_Time=None, Status=None, Username=None, User_Time=None, Extracted_Features=None, Open_File_Descriptor_List=None, Priority=None, RUID=None, Session_ID=None): @@ -538,7 +537,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -584,7 +583,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_user_account_object.py b/cybox/bindings/unix_user_account_object.py index 2939413b..273088ca 100644 --- a/cybox/bindings/unix_user_account_object.py +++ b/cybox/bindings/unix_user_account_object.py @@ -4,16 +4,15 @@ import sys from cybox.bindings import * -import cybox_common - -import user_account_object +from . import cybox_common +from . import user_account_object class UnixPrivilegeType(user_account_object.PrivilegeType): """The UnixPrivilegeType type is used to specify Unix privileges. It extends the abstract user_account_object.PrivilegeType from the CybOX UserAccount object.""" - + subclass = None superclass = user_account_object.PrivilegeType def __init__(self, Permissions_Mask=None): @@ -84,7 +83,7 @@ class UnixGroupType(user_account_object.GroupType): """The UnixGroupType type is used for specifying Unix groups. It extends the abstract user_account_object.GroupType from the Cybox UserAccount construct.""" - + subclass = None superclass = user_account_object.GroupType def __init__(self, Group_ID=None): @@ -154,7 +153,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class UnixUserAccountObjectType(user_account_object.UserAccountObjectType): """The UnixUserAccountType type is intended to characterize Unix user accounts.""" - + subclass = None superclass = user_account_object.UserAccountObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, disabled=None, locked_out=None, Description=None, Domain=None, password_required=None, Full_Name=None, Group_List=None, Home_Directory=None, Last_Login=None, Privilege_List=None, Script_Path=None, Username=None, User_Password_Age=None, Group_ID=None, User_ID=None, Login_Shell=None): @@ -358,7 +357,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -404,7 +403,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_volume_object.py b/cybox/bindings/unix_volume_object.py index 07cf67a2..f525177b 100644 --- a/cybox/bindings/unix_volume_object.py +++ b/cybox/bindings/unix_volume_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import volume_object +from . import cybox_common +from . import volume_object class UnixVolumeObjectType(volume_object.VolumeObjectType): """The UnixVolumeObjectType type is intended to characterize Unix disk volumes.""" - + subclass = None superclass = volume_object.VolumeObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_mounted=None, Name=None, Device_Path=None, File_System_Type=None, Total_Allocation_Units=None, Sectors_Per_Allocation_Unit=None, Bytes_Per_Sector=None, Actual_Available_Allocation_Units=None, Creation_Time=None, File_System_Flag_List=None, Serial_Number=None, Mount_Point=None, Options=None): @@ -200,7 +199,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -246,7 +245,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/uri_object.py b/cybox/bindings/uri_object.py index d8792aa8..2ee61529 100644 --- a/cybox/bindings/uri_object.py +++ b/cybox/bindings/uri_object.py @@ -4,14 +4,14 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class URIObjectType(cybox_common.ObjectPropertiesType): """The URIObjectType type is intended to characterize Uniform Resource Identifiers (URI's).The type field specifies the type of URI that is being defined.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, type_=None, Value=None): @@ -186,7 +186,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -232,7 +232,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/url_history_object.py b/cybox/bindings/url_history_object.py index 4e259efb..35ad630a 100644 --- a/cybox/bindings/url_history_object.py +++ b/cybox/bindings/url_history_object.py @@ -4,10 +4,9 @@ import sys from cybox.bindings import * -import cybox_common - -import hostname_object -import uri_object +from . import cybox_common +from . import hostname_object +from . import uri_object class URLHistoryEntryType(GeneratedsSuper): @@ -385,7 +384,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -431,7 +430,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/user_account_object.py b/cybox/bindings/user_account_object.py index 7504a721..8ad2fe72 100644 --- a/cybox/bindings/user_account_object.py +++ b/cybox/bindings/user_account_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import account_object +from . import cybox_common +from . import account_object class PrivilegeListType(GeneratedsSuper): """The PrivilegeListType type specifies the list of privileges that the user account has.""" - + subclass = None superclass = None def __init__(self, Privilege=None): @@ -96,7 +95,7 @@ class PrivilegeType(GeneratedsSuper): has. This is an abstract type since user privileges are operating-system specific, and is extended as needed in the derived CybOX object schemas.""" - + subclass = None superclass = None def __init__(self): @@ -148,7 +147,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class GroupListType(GeneratedsSuper): """The GroupListType type specifies the groups that the user account belongs to.""" - + subclass = None superclass = None def __init__(self, Group=None): @@ -232,7 +231,7 @@ class GroupType(GeneratedsSuper): This is an abstract type since group IDs are operating-system specific, and is extended as needed in the derived CybOX object schemas.""" - + subclass = None superclass = None def __init__(self): @@ -285,7 +284,7 @@ class UserAccountObjectType(account_object.AccountObjectType): """The UserAccountObjectType type is intended to characterize generic user accounts.The password_required field specifies whether a password is required for this user account.""" - + subclass = None superclass = account_object.AccountObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, disabled=None, locked_out=None, Description=None, Domain=None, password_required=None, Full_Name=None, Group_List=None, Home_Directory=None, Last_Login=None, Privilege_List=None, Script_Path=None, Username=None, User_Password_Age=None): @@ -549,7 +548,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -595,7 +594,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/user_session_object.py b/cybox/bindings/user_session_object.py index 52b88996..b284ebba 100644 --- a/cybox/bindings/user_session_object.py +++ b/cybox/bindings/user_session_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class UserSessionObjectType(cybox_common.ObjectPropertiesType): """The UserSessionObjectType type is intended to characterize user sessions.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Effective_Group=None, Effective_Group_ID=None, Effective_User=None, Effective_User_ID=None, Login_Time=None, Logout_Time=None): @@ -234,7 +234,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -280,7 +280,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/volume_object.py b/cybox/bindings/volume_object.py index 940d4695..148da17e 100644 --- a/cybox/bindings/volume_object.py +++ b/cybox/bindings/volume_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class VolumeOptionsType(GeneratedsSuper): @@ -12,7 +12,7 @@ class VolumeOptionsType(GeneratedsSuper): the volume. This is an abstract type since volume options are OS-specific, and is extended by the related OS-specific CybOX volume objects.""" - + subclass = None superclass = None def __init__(self): @@ -64,7 +64,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class FileSystemFlagListType(GeneratedsSuper): """The FileSystemFlagListType is a listing of the flags specified for the volume by the file system.""" - + subclass = None superclass = None def __init__(self, File_System_Flag=None): @@ -139,7 +139,7 @@ class VolumeFileSystemFlagType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -209,7 +209,7 @@ class VolumeObjectType(cybox_common.ObjectPropertiesType): """The VolumeObjectType type is intended to characterize generic drive volumes.The is_mounted field specifies whether the volume is mounted.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_mounted=None, Name=None, Device_Path=None, File_System_Type=None, Total_Allocation_Units=None, Sectors_Per_Allocation_Unit=None, Bytes_Per_Sector=None, Actual_Available_Allocation_Units=None, Creation_Time=None, File_System_Flag_List=None, Serial_Number=None): @@ -499,7 +499,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -545,7 +545,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/whois_object.py b/cybox/bindings/whois_object.py index 9bc319cc..0a944a7d 100644 --- a/cybox/bindings/whois_object.py +++ b/cybox/bindings/whois_object.py @@ -4,14 +4,13 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object -import uri_object +from . import cybox_common +from . import address_object +from . import uri_object class WhoisRegistrarInfoType(GeneratedsSuper): - + subclass = None superclass = None def __init__(self, Registrar_ID=None, Registrar_GUID=None, Name=None, Address=None, Email_Address=None, Phone_Number=None, Whois_Server=None, Referral_URL=None, Contacts=None): @@ -157,7 +156,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WhoisContactsType(GeneratedsSuper): """The WhoisContactsType represents a list of contacts (usually registrar or registrant) found in a Whois entry""" - + subclass = None superclass = None def __init__(self, Contact=None): @@ -225,7 +224,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WhoisContactType(GeneratedsSuper): """The contact_type field specifies what type of contact this is. Only values from WhoisObj:RegistrarContactTypeEnum can be used.""" - + subclass = None superclass = None def __init__(self, contact_type=None, Contact_ID=None, Name=None, Email_Address=None, Phone_Number=None, Fax_Number=None, Address=None, Organization=None, extensiontype_=None): @@ -369,7 +368,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WhoisStatusesType(GeneratedsSuper): """The WhoisStatusesType defines a list of WhoisStatusType objecst""" - + subclass = None superclass = None def __init__(self, Status=None): @@ -440,7 +439,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WhoisNameserversType(GeneratedsSuper): """The WhoisNameserversType defines a list of nameservers associated with a Whois entry""" - + subclass = None superclass = None def __init__(self, Nameserver=None): @@ -506,7 +505,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): # end class WhoisNameserversType class WhoisRegistrantInfoType(WhoisContactType): - + subclass = None superclass = WhoisContactType def __init__(self, contact_type=None, Contact_ID=None, Name=None, Email_Address=None, Phone_Number=None, Fax_Number=None, Address=None, Organization=None, Registrant_ID=None): @@ -576,7 +575,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WhoisRegistrantsType(GeneratedsSuper): """The WhoisRegistrantsType represents a list of registrant information for a given Whois entry""" - + subclass = None superclass = None def __init__(self, Registrant=None): @@ -646,7 +645,7 @@ class RegionalRegistryType(cybox_common.BaseObjectPropertyType): (RIR) for a given WHOIS entry. RIRs defined by the RegionalRegistryTypeEnum may be used, as well as those specified by a free form text string.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, pattern_type=None, datatype='string', refanging_transform=None, bit_mask=None, appears_random=None, trend=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -706,7 +705,7 @@ class WhoisStatusType(cybox_common.BaseObjectPropertyType): """The WhoisStatusType specifies a status for a domain as listed in its Whois entry. Only statuses defined by WhoisStatusTypeEnum can be used.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None, extensiontype_=None): @@ -765,7 +764,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WhoisObjectType(cybox_common.ObjectPropertiesType): """The WhoisObjectType type is intended to characterize Whois information for a domain.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Lookup_Date=None, Domain_Name=None, Domain_ID=None, Server_Name=None, IP_Address=None, DNSSEC=None, Nameservers=None, Status=None, Updated_Date=None, Creation_Date=None, Expiration_Date=None, Regional_Internet_Registry=None, Sponsoring_Registrar=None, Registrar_Info=None, Registrants=None, Contact_Info=None, Remarks=None): @@ -1120,7 +1119,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -1166,7 +1165,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_computer_account_object.py b/cybox/bindings/win_computer_account_object.py index a4bb9a61..66bffe49 100644 --- a/cybox/bindings/win_computer_account_object.py +++ b/cybox/bindings/win_computer_account_object.py @@ -4,16 +4,15 @@ import sys from cybox.bindings import * -import cybox_common - -import account_object -import port_object +from . import cybox_common +from . import account_object +from . import port_object class FullyQualifiedNameType(GeneratedsSuper): """The FullyQualifiedNameType type refers to the fully qualified name(s) of the Windows computer account.""" - + subclass = None superclass = None def __init__(self, NetBEUI_Name=None, Full_Name=None): @@ -89,7 +88,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class KerberosType(GeneratedsSuper): """The KerberosType type specifies the Kerberos authentication protocol specific Object properties for the Windows computer account.""" - + subclass = None superclass = None def __init__(self, Delegation=None, Ticket=None): @@ -165,7 +164,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class KerberosDelegationType(GeneratedsSuper): """The Delegation field specifies the Kerberos delegation used for the Windows computer account.""" - + subclass = None superclass = None def __init__(self, Bitmask=None, Service=None): @@ -241,7 +240,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class KerberosServiceType(GeneratedsSuper): """The KerberosServiceType specifies the properties of the Kerberos delegation service for the Windows computer account.""" - + subclass = None superclass = None def __init__(self, Computer=None, Name=None, Port=None, User=None): @@ -337,7 +336,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsComputerAccountObjectType(account_object.AccountObjectType): """The WinComputerAccountObject type is intended to characterize Windows computer accounts.""" - + subclass = None superclass = account_object.AccountObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, disabled=None, locked_out=None, Description=None, Domain=None, Fully_Qualified_Name=None, Kerberos=None, Security_ID=None, Security_Type=None, Type=None): @@ -558,7 +557,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -604,7 +603,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_critical_section_object.py b/cybox/bindings/win_critical_section_object.py index ea71afad..10fe77da 100644 --- a/cybox/bindings/win_critical_section_object.py +++ b/cybox/bindings/win_critical_section_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class WindowsCriticalSectionObjectType(cybox_common.ObjectPropertiesType): """The WindowsCriticalSectionObjectType type is intended to characterize Windows Critical Section objects.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Address=None, Spin_Count=None): @@ -189,7 +189,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -235,7 +235,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_driver_object.py b/cybox/bindings/win_driver_object.py index 43812a59..7f3c3437 100644 --- a/cybox/bindings/win_driver_object.py +++ b/cybox/bindings/win_driver_object.py @@ -4,9 +4,8 @@ import sys from cybox.bindings import * -import cybox_common - -import win_executable_file_object +from . import cybox_common +from . import win_executable_file_object class DeviceObjectStructType(GeneratedsSuper): @@ -15,7 +14,7 @@ class DeviceObjectStructType(GeneratedsSuper): virtual, or physical device for which a driver handles I/O requests. See also: http://msdn.microsoft.com/en- us/library/windows/hardware/ff543147(v=vs.85).aspx""" - + subclass = None superclass = None def __init__(self, Attached_Device_Name=None, Attached_Device_Object=None, Attached_To_Device_Name=None, Attached_To_Device_Object=None, Attached_To_Driver_Object=None, Attached_To_Driver_Name=None, Device_Name=None, Device_Object=None): @@ -153,7 +152,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class DeviceObjectListType(GeneratedsSuper): """The DeviceObjectListType specifies a list of device objects.""" - + subclass = None superclass = None def __init__(self, Device_Object_Struct=None): @@ -221,7 +220,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsDriverObjectType(win_executable_file_object.WindowsExecutableFileObjectType): """The WindowsDriverObject type is intended to characterize Windows device drivers.""" - + subclass = None superclass = win_executable_file_object.WindowsExecutableFileObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Device_Object_List=None, Driver_Init=None, Driver_Name=None, Driver_Object_Address=None, Driver_Start_IO=None, Driver_Unload=None, Image_Base=None, Image_Size=None, IRP_MJ_CLEANUP=None, IRP_MJ_CLOSE=None, IRP_MJ_CREATE=None, IRP_MJ_CREATE_MAILSLOT=None, IRP_MJ_CREATE_NAMED_PIPE=None, IRP_MJ_DEVICE_CHANGE=None, IRP_MJ_DEVICE_CONTROL=None, IRP_MJ_DIRECTORY_CONTROL=None, IRP_MJ_FILE_SYSTEM_CONTROL=None, IRP_MJ_FLUSH_BUFFERS=None, IRP_MJ_INTERNAL_DEVICE_CONTROL=None, IRP_MJ_LOCK_CONTROL=None, IRP_MJ_PNP=None, IRP_MJ_POWER=None, IRP_MJ_READ=None, IRP_MJ_QUERY_EA=None, IRP_MJ_QUERY_INFORMATION=None, IRP_MJ_QUERY_SECURITY=None, IRP_MJ_QUERY_QUOTA=None, IRP_MJ_QUERY_VOLUME_INFORMATION=None, IRP_MJ_SET_EA=None, IRP_MJ_SET_INFORMATION=None, IRP_MJ_SET_SECURITY=None, IRP_MJ_SET_QUOTA=None, IRP_MJ_SET_VOLUME_INFORMATION=None, IRP_MJ_SHUTDOWN=None, IRP_MJ_SYSTEM_CONTROL=None, IRP_MJ_WRITE=None): @@ -785,7 +784,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -831,7 +830,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_event_log_object.py b/cybox/bindings/win_event_log_object.py index 11e63b19..013f18f5 100644 --- a/cybox/bindings/win_event_log_object.py +++ b/cybox/bindings/win_event_log_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class UnformattedMessageListType(GeneratedsSuper): """The UnformattedMessageListType type is a list of unformatted messages in the event log entry.""" - + subclass = None superclass = None def __init__(self, Unformatted_Message=None): @@ -81,7 +81,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsEventLogObjectType(cybox_common.ObjectPropertiesType): """The WindowsEventLogObjectType type is intended to characterize entries in the Windows event log.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, EID=None, Type=None, Log=None, Message=None, Category_Num=None, Category=None, Generation_Time=None, Source=None, Machine=None, User=None, Blob=None, Correlation_Activity_ID=None, Correlation_Related_Activity_ID=None, Execution_Process_ID=None, Execution_Thread_ID=None, Index=None, Reserved=None, Unformatted_Message_List=None, Write_Time=None): @@ -453,7 +453,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -499,7 +499,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_event_object.py b/cybox/bindings/win_event_object.py index ea37174a..5ea7feca 100644 --- a/cybox/bindings/win_event_object.py +++ b/cybox/bindings/win_event_object.py @@ -4,9 +4,8 @@ import sys from cybox.bindings import * -import cybox_common - -import win_handle_object +from . import cybox_common +from . import win_handle_object class WinEventType(cybox_common.BaseObjectPropertyType): @@ -16,7 +15,7 @@ class WinEventType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -85,7 +84,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsEventObjectType(cybox_common.ObjectPropertiesType): """The WindowsEventObjectType type is intended to characterize Windows event (synchronization) objects.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Handle=None, Name=None, Type=None): @@ -279,7 +278,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -325,7 +324,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_executable_file_object.py b/cybox/bindings/win_executable_file_object.py index 879ff1f2..2289d1ef 100644 --- a/cybox/bindings/win_executable_file_object.py +++ b/cybox/bindings/win_executable_file_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import win_file_object +from . import cybox_common +from . import win_file_object class PEChecksumType(GeneratedsSuper): """The PECheckSumType records the checksum of the PE file, both as found in the file and computed.""" - + subclass = None superclass = None def __init__(self, PE_Computed_API=None, PE_File_API=None, PE_File_Raw=None): @@ -101,7 +100,7 @@ class PEExportsType(GeneratedsSuper): by the PE File (a DLL) which can be dynamically loaded by other executables. This type abstracts, and its components, abstract the Windows structures.""" - + subclass = None superclass = None def __init__(self, Name=None, Exported_Functions=None, Number_Of_Functions=None, Exports_Time_Stamp=None, Number_Of_Addresses=None, Number_Of_Names=None): @@ -219,7 +218,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PEExportedFunctionsType(GeneratedsSuper): """PEExportedFunctionsType specifies a list of PE exported functions""" - + subclass = None superclass = None def __init__(self, Exported_Function=None): @@ -286,7 +285,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PESectionListType(GeneratedsSuper): """Specifies a list of sections that appear in the PE file.""" - + subclass = None superclass = None def __init__(self, Section=None): @@ -353,7 +352,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class EntropyType(GeneratedsSuper): """Specifies the result of an entropy computation.""" - + subclass = None superclass = None def __init__(self, Value=None, Min=None, Max=None): @@ -446,7 +445,7 @@ class PEImportType(GeneratedsSuper): binary will typically have few initially visible imports, and thus it is necessary to make the distinction between those that are visible initially or only after the binary is unpacked.""" - + subclass = None superclass = None def __init__(self, initially_visible=None, delay_load=None, File_Name=None, Imported_Functions=None, Virtual_Address=None): @@ -562,7 +561,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PEImportedFunctionsType(GeneratedsSuper): """A list of PE imported functions""" - + subclass = None superclass = None def __init__(self, Imported_Function=None): @@ -702,7 +701,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PEResourceType(GeneratedsSuper): """The PEResourceType type is intended as container for the properties relevant to PE binary resources.""" - + subclass = None superclass = None def __init__(self, Type=None, Name=None, Size=None, Virtual_Address=None, Language=None, Sub_Language=None, Hashes=None, Data=None, extensiontype_=None): @@ -853,7 +852,7 @@ class PEVersionInfoResourceType(PEResourceType): resource type. For more information please see: http://msdn.microsoft.com/en- us/library/windows/desktop/aa381058(v=vs.85).aspx""" - + subclass = None superclass = PEResourceType def __init__(self, Type=None, Name=None, Hashes=None, Comments=None, CompanyName=None, FileDescription=None, FileVersion=None, InternalName=None, LangID=None, LegalCopyright=None, LegalTrademarks=None, OriginalFilename=None, PrivateBuild=None, ProductName=None, ProductVersion=None, SpecialBuild=None): @@ -1042,7 +1041,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PEExportedFunctionType(GeneratedsSuper): """PEExportType sepcifies the type describing exported functions.""" - + subclass = None superclass = None def __init__(self, Function_Name=None, Entry_Point=None, Ordinal=None): @@ -1134,7 +1133,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PEResourceListType(GeneratedsSuper): """PEResourceListType specifies a list of resources found in the PE file.""" - + subclass = None superclass = None def __init__(self, Resource=None): @@ -1209,7 +1208,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PEImportedFunctionType(GeneratedsSuper): """PEImportedFunctionType specifies the type describing imported functions.""" - + subclass = None superclass = None def __init__(self, Function_Name=None, Hint=None, Ordinal=None, Bound=None, Virtual_Address=None): @@ -1321,7 +1320,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PEImportListType(GeneratedsSuper): """PEImportListType specifies a list of functions in an import data section.""" - + subclass = None superclass = None def __init__(self, Import=None): @@ -1392,7 +1391,7 @@ class PESectionType(GeneratedsSuper): header and data. The PESectionType contains properties that describe the Section Header and metadata computed about the section (e.g., hashes, entropy).""" - + subclass = None superclass = None def __init__(self, Section_Header=None, Data_Hashes=None, Entropy=None, Header_Hashes=None): @@ -1488,7 +1487,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PEDataDirectoryStructType(GeneratedsSuper): """The PEDataDirectoryStruct type is intended as container for the properties relevant to a PE binary's data directory structure.""" - + subclass = None superclass = None def __init__(self, Virtual_Address=None, Size=None): @@ -1567,7 +1566,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PESectionHeaderStructType(GeneratedsSuper): """The PESectionHeaderStruct type is intended as container for the properties relevant to a PE binary's section header structure.""" - + subclass = None superclass = None def __init__(self, Name=None, Virtual_Size=None, Virtual_Address=None, Size_Of_Raw_Data=None, Pointer_To_Raw_Data=None, Pointer_To_Relocations=None, Pointer_To_Linenumbers=None, Number_Of_Relocations=None, Number_Of_Linenumbers=None, Characteristics=None): @@ -1733,7 +1732,7 @@ class DOSHeaderType(GeneratedsSuper): /doc/pefile.html for more information about the winnt.h file, and http://www.tavi.co.uk/phobos/exeformat.html for even more clarification.""" - + subclass = None superclass = None def __init__(self, e_magic=None, e_cblp=None, e_cp=None, e_crlc=None, e_cparhdr=None, e_minalloc=None, e_maxalloc=None, e_ss=None, e_sp=None, e_csum=None, e_ip=None, e_cs=None, e_lfarlc=None, e_ovro=None, reserved1=None, e_oemid=None, e_oeminfo=None, reserved2=None, e_lfanew=None, Hashes=None): @@ -1993,7 +1992,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PEHeadersType(GeneratedsSuper): """PEHeaderType specifies the headers found in PE and COFF files.""" - + subclass = None superclass = None def __init__(self, DOS_Header=None, Signature=None, File_Header=None, Optional_Header=None, Entropy=None, Hashes=None): @@ -2110,7 +2109,7 @@ class PEFileHeaderType(GeneratedsSuper): """The PEFileHeaderType type refers to the PE file header (somtimes referred to as the COFF header) and its associated characteristics.""" - + subclass = None superclass = None def __init__(self, Machine=None, Number_Of_Sections=None, Time_Date_Stamp=None, Pointer_To_Symbol_Table=None, Number_Of_Symbols=None, Size_Of_Optional_Header=None, Characteristics=None, Hashes=None): @@ -2250,7 +2249,7 @@ class PEOptionalHeaderType(GeneratedsSuper): """The PEOptionalHeaderType type describes the PE Optional Header structure. Additional computed metadata, e.g., hashes of the header, are also included.""" - + subclass = None superclass = None def __init__(self, Magic=None, Major_Linker_Version=None, Minor_Linker_Version=None, Size_Of_Code=None, Size_Of_Initialized_Data=None, Size_Of_Uninitialized_Data=None, Address_Of_Entry_Point=None, Base_Of_Code=None, Base_Of_Data=None, Image_Base=None, Section_Alignment=None, File_Alignment=None, Major_OS_Version=None, Minor_OS_Version=None, Major_Image_Version=None, Minor_Image_Version=None, Major_Subsystem_Version=None, Minor_Subsystem_Version=None, Win32_Version_Value=None, Size_Of_Image=None, Size_Of_Headers=None, Checksum=None, Subsystem=None, DLL_Characteristics=None, Size_Of_Stack_Reserve=None, Size_Of_Stack_Commit=None, Size_Of_Heap_Reserve=None, Size_Of_Heap_Commit=None, Loader_Flags=None, Number_Of_Rva_And_Sizes=None, Data_Directory=None, Hashes=None): @@ -2628,7 +2627,7 @@ class DataDirectoryType(GeneratedsSuper): in the PE file's optional header. The data directories, except the Certificate Table, are loaded into memory so they can be used at runtime.""" - + subclass = None superclass = None def __init__(self, Export_Table=None, Import_Table=None, Resource_Table=None, Exception_Table=None, Certificate_Table=None, Base_Relocation_Table=None, Debug=None, Architecture=None, Global_Ptr=None, TLS_Table=None, Load_Config_Table=None, Bound_Import=None, Import_Address_Table=None, Delay_Import_Descriptor=None, CLR_Runtime_Header=None, Reserved=None): @@ -2841,7 +2840,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class PEBuildInformationType(GeneratedsSuper): """The PEBuildInformationType captures information about the tools used to build the PE binary, including the compiler and linker.""" - + subclass = None superclass = None def __init__(self, Linker_Name=None, Linker_Version=None, Compiler_Name=None, Compiler_Version=None): @@ -2943,7 +2942,7 @@ class PEType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -3016,7 +3015,7 @@ class SubsystemType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -3085,7 +3084,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsExecutableFileObjectType(win_file_object.WindowsFileObjectType): """The WindowsExecutableFileObjectType type is intended to characterize Windows PE (Portable Executable) files.""" - + subclass = None superclass = win_file_object.WindowsFileObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_packed=None, File_Name=None, File_Path=None, Device_Path=None, Full_Path=None, File_Extension=None, Size_In_Bytes=None, Magic_Number=None, File_Format=None, Hashes=None, Digital_Signatures=None, Modified_Time=None, Accessed_Time=None, Created_Time=None, File_Attributes_List=None, Permissions=None, User_Owner=None, Packer_List=None, Peak_Entropy=None, Sym_Links=None, Byte_Runs=None, Extracted_Features=None, Filename_Accessed_Time=None, Filename_Created_Time=None, Filename_Modified_Time=None, Drive=None, Security_ID=None, Security_Type=None, Stream_List=None, Build_Information=None, Digital_Signature=None, Exports=None, Extraneous_Bytes=None, Headers=None, Imports=None, PE_Checksum=None, Resources=None, Sections=None, Type=None): @@ -3470,7 +3469,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -3516,7 +3515,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_file_object.py b/cybox/bindings/win_file_object.py index 44f54832..c7eec32e 100644 --- a/cybox/bindings/win_file_object.py +++ b/cybox/bindings/win_file_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import file_object +from . import cybox_common +from . import file_object class StreamListType(GeneratedsSuper): """The StreamListType type specifies a list of NTFS alternate data streams.""" - + subclass = None superclass = None def __init__(self, Stream=None): @@ -81,7 +80,7 @@ class WindowsFilePermissionsType(file_object.FilePermissionsType): """The WindowsFilePermissionsType type specifies Windows file permissions. It imports and extends the file_object.FilePermissionsType from the CybOX File Object.""" - + subclass = None superclass = file_object.FilePermissionsType def __init__(self, Full_Control=None, Modify=None, Read=None, Read_And_Execute=None, Write=None): @@ -227,7 +226,7 @@ class WindowsFileAttributeType(cybox_common.BaseObjectPropertyType): for permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -297,7 +296,7 @@ class WindowsFileAttributesType(file_object.FileAttributeType): """The WindowsFileAttributesType type specifies Windows file attributes. It imports and extends the file_object.FileAttributeType from the CybOX File Object.""" - + subclass = None superclass = file_object.FileAttributeType def __init__(self, Attribute=None): @@ -372,7 +371,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class StreamObjectType(cybox_common.HashListType): """The StreamObjectType type is intended to characterize NTFS alternate data streams.""" - + subclass = None superclass = cybox_common.HashListType def __init__(self, Hash=None, Name=None, Size_In_Bytes=None): @@ -455,7 +454,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsFileObjectType(file_object.FileObjectType): """The WindowsFileObjectType type is intended to characterize Windows files.""" - + subclass = None superclass = file_object.FileObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_packed=None, File_Name=None, File_Path=None, Device_Path=None, Full_Path=None, File_Extension=None, Size_In_Bytes=None, Magic_Number=None, File_Format=None, Hashes=None, Digital_Signatures=None, Modified_Time=None, Accessed_Time=None, Created_Time=None, File_Attributes_List=None, Permissions=None, User_Owner=None, Packer_List=None, Peak_Entropy=None, Sym_Links=None, Byte_Runs=None, Extracted_Features=None, Filename_Accessed_Time=None, Filename_Created_Time=None, Filename_Modified_Time=None, Drive=None, Security_ID=None, Security_Type=None, Stream_List=None): @@ -723,7 +722,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -769,7 +768,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_filemapping_object.py b/cybox/bindings/win_filemapping_object.py index 1ac6e6ce..4bf1cca7 100644 --- a/cybox/bindings/win_filemapping_object.py +++ b/cybox/bindings/win_filemapping_object.py @@ -4,9 +4,8 @@ import sys from cybox.bindings import * -import cybox_common - -import win_handle_object +from . import cybox_common +from . import win_handle_object class PageProtectionAttributeType(cybox_common.BaseObjectPropertyType): @@ -16,7 +15,7 @@ class PageProtectionAttributeType(cybox_common.BaseObjectPropertyType): type. Its base type is the CybOX Core cybox_common.BaseObjectPropertyType, for permitting complex (i.e. regular-expression based) specifications.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -407,7 +406,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -453,7 +452,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_handle_object.py b/cybox/bindings/win_handle_object.py index 9831b394..94099e8c 100644 --- a/cybox/bindings/win_handle_object.py +++ b/cybox/bindings/win_handle_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class WindowsHandleListType(GeneratedsSuper): """The WindowsHandleListType type specifies a list of Windows handles, for re-use in other objects.""" - + subclass = None superclass = None def __init__(self, Handle=None): @@ -82,7 +82,7 @@ class HandleType(cybox_common.BaseObjectPropertyType): (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -151,7 +151,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsHandleObjectType(cybox_common.ObjectPropertiesType): """The WindowsHandleObjectType type is intended to characterize Windows handles.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, ID=None, Name=None, Type=None, Object_Address=None, Access_Mask=None, Pointer_Count=None): @@ -379,7 +379,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -425,7 +425,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_hook_object.py b/cybox/bindings/win_hook_object.py index 4e15170d..0e4608c0 100644 --- a/cybox/bindings/win_hook_object.py +++ b/cybox/bindings/win_hook_object.py @@ -4,10 +4,9 @@ import sys from cybox.bindings import * -import cybox_common - -import library_object -import win_handle_object +from . import cybox_common +from . import library_object +from . import win_handle_object class WinHookType(cybox_common.BaseObjectPropertyType): @@ -312,7 +311,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -358,7 +357,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_kernel_hook_object.py b/cybox/bindings/win_kernel_hook_object.py index 9326392d..b7f143ae 100644 --- a/cybox/bindings/win_kernel_hook_object.py +++ b/cybox/bindings/win_kernel_hook_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class KernelHookType(cybox_common.BaseObjectPropertyType): @@ -14,7 +14,7 @@ class KernelHookType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -83,7 +83,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsKernelHookObjectType(cybox_common.ObjectPropertiesType): """The WindowsKernelHookObjectType type is intended to characterize Windows kernel function hooks.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Digital_Signature_Hooking=None, Digital_Signature_Hooked=None, Hooking_Address=None, Hook_Description=None, Hooked_Function=None, Hooked_Module=None, Hooking_Module=None, Type=None): @@ -331,7 +331,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -377,7 +377,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_kernel_object.py b/cybox/bindings/win_kernel_object.py index 9b2dcfd4..e2c61611 100644 --- a/cybox/bindings/win_kernel_object.py +++ b/cybox/bindings/win_kernel_object.py @@ -4,13 +4,13 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class SSDTEntryListType(GeneratedsSuper): """The SSDTEntryListType type specifies a listing of the entries in the System Service Descriptor Table (SSDT).""" - + subclass = None superclass = None def __init__(self, SSDT_Entry=None): @@ -79,7 +79,7 @@ class SSDTEntryType(GeneratedsSuper): """The SSDTEntryType type specifies a single entry in the System Service Descriptor Table (SSDT).The hooked attribute specifies whether the SSDT entry is hooked.""" - + subclass = None superclass = None def __init__(self, hooked=None, Service_Table_Base=None, Service_Counter_Table_Base=None, Number_Of_Services=None, Argument_Table_Base=None): @@ -194,7 +194,7 @@ class IDTEntryListType(GeneratedsSuper): I386 architecture, indicating where the Prtoetcted mode Interrupt Service Routines (ISR) are located. See http://wiki.osdev.org/Interrupt_Descriptor_Table""" - + subclass = None superclass = None def __init__(self, IDT_Entry=None): @@ -263,7 +263,7 @@ class IDTEntryType(GeneratedsSuper): """The IDTEntryType type specifies a single entry in the Interrupt Descriptor Table (IDT). Entries can be interrupt gates, task gates, and trap gates.""" - + subclass = None superclass = None def __init__(self, Type_Attr=None, Offset_High=None, Offset_Low=None, Offset_Middle=None, Selector=None): @@ -369,7 +369,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsKernelObjectType(cybox_common.ObjectPropertiesType): """The WindowsKernelObjectType type is intended to characterize Windows Kernel structures.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, IDT=None, SSDT=None): @@ -550,7 +550,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -596,7 +596,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_mailslot_object.py b/cybox/bindings/win_mailslot_object.py index 35de9c33..c061f1db 100644 --- a/cybox/bindings/win_mailslot_object.py +++ b/cybox/bindings/win_mailslot_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import win_handle_object +from . import cybox_common +from . import win_handle_object class WindowsMailslotObjectType(cybox_common.ObjectPropertiesType): """The WindowsMailslotObjectType is intended to characterize Windows mailslot objects.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Handle=None, Max_Message_Size=None, Name=None, Read_Timeout=None, Security_Attributes=None): @@ -229,7 +228,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -275,7 +274,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_memory_page_region_object.py b/cybox/bindings/win_memory_page_region_object.py index 22b572f9..2df0674f 100644 --- a/cybox/bindings/win_memory_page_region_object.py +++ b/cybox/bindings/win_memory_page_region_object.py @@ -4,9 +4,8 @@ import sys from cybox.bindings import * -import cybox_common - -import memory_object +from . import cybox_common +from . import memory_object class MemoryPageTypeType(cybox_common.BaseObjectPropertyType): @@ -16,7 +15,7 @@ class MemoryPageTypeType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -89,7 +88,7 @@ class MemoryPageStateType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -163,7 +162,7 @@ class MemoryPageProtectionType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -232,7 +231,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsMemoryPageRegionObjectType(memory_object.MemoryObjectType): """The WindowsMemoryPageRegionObjectType type is intended to characterize Windows memory page regions.""" - + subclass = None superclass = memory_object.MemoryObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_protected=None, is_injected=None, is_mapped=None, Hashes=None, Name=None, Region_Size=None, Region_Start_Address=None, Extracted_Features=None, Type=None, Allocation_Base_Address=None, Allocation_Protect=None, State=None, Protect=None): @@ -451,7 +450,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -497,7 +496,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_mutex_object.py b/cybox/bindings/win_mutex_object.py index e3544a92..6cf90244 100644 --- a/cybox/bindings/win_mutex_object.py +++ b/cybox/bindings/win_mutex_object.py @@ -4,16 +4,15 @@ import sys from cybox.bindings import * -import cybox_common - -import mutex_object -import win_handle_object +from . import cybox_common +from . import mutex_object +from . import win_handle_object class WindowsMutexObjectType(mutex_object.MutexObjectType): """The WindowsMutexObjectType type is intended to characterize Windows mutual exclusion (mutex) objects.""" - + subclass = None superclass = mutex_object.MutexObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, named=None, Name=None, Handle=None, Security_Attributes=None): @@ -196,7 +195,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -242,7 +241,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_network_route_entry_object.py b/cybox/bindings/win_network_route_entry_object.py index a3eabc7b..39c2ff03 100644 --- a/cybox/bindings/win_network_route_entry_object.py +++ b/cybox/bindings/win_network_route_entry_object.py @@ -4,10 +4,9 @@ import sys from cybox.bindings import * -import cybox_common - -import address_object -import network_route_entry_object +from . import cybox_common +from . import address_object +from . import network_route_entry_object class NLRouteProtocolType(cybox_common.BaseObjectPropertyType): @@ -18,7 +17,7 @@ class NLRouteProtocolType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -92,7 +91,7 @@ class NLRouteOriginType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -161,7 +160,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsNetworkRouteEntryObjectType(network_route_entry_object.NetworkRouteEntryObjectType): """The WindowsNetworkRouteEntryObjectType type is intended to characterize Windows network routing table entries.""" - + subclass = None superclass = network_route_entry_object.NetworkRouteEntryObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_publish=None, is_autoconfigure_address=None, is_loopback=None, is_immortal=None, is_ipv6=None, Destination_Address=None, Origin=None, Netmask=None, Gateway_Address=None, Metric=None, Type=None, Protocol=None, Interface=None, Preferred_Lifetime=None, Valid_Lifetime=None, Route_Age=None, NL_ROUTE_PROTOCOL=None, NL_ROUTE_ORIGIN=None): @@ -353,7 +352,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -399,7 +398,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_network_share_object.py b/cybox/bindings/win_network_share_object.py index cfd65f9a..c01dc138 100644 --- a/cybox/bindings/win_network_share_object.py +++ b/cybox/bindings/win_network_share_object.py @@ -4,7 +4,7 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class SharedResourceType(cybox_common.BaseObjectPropertyType): @@ -419,7 +419,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -465,7 +465,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_pipe_object.py b/cybox/bindings/win_pipe_object.py index bb5e7c54..80e51d15 100644 --- a/cybox/bindings/win_pipe_object.py +++ b/cybox/bindings/win_pipe_object.py @@ -4,16 +4,15 @@ import sys from cybox.bindings import * -import cybox_common - -import pipe_object -import win_handle_object +from . import cybox_common +from . import pipe_object +from . import win_handle_object class WindowsPipeObjectType(pipe_object.PipeObjectType): """The WindowsPipeObjectType type is intended to characterize Windows pipes.""" - + subclass = None superclass = pipe_object.PipeObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, named=None, Name=None, Default_Time_Out=None, Handle=None, In_Buffer_Size=None, Max_Instances=None, Open_Mode=None, Out_Buffer_Size=None, Pipe_Mode=None, Security_Attributes=None): @@ -268,7 +267,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -314,7 +313,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_prefetch_object.py b/cybox/bindings/win_prefetch_object.py index 3f3dcf9f..a36a9fd6 100644 --- a/cybox/bindings/win_prefetch_object.py +++ b/cybox/bindings/win_prefetch_object.py @@ -4,16 +4,15 @@ import sys from cybox.bindings import * -import cybox_common - -import device_object -import win_volume_object +from . import cybox_common +from . import device_object +from . import win_volume_object class AccessedFileListType(GeneratedsSuper): """The AccessedFileListType specifies a list of files accessed by a prefetch application.""" - + subclass = None superclass = None def __init__(self, Accessed_Filename=None): @@ -84,7 +83,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class AccessedDirectoryListType(GeneratedsSuper): """The AccessedDirectoryListType specifies a list of directories accessed by a prefetch application.""" - + subclass = None superclass = None def __init__(self, Accessed_Directory=None): @@ -155,7 +154,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class VolumeType(GeneratedsSuper): """VolumeType characterizes the volume information in the Windows prefetch file.""" - + subclass = None superclass = None def __init__(self, VolumeItem=None, DeviceItem=None): @@ -241,7 +240,7 @@ class WindowsPrefetchObjectType(cybox_common.ObjectPropertiesType): prefetching was introduced to speed up application startup. The prefetch object draws upon the descriptions and XML sample at http://www.forensicswiki.org/wiki/Prefetch_XML""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Application_File_Name=None, Prefetch_Hash=None, Times_Executed=None, First_Run=None, Last_Run=None, Volume=None, Accessed_File_List=None, Accessed_Directory_List=None): @@ -508,7 +507,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -554,7 +553,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_process_object.py b/cybox/bindings/win_process_object.py index d6746a23..0092eb70 100644 --- a/cybox/bindings/win_process_object.py +++ b/cybox/bindings/win_process_object.py @@ -4,18 +4,17 @@ import sys from cybox.bindings import * -import cybox_common - -import memory_object -import process_object -import win_handle_object -import win_thread_object +from . import cybox_common +from . import memory_object +from . import process_object +from . import win_handle_object +from . import win_thread_object class MemorySectionListType(GeneratedsSuper): """The MemorySectionListType type specifies a list of memory sections used by the process.""" - + subclass = None superclass = None def __init__(self, Memory_Section=None): @@ -83,7 +82,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class StartupInfoType(GeneratedsSuper): """The StartupInfoType type encapsulates the information contained in the STARTUPINFO struct for the process.""" - + subclass = None superclass = None def __init__(self, lpDesktop=None, lpTitle=None, dwX=None, dwY=None, dwXSize=None, dwYSize=None, dwXCountChars=None, dwYCountChars=None, dwFillAttribute=None, dwFlags=None, wShowWindow=None, hStdInput=None, hStdOutput=None, hStdError=None): @@ -288,7 +287,7 @@ class WindowsProcessObjectType(process_object.ProcessObjectType): Address Space Layout Randomization (ASLR) is enabled for the process.The dep_enabled field specifies whether Data Execution Prevention (DEP) is enabled for the process.""" - + subclass = None superclass = process_object.ProcessObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_hidden=None, PID=None, Name=None, Creation_Time=None, Parent_PID=None, Child_PID_List=None, Image_Info=None, Argument_List=None, Environment_Variable_List=None, Kernel_Time=None, Port_List=None, Network_Connection_List=None, Start_Time=None, Status=None, Username=None, User_Time=None, Extracted_Features=None, aslr_enabled=None, dep_enabled=None, Handle_List=None, Priority=None, Section_List=None, Security_ID=None, Startup_Info=None, Security_Type=None, Window_Title=None, Thread=None): @@ -305,7 +304,7 @@ def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, if not Thread: self.Thread = [] else: - self.Thread = Thread + self.Thread = Thread def factory(*args_, **kwargs_): if WindowsProcessObjectType.subclass: return WindowsProcessObjectType.subclass(*args_, **kwargs_) @@ -686,7 +685,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -732,7 +731,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_registry_key_object.py b/cybox/bindings/win_registry_key_object.py index e2e04c66..e98f733b 100644 --- a/cybox/bindings/win_registry_key_object.py +++ b/cybox/bindings/win_registry_key_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import win_handle_object +from . import cybox_common +from . import win_handle_object class RegistryValueType(GeneratedsSuper): """The RegistryValueType type is intended to characterize Windows registry Value name/data pairs.""" - + subclass = None superclass = None def __init__(self, Name=None, Data=None, Datatype=None, Byte_Runs=None): @@ -111,7 +110,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class RegistryValuesType(GeneratedsSuper): """The RegistryValuesType type specifies the values (with their name/data pairs) held within the registry key.""" - + subclass = None superclass = None def __init__(self, Value=None): @@ -179,7 +178,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class RegistrySubkeysType(GeneratedsSuper): """The RegistrySubkeysType specifies the set of subkeys contained under the registry key.""" - + subclass = None superclass = None def __init__(self, Subkey=None): @@ -251,7 +250,7 @@ class RegistryHiveType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -324,7 +323,7 @@ class RegistryDatatypeType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -393,7 +392,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsRegistryKeyObjectType(cybox_common.ObjectPropertiesType): """The WindowsRegistryObjectType type is intended to characterize Windows registry objects, including Keys and Key/Value pairs.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Key=None, Hive=None, Number_Values=None, Values=None, Modified_Time=None, Creator_Username=None, Handle_List=None, Number_Subkeys=None, Subkeys=None, Byte_Runs=None): @@ -671,7 +670,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -717,7 +716,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_semaphore_object.py b/cybox/bindings/win_semaphore_object.py index 1bfccb55..abaa4f13 100644 --- a/cybox/bindings/win_semaphore_object.py +++ b/cybox/bindings/win_semaphore_object.py @@ -4,16 +4,15 @@ import sys from cybox.bindings import * -import cybox_common - -import semaphore_object -import win_handle_object +from . import cybox_common +from . import semaphore_object +from . import win_handle_object class WindowsSemaphoreObjectType(semaphore_object.SemaphoreObjectType): """The WindowsSemaphoreObjectType is intended to characterize Windows semaphore (synchronization) objects.""" - + subclass = None superclass = semaphore_object.SemaphoreObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, named=None, Current_Count=None, Maximum_Count=None, Name=None, Handle=None, Security_Attributes=None): @@ -198,7 +197,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -244,7 +243,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_service_object.py b/cybox/bindings/win_service_object.py index 2f94caf2..d9101c4c 100644 --- a/cybox/bindings/win_service_object.py +++ b/cybox/bindings/win_service_object.py @@ -4,14 +4,13 @@ import sys from cybox.bindings import * -import cybox_common - -import win_process_object +from . import cybox_common +from . import win_process_object class ServiceDescriptionListType(GeneratedsSuper): """A collection of service descriptions.""" - + subclass = None superclass = None def __init__(self, Description=None): @@ -86,7 +85,7 @@ class ServiceType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -159,7 +158,7 @@ class ServiceStatusType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -232,7 +231,7 @@ class ServiceModeType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -303,7 +302,7 @@ class WindowsServiceObjectType(win_process_object.WindowsProcessObjectType): Windows services.Indicates whether or not the DLL is signed.Indicates whether or not the DLL's signature was verified.""" - + subclass = None superclass = win_process_object.WindowsProcessObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_hidden=None, PID=None, Name=None, Creation_Time=None, Parent_PID=None, Child_PID_List=None, Image_Info=None, Argument_List=None, Environment_Variable_List=None, Kernel_Time=None, Port_List=None, Network_Connection_List=None, Start_Time=None, Status=None, Username=None, User_Time=None, Extracted_Features=None, aslr_enabled=None, dep_enabled=None, Handle_List=None, Priority=None, Section_List=None, Security_ID=None, Startup_Info=None, Security_Type=None, Window_Title=None, service_dll_signature_verified=None, service_dll_signature_exists=None, Description_List=None, Display_Name=None, Group_Name=None, Service_Name=None, Service_DLL=None, Service_DLL_Certificate_Issuer=None, Service_DLL_Certificate_Subject=None, Service_DLL_Hashes=None, Service_DLL_Signature_Description=None, Startup_Command_Line=None, Startup_Type=None, Service_Status=None, Service_Type=None, Started_As=None): @@ -760,7 +759,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -806,7 +805,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_system_object.py b/cybox/bindings/win_system_object.py index fc06a391..03117134 100644 --- a/cybox/bindings/win_system_object.py +++ b/cybox/bindings/win_system_object.py @@ -4,16 +4,15 @@ import sys from cybox.bindings import * -import cybox_common - -import system_object -import win_handle_object +from . import cybox_common +from . import system_object +from . import win_handle_object class GlobalFlagListType(GeneratedsSuper): """The GlobalFlagListType type is a listing of all Windows global flags.""" - + subclass = None superclass = None def __init__(self, Global_Flag=None): @@ -81,7 +80,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class GlobalFlagType(GeneratedsSuper): """The GlobalFlagType type is intended to characterize Windows global flags.""" - + subclass = None superclass = None def __init__(self, Abbreviation=None, Destination=None, Hexadecimal_Value=None, Symbolic_Name=None): @@ -180,7 +179,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsSystemObjectType(system_object.SystemObjectType): """The WindowsSystemObjectType type is intended to characterize Windows systems.""" - + subclass = None superclass = system_object.SystemObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Available_Physical_Memory=None, BIOS_Info=None, Date=None, Hostname=None, Local_Time=None, Network_Interface_List=None, OS=None, Processor=None, Processor_Architecture=None, System_Time=None, Timezone_DST=None, Timezone_Standard=None, Total_Physical_Memory=None, Uptime=None, Username=None, Domain=None, Global_Flag_List=None, NetBIOS_Name=None, Open_Handle_List=None, Product_ID=None, Product_Name=None, Registered_Organization=None, Registered_Owner=None, Windows_Directory=None, Windows_System_Directory=None, Windows_Temp_Directory=None): @@ -505,7 +504,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -551,7 +550,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_system_restore_object.py b/cybox/bindings/win_system_restore_object.py index e97dc7c3..46341cb7 100644 --- a/cybox/bindings/win_system_restore_object.py +++ b/cybox/bindings/win_system_restore_object.py @@ -4,11 +4,11 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class HiveListType(GeneratedsSuper): - + subclass = None superclass = None def __init__(self, Hive=None): @@ -83,7 +83,7 @@ class ChangeLogEntryTypeType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -152,7 +152,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsSystemRestoreObjectType(cybox_common.ObjectPropertiesType): """The WindowsSystemRestoreObjectType is intended to characterize Windows system restore points.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Restore_Point_Description=None, Restore_Point_Full_Path=None, Restore_Point_Name=None, Restore_Point_Type=None, ACL_Change_SID=None, ACL_Change_Username=None, Backup_File_Name=None, Change_Event=None, ChangeLog_Entry_Flags=None, ChangeLog_Entry_Sequence_Number=None, ChangeLog_Entry_Type=None, Change_Log_File_Name=None, Created=None, File_Attributes=None, New_File_Name=None, Original_File_Name=None, Original_Short_File_Name=None, Process_Name=None, Registry_Hive_List=None): @@ -523,7 +523,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -569,7 +569,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_task_object.py b/cybox/bindings/win_task_object.py index 05ee69f2..9dc621fc 100644 --- a/cybox/bindings/win_task_object.py +++ b/cybox/bindings/win_task_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import email_message_object +from . import cybox_common +from . import email_message_object class TriggerListType(GeneratedsSuper): """The TriggerListType type specifies a set of triggers associated with the scheduled task.""" - + subclass = None superclass = None def __init__(self, Trigger=None): @@ -82,7 +81,7 @@ class TriggerType(GeneratedsSuper): http://msdn.microsoft.com/en- us/library/windows/desktop/aa383868(v=vs.85).aspxThe enabled field specifies whether the trigger is enabled.""" - + subclass = None superclass = None def __init__(self, enabled=None, Trigger_Begin=None, Trigger_Delay=None, Trigger_End=None, Trigger_Frequency=None, Trigger_Max_Run_Time=None, Trigger_Session_Change_Type=None, Trigger_Type=None): @@ -229,7 +228,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class TaskActionListType(GeneratedsSuper): """The TaskActionListType type specifies a list of task actions.""" - + subclass = None superclass = None def __init__(self, Action=None): @@ -296,7 +295,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class TaskActionType(GeneratedsSuper): """The TaskActionType type characterizes scheduled task actions.""" - + subclass = None superclass = None def __init__(self, Action_Type=None, Action_ID=None, IEmailAction=None, IComHandlerAction=None, IExecAction=None, IShowMessageAction=None): @@ -414,7 +413,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IComHandlerActionType(GeneratedsSuper): """The IComHandlerActionType type characterizes IComHandler actions.""" - + subclass = None superclass = None def __init__(self, COM_Data=None, COM_Class_ID=None): @@ -489,7 +488,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IExecActionType(GeneratedsSuper): """The IExecActionType type characterizes IExec actions.""" - + subclass = None superclass = None def __init__(self, Exec_Arguments=None, Exec_Program_Path=None, Exec_Working_Directory=None, Exec_Program_Hashes=None): @@ -584,7 +583,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class IShowMessageActionType(GeneratedsSuper): """The IShowMessageActionType type characterizes IShowMessage actions.""" - + subclass = None superclass = None def __init__(self, Show_Message_Body=None, Show_Message_Title=None): @@ -664,7 +663,7 @@ class TaskStatusType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -738,7 +737,7 @@ class TaskTriggerType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -812,7 +811,7 @@ class TaskTriggerFrequencyType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -885,7 +884,7 @@ class TaskPriorityType(cybox_common.BaseObjectPropertyType): for permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -958,7 +957,7 @@ class TaskFlagType(cybox_common.BaseObjectPropertyType): complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -1028,7 +1027,7 @@ class TaskActionTypeType(cybox_common.BaseObjectPropertyType): """The TaskActionTypeType characterizes the specific types of task actions.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -1098,7 +1097,7 @@ class WindowsTaskObjectType(cybox_common.ObjectPropertiesType): """The WindowsTaskObjectType type is intended to characterize Windows task scheduler tasks. See Also: http://msdn.microsoft.com/en- us/library/windows/desktop/aa381311(v=vs.85).aspx""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Status=None, Priority=None, Name=None, Application_Name=None, Parameters=None, Flags=None, Account_Name=None, Account_Run_Level=None, Account_Logon_Type=None, Creator=None, Creation_Date=None, Most_Recent_Run_Time=None, Exit_Code=None, Max_Run_Time=None, Next_Run_Time=None, Action_List=None, Trigger_List=None, Comment=None, Working_Directory=None, Work_Item_Data=None): @@ -1523,7 +1522,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 'Fuzzy_Hash_Value': cybox_common.FuzzyHashValueType, 'Show_Message_Title': cybox_common.StringObjectPropertyType, 'Data_Size': cybox_common.DataSizeType, - 'Email_Message': email_message_object.EmailMessageObjectType, + 'email_message': email_message_object.EmailMessageObjectType, 'Dependency_Description': cybox_common.StructuredTextType, 'File': email_message_object.AttachmentReferenceType, 'Contributor': cybox_common.ContributorType, @@ -1536,7 +1535,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -1582,7 +1581,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_thread_object.py b/cybox/bindings/win_thread_object.py index 824d3a50..56f45812 100644 --- a/cybox/bindings/win_thread_object.py +++ b/cybox/bindings/win_thread_object.py @@ -4,9 +4,8 @@ import sys from cybox.bindings import * -import cybox_common - -import win_handle_object +from . import cybox_common +from . import win_handle_object class ThreadRunningStatusType(cybox_common.BaseObjectPropertyType): @@ -17,7 +16,7 @@ class ThreadRunningStatusType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -87,7 +86,7 @@ class WindowsThreadObjectType(cybox_common.ObjectPropertiesType): """The Windows_ThreadObjectType is intended to characterize Windows process threads. See also: http://msdn.microsoft.com/en- us/library/windows/desktop/ms684852(v=vs.85).aspx""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Thread_ID=None, Handle=None, Running_Status=None, Context=None, Priority=None, Creation_Flags=None, Creation_Time=None, Start_Address=None, Parameter_Address=None, Security_Attributes=None, Stack_Size=None): @@ -382,7 +381,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -428,7 +427,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_user_account_object.py b/cybox/bindings/win_user_account_object.py index 39dae10c..311b2f49 100644 --- a/cybox/bindings/win_user_account_object.py +++ b/cybox/bindings/win_user_account_object.py @@ -4,15 +4,14 @@ import sys from cybox.bindings import * -import cybox_common - -import user_account_object +from . import cybox_common +from . import user_account_object class WindowsPrivilegeType(user_account_object.PrivilegeType): """Windows Privilege represents a single privilege that a user may have within Windows.""" - + subclass = None superclass = user_account_object.PrivilegeType def __init__(self, User_Right=None): @@ -81,7 +80,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsGroupType(user_account_object.GroupType): """Windows Group represents a single windows group.""" - + subclass = None superclass = user_account_object.GroupType def __init__(self, Name=None): @@ -151,7 +150,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsUserAccountObjectType(user_account_object.UserAccountObjectType): """The WinUserAccountObjectType type is intended to characterize Windows user accounts.""" - + subclass = None superclass = user_account_object.UserAccountObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, disabled=None, locked_out=None, Description=None, Domain=None, password_required=None, Full_Name=None, Group_List=None, Home_Directory=None, Last_Login=None, Privilege_List=None, Script_Path=None, Username=None, User_Password_Age=None, Security_ID=None, Security_Type=None): @@ -344,7 +343,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -390,7 +389,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_volume_object.py b/cybox/bindings/win_volume_object.py index d9c65abc..81fc079b 100644 --- a/cybox/bindings/win_volume_object.py +++ b/cybox/bindings/win_volume_object.py @@ -4,14 +4,13 @@ import sys from cybox.bindings import * -import cybox_common - -import volume_object +from . import cybox_common +from . import volume_object class WindowsVolumeAttributesListType(GeneratedsSuper): """A list of attributes describing this windows volume.""" - + subclass = None superclass = None def __init__(self, Attribute=None): @@ -87,7 +86,7 @@ class WindowsVolumeAttributeType(cybox_common.BaseObjectPropertyType): expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -160,7 +159,7 @@ class WindowsDriveType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, pattern_type=None, datatype='string', refanging_transform=None, bit_mask=None, appears_random=None, trend=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -229,7 +228,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsVolumeObjectType(volume_object.VolumeObjectType): """The WindowsVolumeObjectType type is intended to characterize Windows disk volumes.""" - + subclass = None superclass = volume_object.VolumeObjectType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, is_mounted=None, Name=None, Device_Path=None, File_System_Type=None, Total_Allocation_Units=None, Sectors_Per_Allocation_Unit=None, Bytes_Per_Sector=None, Actual_Available_Allocation_Units=None, Creation_Time=None, File_System_Flag_List=None, Serial_Number=None, Attributes_List=None, Drive_Letter=None, Drive_Type=None): @@ -429,7 +428,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -475,7 +474,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_waitable_timer_object.py b/cybox/bindings/win_waitable_timer_object.py index 7f671df7..953412a1 100644 --- a/cybox/bindings/win_waitable_timer_object.py +++ b/cybox/bindings/win_waitable_timer_object.py @@ -4,9 +4,8 @@ import sys from cybox.bindings import * -import cybox_common - -import win_handle_object +from . import cybox_common +from . import win_handle_object class WaitableTimerType(cybox_common.BaseObjectPropertyType): @@ -16,7 +15,7 @@ class WaitableTimerType(cybox_common.BaseObjectPropertyType): permitting complex (i.e. regular-expression based) specifications.This attribute is optional and specifies the expected type for the value of the specified property.""" - + subclass = None superclass = cybox_common.BaseObjectPropertyType def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): @@ -85,7 +84,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class WindowsWaitableTimerObjectType(cybox_common.ObjectPropertiesType): """The WindowsWaitableTimerObjectType is intended to characterize Windows waitable timer (synchronization) objects.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Handle=None, Name=None, Security_Attributes=None, Type=None): @@ -290,7 +289,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -336,7 +335,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/x509_certificate_object.py b/cybox/bindings/x509_certificate_object.py index 0453d443..87dee5ba 100644 --- a/cybox/bindings/x509_certificate_object.py +++ b/cybox/bindings/x509_certificate_object.py @@ -4,14 +4,14 @@ import sys from cybox.bindings import * -import cybox_common +from . import cybox_common class X509CertificateContentsType(GeneratedsSuper): """The X509CertificateContentsType type represents the contents of an X.509 certificate, including items such as issuer, subject, and others.""" - + subclass = None superclass = None def __init__(self, Version=None, Serial_Number=None, Signature_Algorithm=None, Issuer=None, Validity=None, Subject=None, Subject_Public_Key=None, Standard_Extensions=None, Non_Standard_Extensions=None): @@ -160,7 +160,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class X509CertificateSignatureType(GeneratedsSuper): """The X509CertificateSignatureType contains the signature and signature algorithm of this X.509 certificate.""" - + subclass = None superclass = None def __init__(self, Signature_Algorithm=None, Signature=None): @@ -236,7 +236,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class SubjectPublicKeyType(GeneratedsSuper): """The SubjectPublicKeyType is used to carry the public key and identify the algorithm with which the key is used.""" - + subclass = None superclass = None def __init__(self, Public_Key_Algorithm=None, RSA_Public_Key=None): @@ -313,7 +313,7 @@ class ValidityType(GeneratedsSuper): """The ValidityType type is the time interval during which the issuer warrants that it will maintain information about the status of the certificate.""" - + subclass = None superclass = None def __init__(self, Not_Before=None, Not_After=None): @@ -388,7 +388,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class RSAPublicKeyType(GeneratedsSuper): """The RSAPublicKeyType captures details of RSA public keys.""" - + subclass = None superclass = None def __init__(self, Modulus=None, Exponent=None): @@ -468,7 +468,7 @@ class X509V3ExtensionsType(GeneratedsSuper): """The X509V3ExtensionsType captures the standard X509 V3 Extensions that may be used in X509 certificates. Based on RFC 3280, "Standard Extensions": http://www.ietf.org/rfc/rfc3280.txt""" - + subclass = None superclass = None def __init__(self, Basic_Constraints=None, Name_Constraints=None, Policy_Constraints=None, Key_Usage=None, Extended_Key_Usage=None, Subject_Key_Identifier=None, Authority_Key_Identifier=None, Subject_Alternative_Name=None, Issuer_Alternative_Name=None, Subject_Directory_Attributes=None, CRL_Distribution_Points=None, Inhibit_Any_Policy=None, Private_Key_Usage_Period=None, Certificate_Policies=None, Policy_Mappings=None): @@ -681,7 +681,7 @@ class X509NonStandardExtensionsType(GeneratedsSuper): sl.org/docs/apps/x509v3_config.html#Deprecated_Extensions. Also based on the Alvestrand certificateExtension reference: http://www.alvestrand.no/objectid/2.5.29.html""" - + subclass = None superclass = None def __init__(self, Netscape_Comment=None, Netscape_Certificate_Type=None, Old_Authority_Key_Identifier=None, Old_Primary_Key_Attributes=None): @@ -777,7 +777,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): class X509CertificateObjectType(cybox_common.ObjectPropertiesType): """The X509CertificateObjectType type is intended to characterize X.509 certificates.""" - + subclass = None superclass = cybox_common.ObjectPropertiesType def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Certificate=None, Raw_Certificate=None, Certificate_Signature=None): @@ -986,7 +986,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): """ def usage(): - print USAGE_TEXT + print(USAGE_TEXT) sys.exit(1) def get_root_tag(node): @@ -1032,7 +1032,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from StringIO import StringIO + from cybox.compat import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/common/hashes.py b/cybox/common/hashes.py index 4d72a15d..5fbbab81 100644 --- a/cybox/common/hashes.py +++ b/cybox/common/hashes.py @@ -2,6 +2,7 @@ # See LICENSE.txt for complete terms. import cybox +from cybox.compat import basestring import cybox.bindings.cybox_common as common_binding from cybox.common import vocabs, HexBinary, String, VocabString from cybox.common.vocabs import HashName diff --git a/cybox/common/properties.py b/cybox/common/properties.py index e1958c7e..b57454a8 100644 --- a/cybox/common/properties.py +++ b/cybox/common/properties.py @@ -6,6 +6,7 @@ import dateutil.parser import cybox +from cybox.compat import basestring import cybox.bindings.cybox_common as common_binding from cybox.common import PatternFieldGroup from cybox.utils import normalize_to_xml, denormalize_from_xml @@ -15,6 +16,7 @@ DATETIME_PRECISION_VALUES = DATE_PRECISION_VALUES + TIME_PRECISION_VALUES + class BaseProperty(PatternFieldGroup, cybox.Entity): # Most Properties are defined in the "common" binding, so we'll just set # that here. Some BaseProperty subclasses might have to override this. @@ -63,7 +65,7 @@ def value(self, value_): # static methods, or on an instance of the class after it has been # created. if isinstance(value_, list): - self._value = map(self._parse_value, value_) + self._value = list(map(self._parse_value, value_)) else: self._value = self._parse_value(value_) @@ -104,7 +106,7 @@ def _parse_value(value): @property def serialized_value(self): if isinstance(self.value, list): - return map(self._serialize_value, self.value) + return list(map(self._serialize_value, self.value)) else: return self.__class__._serialize_value(self.value) diff --git a/cybox/compat.py b/cybox/compat.py new file mode 100644 index 00000000..778fc37a --- /dev/null +++ b/cybox/compat.py @@ -0,0 +1,23 @@ +import sys + +# Syntax sugar. +_ver = sys.version_info + +#: Python 2.x? +is_py2 = (_ver[0] == 2) + +#: Python 3.x? +is_py3 = (_ver[0] == 3) + + +if is_py2: + from StringIO import StringIO + basestring = basestring + bytes = str + str = unicode + +elif is_py3: + from io import StringIO + basestring = (str, bytes) + bytes = bytes + str = str diff --git a/cybox/objects/artifact_object.py b/cybox/objects/artifact_object.py index 5f9d5591..011d7aab 100644 --- a/cybox/objects/artifact_object.py +++ b/cybox/objects/artifact_object.py @@ -323,7 +323,7 @@ def __init__(self, key): def unpack(self, packed_data): from zipfile import ZipFile - from StringIO import StringIO + from cybox.compat import StringIO buf = StringIO(packed_data) with ZipFile(buf, 'r') as myzip: diff --git a/cybox/test/__init__.py b/cybox/test/__init__.py index 4c2fab1b..3a88460c 100644 --- a/cybox/test/__init__.py +++ b/cybox/test/__init__.py @@ -4,6 +4,8 @@ import json import unittest +from cybox.compat import str + import cybox.bindings as bindings from cybox import Entity, EntityList, TypedField import cybox.bindings.cybox_core as core_binding @@ -52,8 +54,8 @@ def round_trip(o, output=False, list_=False): klass = o.__class__ if output: - print "Class: ", klass - print "-" * 40 + print("Class: ", klass) + print("-" * 40) # 1. cybox.Entity -> dict/list if list_: @@ -66,7 +68,7 @@ def round_trip(o, output=False, list_=False): if output: print(json_string) - print "-" * 40 + print("-" * 40) # Before parsing the JSON, make sure the cache is clear cybox.utils.cache_clear() @@ -86,12 +88,12 @@ def round_trip(o, output=False, list_=False): # 6. Bindings Object -> XML String xml_string = o2.to_xml(encoding=bindings.ExternalEncoding) - if not isinstance(xml_string, unicode): + if not isinstance(xml_string, str): xml_string = xml_string.decode(bindings.ExternalEncoding) if output: print(xml_string) - print "-" * 40 + print("-" * 40) # Before parsing the XML, make sure the cache is clear cybox.utils.cache_clear() diff --git a/cybox/test/common/hash_test.py b/cybox/test/common/hash_test.py index 273ff806..4cffb426 100644 --- a/cybox/test/common/hash_test.py +++ b/cybox/test/common/hash_test.py @@ -172,10 +172,10 @@ def test_namespace_count(self): h.append(EMPTY_SHA256) h.append(EMPTY_SHA384) h.append(EMPTY_SHA512) - print h.to_xml() + print(h.to_xml()) ns_list = cybox.test.round_trip(h, list_=True)._get_namespaces() - print ns_list + print(ns_list) # Only "common" and "vocabs" should be here. "xsi" is only added later self.assertEqual(2, len(ns_list)) diff --git a/cybox/test/core/object_test.py b/cybox/test/core/object_test.py index 88e5511c..da86983f 100644 --- a/cybox/test/core/object_test.py +++ b/cybox/test/core/object_test.py @@ -150,7 +150,7 @@ def test_relationship_vocabnameref(self): def _test_round_trip(self, observables): self.maxDiff = None - print observables.to_xml() + print(observables.to_xml()) observables2 = round_trip(observables) self.assertEqual(observables.to_dict(), observables2.to_dict()) diff --git a/cybox/test/core/observable_test.py b/cybox/test/core/observable_test.py index c77373d8..42695365 100644 --- a/cybox/test/core/observable_test.py +++ b/cybox/test/core/observable_test.py @@ -42,7 +42,7 @@ def test_keywords(self): self.assertTrue("eyword" not in o.to_xml()) o.add_keyword("Foo") - print o.to_xml() + print(o.to_xml()) self.assertTrue("Foo" in o.to_xml()) o2 = round_trip(o) diff --git a/cybox/test/dev.py b/cybox/test/dev.py index 8e7e15e2..b0bb1236 100755 --- a/cybox/test/dev.py +++ b/cybox/test/dev.py @@ -20,13 +20,13 @@ def main(): subs = list(subclasses(cybox.Entity)) -# print "\n".join([str(x) for x in subs]) -# print len(subs) +# print("\n".join([str(x) for x in subs])) +# print(len(subs)) no_namespace = [x for x in subs if not filter_has_namespace(x)] for x in no_namespace: - print x - print len(no_namespace) + print(x) + print(len(no_namespace)) def filter_has_namespace(cls): diff --git a/cybox/test/objects/email_message_test.py b/cybox/test/objects/email_message_test.py index d65610c9..f03f1570 100644 --- a/cybox/test/objects/email_message_test.py +++ b/cybox/test/objects/email_message_test.py @@ -299,10 +299,10 @@ def test_get_namespaces(self): m.links.append(u.parent.id_) o = Observables([u, m]) - print o.to_xml() + print(o.to_xml()) actual_namespaces = o._get_namespaces() - print "\n".join([str(x) for x in actual_namespaces]) + print("\n".join([str(x) for x in actual_namespaces])) self.assertEqual(5, len(actual_namespaces)) diff --git a/cybox/utils/__init__.py b/cybox/utils/__init__.py index 59bd763d..2bcc7dec 100644 --- a/cybox/utils/__init__.py +++ b/cybox/utils/__init__.py @@ -5,11 +5,14 @@ #importlib is imported below import os +import xml.sax.saxutils from .caches import * from .idgen import * from .nsparser import * +from cybox.compat import str + def get_class_for_object_type(object_type): return META.get_class_for_object_type(object_type) @@ -34,12 +37,12 @@ def normalize_to_xml(value, delimiter): raise ValueError("delimiter must not be None") if isinstance(value, list): - normalized_list = [unicode(x) for x in value] + normalized_list = [str(x) for x in value] if any(delimiter in x for x in normalized_list): raise ValueError("list items cannot contain delimiter") normalized = delimiter.join(normalized_list) else: - normalized = unicode(value) + normalized = str(value) if delimiter in normalized: raise ValueError("value cannot contain delimiter") diff --git a/cybox/utils/normalize.py b/cybox/utils/normalize.py index 9142c4f8..55936dcb 100644 --- a/cybox/utils/normalize.py +++ b/cybox/utils/normalize.py @@ -15,47 +15,47 @@ # Windows-specific file normalization mappings # Replace with CSIDL values, if possible # As a backup, replace with Windows environment variable values -file_path_normalization_mapping = [{'regex' : re.compile('%system%',flags=re.IGNORECASE), +file_path_normalization_mapping = [{'regex' : re.compile('%system%',flags=re.IGNORECASE), 'replacement' : 'CSIDL_SYSTEM'}, - {'regex' : re.compile('%appdata%',flags=re.IGNORECASE), + {'regex' : re.compile('%appdata%',flags=re.IGNORECASE), 'replacement' : 'CSIDL_APPDATA'}, - {'regex' : re.compile('%commonappdata%',flags=re.IGNORECASE), + {'regex' : re.compile('%commonappdata%',flags=re.IGNORECASE), 'replacement' : 'CSIDL_COMMON_APPDATA'}, - {'regex' : re.compile('%commonprograms%',flags=re.IGNORECASE), + {'regex' : re.compile('%commonprograms%',flags=re.IGNORECASE), 'replacement' : 'CSIDL_COMMON_PROGRAMS'}, - {'regex' : re.compile('%programfiles%',flags=re.IGNORECASE), + {'regex' : re.compile('%programfiles%',flags=re.IGNORECASE), 'replacement' : 'CSIDL_PROGRAM_FILES'}, - {'regex' : re.compile('%programs%',flags=re.IGNORECASE), + {'regex' : re.compile('%programs%',flags=re.IGNORECASE), 'replacement' : 'CSIDL_COMMON_PROGRAMS'}, - {'regex' : re.compile('%temp%',flags=re.IGNORECASE), + {'regex' : re.compile('%temp%',flags=re.IGNORECASE), 'replacement' : 'TEMP'}, - {'regex' : re.compile('%userprofile%',flags=re.IGNORECASE), + {'regex' : re.compile('%userprofile%',flags=re.IGNORECASE), 'replacement' : 'CSIDL_PROFILE'}, - {'regex' : re.compile('%profiles%',flags=re.IGNORECASE), + {'regex' : re.compile('%profiles%',flags=re.IGNORECASE), 'replacement' : 'CSIDL_PROFILE'}, - {'regex' : re.compile('%windir%',flags=re.IGNORECASE), + {'regex' : re.compile('%windir%',flags=re.IGNORECASE), 'replacement' : 'CSIDL_WINDOWS'}, - {'regex' : re.compile('%systemroot%',flags=re.IGNORECASE), + {'regex' : re.compile('%systemroot%',flags=re.IGNORECASE), 'replacement' : 'CSIDL_WINDOWS'}, - {'regex' : re.compile('[\w][:]\\\\windows\\\\system32',flags=re.IGNORECASE), + {'regex' : re.compile('[\w][:]\\\\windows\\\\system32',flags=re.IGNORECASE), 'replacement' : 'CSIDL_SYSTEM'}, - {'regex' : re.compile('[\w][:]\\\\windows(?:(?!\\\\system32))',flags=re.IGNORECASE), + {'regex' : re.compile('[\w][:]\\\\windows(?:(?!\\\\system32))',flags=re.IGNORECASE), 'replacement' : 'CSIDL_WINDOWS'}, - {'regex' : re.compile('[\w][:]\\\\[A-Z+a-z~ ()0-9\\\\]+\\\\application data',flags=re.IGNORECASE), + {'regex' : re.compile('[\w][:]\\\\[A-Z+a-z~ ()0-9\\\\]+\\\\application data',flags=re.IGNORECASE), 'replacement' : 'CSIDL_APPDATA'}, - {'regex' : re.compile('[\w][:]\\\\[A-Z+a-z~ ()0-9\\\\]+\\\\all users\\\\application data',flags=re.IGNORECASE), + {'regex' : re.compile('[\w][:]\\\\[A-Z+a-z~ ()0-9\\\\]+\\\\all users\\\\application data',flags=re.IGNORECASE), 'replacement' : 'CSIDL_COMMON_APPDATA'}, - {'regex' : re.compile('[\w][:]\\\\[A-Z+a-z~ ()0-9\\\\]+\\\\all users\\\\start menu\\\\programs',flags=re.IGNORECASE), + {'regex' : re.compile('[\w][:]\\\\[A-Z+a-z~ ()0-9\\\\]+\\\\all users\\\\start menu\\\\programs',flags=re.IGNORECASE), 'replacement' : 'CSIDL_COMMON_PROGRAMS'}, - {'regex' : re.compile('[\w][:]\\\\[A-Z+a-z~ ()0-9\\\\]+\\\\temp',flags=re.IGNORECASE), + {'regex' : re.compile('[\w][:]\\\\[A-Z+a-z~ ()0-9\\\\]+\\\\temp',flags=re.IGNORECASE), 'replacement' : 'TEMP'}, - {'regex' : re.compile('[\w][:]\\\\users\\\\[A-Z+a-z~ ()0-9]+',flags=re.IGNORECASE), + {'regex' : re.compile('[\w][:]\\\\users\\\\[A-Z+a-z~ ()0-9]+',flags=re.IGNORECASE), 'replacement' : 'CSIDL_PROFILE'}, - {'regex' : re.compile('^\w:\\\\{0,2}$',flags=re.IGNORECASE), + {'regex' : re.compile('^\w:\\\\{0,2}$',flags=re.IGNORECASE), 'replacement' : '%SystemDrive%'}, - {'regex' : re.compile('^\w:\\\\documents and settings\\\\all users',flags=re.IGNORECASE), + {'regex' : re.compile('^\w:\\\\documents and settings\\\\all users',flags=re.IGNORECASE), 'replacement' : '%ALLUSERSPROFILE%'}, - {'regex' : re.compile('^\w:\\\\programdata',flags=re.IGNORECASE), + {'regex' : re.compile('^\w:\\\\programdata',flags=re.IGNORECASE), 'replacement' : '%ALLUSERSPROFILE%'}] # Windows Registry Hive Abbreviated -> Full mappings @@ -95,7 +95,7 @@ def perform_replacement(entity, mapping_list): def normalize_object_properties(object_properties): '''Normalize the field values of certain ObjectProperties instances. - + Currently supports: File Objects --File_Path field. Normalized for common Windows paths/environment variables. @@ -103,14 +103,14 @@ def normalize_object_properties(object_properties): --Registry Value/Data field. Normalized for common Windows paths/environment variables. - --Hive field. Normalized for full representation + --Hive field. Normalized for full representation from abbreviated form. E.g., HKLM -> HKEY_LOCAL_MACHINE. Process Objects --Image_Info/Path field. Normalized for common Windows paths/environment variables. ''' - + # Normalize file object properties/subclasses if isinstance(object_properties, File): # Normalize any windows-related file paths @@ -130,4 +130,4 @@ def normalize_object_properties(object_properties): elif isinstance(object_properties, Process): # Normalize any windows-related file paths in the process image path if object_properties.image_info and object_properties.image_info.path: - perform_replacement(object_properties.image_info.path, file_path_normalization_mapping) \ No newline at end of file + perform_replacement(object_properties.image_info.path, file_path_normalization_mapping) diff --git a/examples/artifact_instance.py b/examples/artifact_instance.py index 38a0b3f7..81d46e20 100644 --- a/examples/artifact_instance.py +++ b/examples/artifact_instance.py @@ -32,7 +32,7 @@ def main(): "captured in a PCAP file and then base64 encoded for " "transport.") - print Observables(o).to_xml() + print(Observables(o).to_xml()) if __name__ == "__main__": diff --git a/examples/convert_samples.py b/examples/convert_samples.py index 226b6db9..b33a2d9f 100644 --- a/examples/convert_samples.py +++ b/examples/convert_samples.py @@ -25,7 +25,7 @@ def from_file(filename): def main(): if len(sys.argv) < 2: - print "Argument required" + print("Argument required") return # The argument should be a directory containing XML files. @@ -35,7 +35,7 @@ def main(): os.mkdir(output_dir) if not os.path.isdir(output_dir): - print "{0} exists and is not a directory.".format(output_dir) + print("{0} exists and is not a directory.".format(output_dir)) return for f in os.listdir(sys.argv[1]): @@ -48,9 +48,9 @@ def main(): try: f.write(from_file(orig_file).to_json()) except Exception as e: - print "---------------------------------" - print "ERROR with {0}".format(orig_file) - print e + print("---------------------------------") + print("ERROR with {0}".format(orig_file)) + print(e) continue if __name__ == "__main__": diff --git a/examples/parse_xml.py b/examples/parse_xml.py index 5e06c506..34585700 100755 --- a/examples/parse_xml.py +++ b/examples/parse_xml.py @@ -18,12 +18,12 @@ def parse(xml_file): def main(): if len(sys.argv) != 2: - print "[!] Please provide an xml file" + print("[!] Please provide an xml file" ) exit(1) xml_file = sys.argv[-1] observables = parse(xml_file) - print observables.to_dict() # example to_dict() call on returned object + print(observables.to_dict() # example to_dict() call on returned object) if __name__ == "__main__": main() diff --git a/examples/simple_email_instance.py b/examples/simple_email_instance.py index 33cecaa6..57cbe9d8 100644 --- a/examples/simple_email_instance.py +++ b/examples/simple_email_instance.py @@ -25,7 +25,7 @@ def main(): m.add_related(a, "Received_From", inline=False) - print Observables([m, a]).to_xml() + print(Observables([m, a]).to_xml()) if __name__ == "__main__": diff --git a/examples/simple_email_pattern.py b/examples/simple_email_pattern.py index 75325937..93dea7a9 100644 --- a/examples/simple_email_pattern.py +++ b/examples/simple_email_pattern.py @@ -23,7 +23,7 @@ def main(): m.subject = "New modifications to the specification" m.subject.condition = "Equals" - print Observables(m).to_xml() + print(Observables(m).to_xml()) if __name__ == "__main__": main() diff --git a/examples/simple_file_instance.py b/examples/simple_file_instance.py index 03e57658..dad2a150 100644 --- a/examples/simple_file_instance.py +++ b/examples/simple_file_instance.py @@ -28,7 +28,7 @@ def main(): o = Observable(f) o.description = "This observable specifies a specific file observation." - print Observables(o).to_xml() + print(Observables(o).to_xml()) if __name__ == "__main__": main() diff --git a/examples/url_instance.py b/examples/url_instance.py index bdccc271..c5f8167d 100644 --- a/examples/url_instance.py +++ b/examples/url_instance.py @@ -22,7 +22,7 @@ def main(): u.value = v u.type_ = URI.TYPE_URL - print Observables(u).to_xml() + print(Observables(u).to_xml()) if __name__ == "__main__": main() diff --git a/examples/url_pattern.py b/examples/url_pattern.py index 16559e2e..4427b9f9 100644 --- a/examples/url_pattern.py +++ b/examples/url_pattern.py @@ -23,7 +23,7 @@ def main(): u.value = v u.type_ = URI.TYPE_URL - print Observables(u).to_xml() + print(Observables(u).to_xml()) if __name__ == "__main__": main() diff --git a/examples/xml_to_json.py b/examples/xml_to_json.py index fb27f434..d0546ed3 100644 --- a/examples/xml_to_json.py +++ b/examples/xml_to_json.py @@ -17,10 +17,10 @@ def from_file(filename): def main(): if len(sys.argv) < 2: - print "Argument required" + print("Argument required") return - print from_file(sys.argv[1]).to_json() + print(from_file(sys.argv[1]).to_json()) if __name__ == "__main__": main() From 1f65b62b96fdd55687ee0d425c87e5e24b8c163e Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 12 Feb 2015 15:27:58 -0600 Subject: [PATCH 02/17] Add 'long' to compat. --- cybox/common/properties.py | 2 +- cybox/compat.py | 2 + cybox/test/objects/archive_file_test.py | 8 ++- cybox/test/objects/file_test.py | 6 +- cybox/test/objects/image_file_test.py | 8 ++- cybox/test/objects/memory_test.py | 4 +- .../test/objects/network_route_entry_test.py | 11 ++-- .../test/objects/win_computer_account_test.py | 3 +- cybox/test/objects/win_driver_test.py | 57 ++++++++++--------- cybox/test/objects/win_file_test.py | 3 +- cybox/test/objects/win_filemapping_test.py | 13 +++-- .../objects/win_memory_page_region_test.py | 3 +- cybox/test/objects/win_registry_key_test.py | 3 +- cybox/test/objects/win_semaphore_test.py | 7 ++- cybox/test/objects/win_task_test.py | 5 +- 15 files changed, 77 insertions(+), 58 deletions(-) diff --git a/cybox/common/properties.py b/cybox/common/properties.py index b57454a8..54944d27 100644 --- a/cybox/common/properties.py +++ b/cybox/common/properties.py @@ -6,7 +6,7 @@ import dateutil.parser import cybox -from cybox.compat import basestring +from cybox.compat import basestring, long import cybox.bindings.cybox_common as common_binding from cybox.common import PatternFieldGroup from cybox.utils import normalize_to_xml, denormalize_from_xml diff --git a/cybox/compat.py b/cybox/compat.py index 778fc37a..4f0d1d1f 100644 --- a/cybox/compat.py +++ b/cybox/compat.py @@ -14,10 +14,12 @@ from StringIO import StringIO basestring = basestring bytes = str + long = long str = unicode elif is_py3: from io import StringIO basestring = (str, bytes) bytes = bytes + long = int str = str diff --git a/cybox/test/objects/archive_file_test.py b/cybox/test/objects/archive_file_test.py index 95b82cec..23438b58 100644 --- a/cybox/test/objects/archive_file_test.py +++ b/cybox/test/objects/archive_file_test.py @@ -3,8 +3,10 @@ import unittest -from cybox.common import Hash, String from cybox.objects.archive_file_object import ArchiveFile + +from cybox.common import Hash, String +from cybox.compat import long import cybox.test from cybox.test import EntityTestCase from cybox.test.objects import ObjectTestCase @@ -21,7 +23,7 @@ class TestArchiveFile(ObjectTestCase, unittest.TestCase): 'decryption_key': u"abc123key", 'comment': u"This is a test", #'archived_file': [], - + 'is_packed': False, 'is_masqueraded': True, 'file_name': u"example.txt", @@ -30,7 +32,7 @@ class TestArchiveFile(ObjectTestCase, unittest.TestCase): 'device_path': u"\\Device\\CdRom0", 'full_path': u"C:\\Temp\\example.txt", 'file_extension': u"txt", - 'size_in_bytes': 1024L, + 'size_in_bytes': long(1024), 'magic_number': u"D0CF11E0", 'file_format': u"ASCII Text", 'hashes': [ diff --git a/cybox/test/objects/file_test.py b/cybox/test/objects/file_test.py index 0bb936aa..561448c1 100644 --- a/cybox/test/objects/file_test.py +++ b/cybox/test/objects/file_test.py @@ -3,8 +3,10 @@ import unittest -from cybox.common import Hash, String from cybox.objects.file_object import File, FilePath, Packer, SymLinksList + +from cybox.common import Hash, String +from cybox.compat import long import cybox.test from cybox.test import EntityTestCase from cybox.test.common.hash_test import (EMPTY_MD5, EMPTY_SHA1, EMPTY_SHA224, @@ -43,7 +45,7 @@ class TestFile(ObjectTestCase, unittest.TestCase): 'device_path': u"\\Device\\CdRom0", 'full_path': u"C:\\Temp\\example.txt", 'file_extension': u"txt", - 'size_in_bytes': 1024L, + 'size_in_bytes': long(1024), 'magic_number': u"D0CF11E0", 'file_format': u"ASCII Text", 'hashes': [ diff --git a/cybox/test/objects/image_file_test.py b/cybox/test/objects/image_file_test.py index b73d6b1f..0c7abb0e 100644 --- a/cybox/test/objects/image_file_test.py +++ b/cybox/test/objects/image_file_test.py @@ -3,8 +3,10 @@ import unittest -from cybox.common import Hash, String from cybox.objects.image_file_object import ImageFile + +from cybox.common import Hash, String +from cybox.compat import long import cybox.test from cybox.test import EntityTestCase from cybox.test.objects import ObjectTestCase @@ -20,7 +22,7 @@ class TestImageFile(ObjectTestCase, unittest.TestCase): 'image_width': 3000, 'bits_per_pixel': 9000, 'compression_algorithm': u"An algorithm", - + 'is_packed': False, 'is_masqueraded': True, 'file_name': u"example.txt", @@ -29,7 +31,7 @@ class TestImageFile(ObjectTestCase, unittest.TestCase): 'device_path': u"\\Device\\CdRom0", 'full_path': u"C:\\Temp\\example.txt", 'file_extension': u"txt", - 'size_in_bytes': 1024L, + 'size_in_bytes': long(1024), 'magic_number': u"D0CF11E0", 'file_format': u"ASCII Text", 'hashes': [ diff --git a/cybox/test/objects/memory_test.py b/cybox/test/objects/memory_test.py index e3973242..37825df7 100644 --- a/cybox/test/objects/memory_test.py +++ b/cybox/test/objects/memory_test.py @@ -4,6 +4,8 @@ import unittest from cybox.objects.memory_object import Memory + +from cybox.compat import long from cybox.test.common.hash_test import EMPTY_MD5 from cybox.test.objects import ObjectTestCase @@ -23,7 +25,7 @@ class TestMemory(ObjectTestCase, unittest.TestCase): 'is_volatile': False, 'hashes': [{'type': u"MD5", 'simple_hash_value': EMPTY_MD5}], 'name': u"A memory region", - 'region_size': 65536L, + 'region_size': long(65536), 'memory_source': u".data", 'block_type': u"Free", 'region_start_address': u"00040000", diff --git a/cybox/test/objects/network_route_entry_test.py b/cybox/test/objects/network_route_entry_test.py index c1a41ef0..57577692 100644 --- a/cybox/test/objects/network_route_entry_test.py +++ b/cybox/test/objects/network_route_entry_test.py @@ -5,6 +5,7 @@ from cybox.objects.network_route_entry_object import NetworkRouteEntry +from cybox.compat import long from cybox.test import EntityTestCase, round_trip from cybox.test.objects import ObjectTestCase @@ -20,22 +21,22 @@ class TestNetworkRouteEntry(ObjectTestCase, unittest.TestCase): 'is_loopback': False, 'is_publish': True, 'destination_address': { - 'address_value': u"1.2.3.4", + 'address_value': u"1.2.3.4", 'xsi:type': 'AddressObjectType' }, 'origin': { - 'address_value': u"1.2.3.4", + 'address_value': u"1.2.3.4", 'xsi:type': 'AddressObjectType' }, 'netmask': { - 'address_value': u"1.2.3.4", + 'address_value': u"1.2.3.4", 'xsi:type': 'AddressObjectType' }, 'gateway_address': { - 'address_value': u"1.2.3.4", + 'address_value': u"1.2.3.4", 'xsi:type': 'AddressObjectType' }, - 'metric': 1234L, + 'metric': long(1234), 'type': u"A type", 'protocol': u"A protocol", 'interface': u"An interface", diff --git a/cybox/test/objects/win_computer_account_test.py b/cybox/test/objects/win_computer_account_test.py index 0e540b76..bb8a02fd 100644 --- a/cybox/test/objects/win_computer_account_test.py +++ b/cybox/test/objects/win_computer_account_test.py @@ -3,6 +3,7 @@ import unittest +from cybox.compat import long from cybox.objects.win_computer_account_object import WinComputerAccount from cybox.test.objects import ObjectTestCase @@ -19,7 +20,7 @@ class TestWinCriticalSection(ObjectTestCase, unittest.TestCase): 'full_name': u"A full name" }, 'kerberos': { - 'ticket': 9000L, + 'ticket': long(9000), 'delegation': { 'bitmask': "dead1234", 'service': { diff --git a/cybox/test/objects/win_driver_test.py b/cybox/test/objects/win_driver_test.py index db17239b..9df4c275 100644 --- a/cybox/test/objects/win_driver_test.py +++ b/cybox/test/objects/win_driver_test.py @@ -5,6 +5,7 @@ from cybox.objects.win_driver_object import WinDriver +from cybox.compat import long from cybox.test import EntityTestCase, round_trip from cybox.test.objects import ObjectTestCase @@ -21,34 +22,34 @@ class TestWinDriver(ObjectTestCase, unittest.TestCase): 'driver_unload': "ab3234dec", 'image_base': "12345abc", 'image_size': "12ff", - 'irp_mj_cleanup': 1L, - 'irp_mj_close': 2L, - 'irp_mj_create': 3L, - 'irp_mj_create_mailslot': 4L, - 'irp_mj_create_named_pipe': 5L, - 'irp_mj_device_change': 6L, - 'irp_mj_device_control': 7L, - 'irp_mj_directory_control': 8L, - 'irp_mj_file_system_control': 9L, - 'irp_mj_flush_buffers': 11L, - 'irp_mj_internal_device_control': 12L, - 'irp_mj_lock_control': 13L, - 'irp_mj_pnp': 14L, - 'irp_mj_power': 15L, - 'irp_mj_query_ea': 16L, - 'irp_mj_query_information': 17L, - 'irp_mj_query_quota': 22L, - 'irp_mj_query_security': 23L, - 'irp_mj_query_volume_information': 24L, - 'irp_mj_read': 25L, - 'irp_mj_set_ea': 26L, - 'irp_mj_set_information': 27L, - 'irp_mj_set_quota': 33L, - 'irp_mj_set_security': 34L, - 'irp_mj_set_volume_information': 35L, - 'irp_mj_shutdown': 36L, - 'irp_mj_system_control': 37L, - 'irp_mj_write': 38L, + 'irp_mj_cleanup': long(1), + 'irp_mj_close': long(2), + 'irp_mj_create': long(3), + 'irp_mj_create_mailslot': long(4), + 'irp_mj_create_named_pipe': long(5), + 'irp_mj_device_change': long(6), + 'irp_mj_device_control': long(7), + 'irp_mj_directory_control': long(8), + 'irp_mj_file_system_control': long(9), + 'irp_mj_flush_buffers': long(11), + 'irp_mj_internal_device_control': long(12), + 'irp_mj_lock_control': long(13), + 'irp_mj_pnp': long(14), + 'irp_mj_power': long(15), + 'irp_mj_query_ea': long(16), + 'irp_mj_query_information': long(17), + 'irp_mj_query_quota': long(22), + 'irp_mj_query_security': long(23), + 'irp_mj_query_volume_information': long(24), + 'irp_mj_read': long(25), + 'irp_mj_set_ea': long(26), + 'irp_mj_set_information': long(27), + 'irp_mj_set_quota': long(33), + 'irp_mj_set_security': long(34), + 'irp_mj_set_volume_information': long(35), + 'irp_mj_shutdown': long(36), + 'irp_mj_system_control': long(37), + 'irp_mj_write': long(38), #'device_object_list' = TypedField("Device_Object_List", DeviceObjectList) 'xsi:type': object_type, } diff --git a/cybox/test/objects/win_file_test.py b/cybox/test/objects/win_file_test.py index 4408bdbe..6b55f560 100644 --- a/cybox/test/objects/win_file_test.py +++ b/cybox/test/objects/win_file_test.py @@ -3,6 +3,7 @@ import unittest +from cybox.compat import long from cybox.objects.win_file_object import WinFile, Stream from cybox.test.common.hash_test import EMPTY_MD5 from cybox.test import EntityTestCase @@ -26,7 +27,7 @@ class TestWinFile(ObjectTestCase, unittest.TestCase): 'file_name': u"example.doc", 'full_path': u"C:\\Temp\\example.doc", 'file_extension': u"doc", - 'size_in_bytes': 1024L, + 'size_in_bytes': long(1024), 'magic_number': u"D0CF11E0", # WinFile-specific fields diff --git a/cybox/test/objects/win_filemapping_test.py b/cybox/test/objects/win_filemapping_test.py index 2015708c..1bcfbdc1 100644 --- a/cybox/test/objects/win_filemapping_test.py +++ b/cybox/test/objects/win_filemapping_test.py @@ -3,6 +3,7 @@ import unittest +from cybox.compat import long from cybox.objects.win_filemapping_object import WinFilemapping from cybox.test.objects import ObjectTestCase @@ -16,18 +17,18 @@ class TestWinFilemapping(ObjectTestCase, unittest.TestCase): 'id': 1234, 'name': u"MyHandle", 'type': u"Window", - 'object_address': 0xdeadbeefL, - 'access_mask': 0x70000000L, - 'pointer_count': 3L, + 'object_address': long(0xdeadbeef), + 'access_mask': long(0x70000000), + 'pointer_count': long(3), 'xsi:type': "WindowsHandleObjectType", }, 'file_handle': { 'id': 5678, 'name': u"MyHandle2", 'type': u"Window", - 'object_address': 0xbeadbeefL, - 'access_mask': 0x90009000L, - 'pointer_count': 9L, + 'object_address': long(0xbeadbeef), + 'access_mask': long(0x90009000), + 'pointer_count': long(9), 'xsi:type': "WindowsHandleObjectType", }, 'security_attributes': u"Attributes go here", diff --git a/cybox/test/objects/win_memory_page_region_test.py b/cybox/test/objects/win_memory_page_region_test.py index 9684d31a..b984dc96 100644 --- a/cybox/test/objects/win_memory_page_region_test.py +++ b/cybox/test/objects/win_memory_page_region_test.py @@ -5,6 +5,7 @@ from cybox.objects.win_memory_page_region_object import WinMemoryPageRegion +from cybox.compat import long from cybox.test import EntityTestCase, round_trip from cybox.test.objects import ObjectTestCase @@ -20,7 +21,7 @@ class TestWinMemoryPageRegion(ObjectTestCase, unittest.TestCase): 'is_volatile': False, 'name': u"A page region", 'memory_source': u"A source", - 'region_size': 10000L, + 'region_size': long(10000), 'block_type': u"A block type", 'region_start_address': u"1234abcde", 'region_end_address': u"1234abdde", diff --git a/cybox/test/objects/win_registry_key_test.py b/cybox/test/objects/win_registry_key_test.py index 211f4148..d00a3be7 100644 --- a/cybox/test/objects/win_registry_key_test.py +++ b/cybox/test/objects/win_registry_key_test.py @@ -3,6 +3,7 @@ import unittest +from cybox.compat import long from cybox.objects.win_registry_key_object import WinRegistryKey from cybox.test.objects import ObjectTestCase @@ -33,7 +34,7 @@ class TestWinRegistryKey(ObjectTestCase, unittest.TestCase): 'handle_list': [ { 'name': u"RegHandle", - 'pointer_count': 1L, + 'pointer_count': long(1), 'type': u"RegistryKey", 'xsi:type': u'WindowsHandleObjectType', }, diff --git a/cybox/test/objects/win_semaphore_test.py b/cybox/test/objects/win_semaphore_test.py index 6865d82f..cd2e2cf2 100644 --- a/cybox/test/objects/win_semaphore_test.py +++ b/cybox/test/objects/win_semaphore_test.py @@ -3,6 +3,7 @@ import unittest +from cybox.compat import long from cybox.objects.win_semaphore_object import WinSemaphore from cybox.test.objects import ObjectTestCase @@ -16,9 +17,9 @@ class TestWinSemaphore(ObjectTestCase, unittest.TestCase): 'id': 1234, 'name': u"MyHandle", 'type': u"Window", - 'object_address': 0xdeadbeefL, - 'access_mask': 0x70000000L, - 'pointer_count': 3L, + 'object_address': long(0xdeadbeef), + 'access_mask': long(0x70000000), + 'pointer_count': long(3), 'xsi:type': "WindowsHandleObjectType", }, 'security_attributes': u"Attributes go here", diff --git a/cybox/test/objects/win_task_test.py b/cybox/test/objects/win_task_test.py index c1ea238f..6b849466 100644 --- a/cybox/test/objects/win_task_test.py +++ b/cybox/test/objects/win_task_test.py @@ -3,6 +3,7 @@ import unittest +from cybox.compat import long from cybox.objects.win_task_object import WinTask from cybox.test.common.hash_test import TEST_HASH_LIST from cybox.test.objects import ObjectTestCase @@ -25,8 +26,8 @@ class TestWinTask(ObjectTestCase, unittest.TestCase): 'creator': u"TheCreator", 'creation_date': "2012-04-26T15:30:45-05:00", 'most_recent_run_time': "2013-06-26T10:20:30-05:00", - 'exit_code': 0L, - 'max_run_time': 15000L, + 'exit_code': long(0), + 'max_run_time': long(15000), 'next_run_time': "2013-06-27T10:20:30-05:00", 'action_list': [ { From e32c55fdbeeb6c66ca788ecf0656c2f6ab6f6620 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Mon, 9 Mar 2015 15:29:04 -0500 Subject: [PATCH 03/17] Clean up compat --- cybox/compat.py | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/cybox/compat.py b/cybox/compat.py index 4f0d1d1f..f3908673 100644 --- a/cybox/compat.py +++ b/cybox/compat.py @@ -1,25 +1,45 @@ import sys -# Syntax sugar. -_ver = sys.version_info +import six -#: Python 2.x? -is_py2 = (_ver[0] == 2) - -#: Python 3.x? -is_py3 = (_ver[0] == 3) - - -if is_py2: +if six.PY2: from StringIO import StringIO basestring = basestring bytes = str long = long str = unicode -elif is_py3: +elif six.PY3: from io import StringIO basestring = (str, bytes) bytes = bytes long = int str = str + chars = lambda x: [chr(y) for y in x] + def xor(data, key): + key = int(key) + b = bytearray(data) + for i in range(len(b)): + b[i] ^= key + return bytes(b) + + +class UnicodeMixin(object): + """Make String functions work on Python 2 and 3. + + Classes using this mixin must define a `__unicode__` function that returns + the Unicode representation of the object (as a `str` on Python 3 and a + `unicode` on Python 2). + + Python 2 will use `__unicode__()` directly for `unicode()` calls, and + encode the output in UTF-8 when the `str()` function is called. + + Python 3 will use `__unicode__()` indirectly when `str()` is called. + + This code was adapted from: + http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/ + """ + if six.PY3: + __str__ = lambda x: x.__unicode__() + else: + __str__ = lambda x: x.__unicode__().encode('utf-8') From a9ab97b451ff4769cd9ccad46315fdef8993714c Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 12 Feb 2015 16:22:36 -0600 Subject: [PATCH 04/17] Better handling of __str__ and __unicode__. --- cybox/common/properties.py | 11 +++-------- cybox/common/structured_text.py | 8 +++----- cybox/compat.py | 7 ------- cybox/objects/address_object.py | 5 +++-- cybox/objects/uri_object.py | 9 +++------ 5 files changed, 12 insertions(+), 28 deletions(-) diff --git a/cybox/common/properties.py b/cybox/common/properties.py index 54944d27..b8c84b47 100644 --- a/cybox/common/properties.py +++ b/cybox/common/properties.py @@ -6,7 +6,7 @@ import dateutil.parser import cybox -from cybox.compat import basestring, long +from cybox.compat import basestring, long, str, UnicodeMixin import cybox.bindings.cybox_common as common_binding from cybox.common import PatternFieldGroup from cybox.utils import normalize_to_xml, denormalize_from_xml @@ -16,8 +16,7 @@ DATETIME_PRECISION_VALUES = DATE_PRECISION_VALUES + TIME_PRECISION_VALUES - -class BaseProperty(PatternFieldGroup, cybox.Entity): +class BaseProperty(PatternFieldGroup, cybox.Entity, UnicodeMixin): # Most Properties are defined in the "common" binding, so we'll just set # that here. Some BaseProperty subclasses might have to override this. _binding = common_binding @@ -44,12 +43,8 @@ def __init__(self, value=None): self.refanging_transform = None self.observed_encoding = None - def __str__(self): - # To be safe, return the unicode string encoded as UTF-8 - return self.__unicode__().encode("utf-8") - def __unicode__(self): - return unicode(self.serialized_value) + return str(self.serialized_value) def __int__(self): return int(self.serialized_value) diff --git a/cybox/common/structured_text.py b/cybox/common/structured_text.py index 2d277aa5..70663cdc 100644 --- a/cybox/common/structured_text.py +++ b/cybox/common/structured_text.py @@ -3,9 +3,10 @@ import cybox import cybox.bindings.cybox_common as common_binding +from cybox.compat import UnicodeMixin, str -class StructuredText(cybox.Entity): +class StructuredText(cybox.Entity, UnicodeMixin): _binding = common_binding _namespace = 'http://cybox.mitre.org/common-2' @@ -75,8 +76,5 @@ def from_dict(cls, text_dict, text=None): return text - def __str__(self): - return self.__unicode__().encode("utf-8") - def __unicode__(self): - return unicode(self.value) + return str(self.value) diff --git a/cybox/compat.py b/cybox/compat.py index f3908673..d3fd2bb8 100644 --- a/cybox/compat.py +++ b/cybox/compat.py @@ -15,13 +15,6 @@ bytes = bytes long = int str = str - chars = lambda x: [chr(y) for y in x] - def xor(data, key): - key = int(key) - b = bytearray(data) - for i in range(len(b)): - b[i] ^= key - return bytes(b) class UnicodeMixin(object): diff --git a/cybox/objects/address_object.py b/cybox/objects/address_object.py index d225bf0e..b5035bbf 100644 --- a/cybox/objects/address_object.py +++ b/cybox/objects/address_object.py @@ -5,9 +5,10 @@ import cybox from cybox.common import ObjectProperties, String, Integer +from cybox.compat import str, UnicodeMixin -class Address(ObjectProperties): +class Address(ObjectProperties, UnicodeMixin): _binding = address_binding _binding_class = address_binding.AddressObjectType _namespace = 'http://cybox.mitre.org/objects#AddressObject-2' @@ -40,7 +41,7 @@ def __init__(self, address_value=None, category=None): self.address_value = address_value self.category = category - def __str__(self): + def __unicode__(self): return str(self.address_value) # Shortcuts diff --git a/cybox/objects/uri_object.py b/cybox/objects/uri_object.py index 6e12e274..02943df7 100644 --- a/cybox/objects/uri_object.py +++ b/cybox/objects/uri_object.py @@ -1,13 +1,13 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. - import cybox import cybox.bindings.uri_object as uri_binding from cybox.common import ObjectProperties, AnyURI +from cybox.compat import str, UnicodeMixin -class URI(ObjectProperties): +class URI(ObjectProperties, UnicodeMixin): _binding = uri_binding _binding_class = uri_binding.URIObjectType _namespace = 'http://cybox.mitre.org/objects#URIObject-2' @@ -28,8 +28,5 @@ def __init__(self, value=None, type_=None): self.value = value self.type_ = type_ - def __str__(self): - return self.__unicode__().encode("utf-8") - def __unicode__(self): - return unicode(self.value) + return str(self.value) From 7f563660b90ffd8ead5795539ff8a91d682fc0f5 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Fri, 13 Feb 2015 18:03:44 -0600 Subject: [PATCH 05/17] Update tests. Removed a couple failing encoding tests that don't reflect what should typically happen in the course of the library being used. --- cybox/common/structured_text.py | 6 +- cybox/compat.py | 11 +++ cybox/objects/artifact_object.py | 49 ++++++++-- cybox/test/common/extracted_string_test.py | 5 +- cybox/test/common/hash_test.py | 2 +- cybox/test/common/properties_test.py | 22 +++-- cybox/test/common/structured_test_text.py | 16 +++- cybox/test/core/event_test.py | 2 +- cybox/test/core/observable_test.py | 4 +- cybox/test/encoding_test.py | 24 ++--- cybox/test/objects/artifact_test.py | 101 ++++++++++++++++----- cybox/test/objects/file_test.py | 5 +- cybox/test/objects/hostname_test.py | 2 +- cybox/test/objects/network_packet_test.py | 2 +- 14 files changed, 180 insertions(+), 71 deletions(-) diff --git a/cybox/common/structured_text.py b/cybox/common/structured_text.py index 70663cdc..5624099f 100644 --- a/cybox/common/structured_text.py +++ b/cybox/common/structured_text.py @@ -1,9 +1,11 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. +import six + import cybox import cybox.bindings.cybox_common as common_binding -from cybox.compat import UnicodeMixin, str +from cybox.compat import UnicodeMixin class StructuredText(cybox.Entity, UnicodeMixin): @@ -77,4 +79,4 @@ def from_dict(cls, text_dict, text=None): return text def __unicode__(self): - return str(self.value) + return six.text_type(self.value) diff --git a/cybox/compat.py b/cybox/compat.py index d3fd2bb8..75fcf7e8 100644 --- a/cybox/compat.py +++ b/cybox/compat.py @@ -8,6 +8,10 @@ bytes = str long = long str = unicode + chars = lambda x: x + def xor(data, key): + key = int(key) + return b''.join([chr(ord(c) ^ key) for c in chars(data)]) elif six.PY3: from io import StringIO @@ -15,6 +19,13 @@ bytes = bytes long = int str = str + chars = lambda x: [chr(y) for y in x] + def xor(data, key): + key = int(key) + b = bytearray(data) + for i in range(len(b)): + b[i] ^= key + return bytes(b) class UnicodeMixin(object): diff --git a/cybox/objects/artifact_object.py b/cybox/objects/artifact_object.py index 011d7aab..39763cac 100644 --- a/cybox/objects/artifact_object.py +++ b/cybox/objects/artifact_object.py @@ -9,13 +9,16 @@ import cybox.bindings.artifact_object as artifact_binding from cybox.common import ObjectProperties, String +from cybox.compat import bytes, chars, str, xor + class RawArtifact(String): _binding_class = artifact_binding.RawArtifactType _namespace = 'http://cybox.mitre.org/objects#ArtifactObject-2' - + byte_order = cybox.TypedField("byte_order") + class Artifact(ObjectProperties): # Warning: Do not attempt to get or set Raw_Artifact directly. Use `data` # or `packed_data` respectively. Raw_Artifact will be set on export. @@ -34,15 +37,33 @@ def __init__(self, data=None, type_=None): super(Artifact, self).__init__() self.type_ = type_ self.packaging = [] + + # `data` is the actual binary data that is being encoded in this + # Artifact. It should use the `str` type on Python 2 or the `bytes` + # type on Python 3. + + # `packed_data` is the literal character data that comes from (or + # becomes) the contents of the Raw_Artifact element. It should be a + # Unicode string (`unicode` on Python 2, `str` on Python 3), and should + # in general be ASCII-encoded, since any other data should be + # Base64-encoded. + + # Only one of these two attributes can be set directly. The other can + # be calculated based on the various `Packaging` types added to this + # Artifact. + + # We set the private attribute `_packed_data` first, so that the setter + # for `data` has access to this attribute. self._packed_data = None self.data = data @property def data(self): + """Should return a byte string""" if self._data: return self._data elif self._packed_data: - tmp_data = self._packed_data + tmp_data = self._packed_data.encode('ascii') for p in reversed(self.packaging): tmp_data = p.unpack(tmp_data) return tmp_data @@ -53,17 +74,22 @@ def data(self): def data(self, value): if self._packed_data: raise ValueError("packed_data already set, can't set data") + if value is not None and not isinstance(value, bytes): + msg = ("Artifact data must be either None or byte data, not a " + "Unicode string.") + raise ValueError(msg) self._data = value @property def packed_data(self): + "Should return a Unicode string" if self._packed_data: return self._packed_data elif self._data: tmp_data = self._data for p in self.packaging: tmp_data = p.pack(tmp_data) - return tmp_data + return tmp_data.decode('ascii') else: return None @@ -71,6 +97,10 @@ def packed_data(self): def packed_data(self, value): if self._data: raise ValueError("data already set, can't set packed_data") + if value is not None and not isinstance(value, str): + msg = ("Artifact packed_data must be either None or a Unicode " + "string, not byte data.") + raise ValueError(msg) self._packed_data = value def to_obj(self, return_obj=None, ns_info=None): @@ -132,7 +162,8 @@ def from_obj(artifact_obj): raw_artifact = artifact_obj.Raw_Artifact if raw_artifact: - artifact.packed_data = RawArtifact.from_obj(raw_artifact).value + data = RawArtifact.from_obj(raw_artifact).value + artifact.packed_data = str(data) artifact.type_ = artifact_obj.type_ return artifact @@ -155,7 +186,8 @@ def from_dict(artifact_dict): raw_artifact = artifact_dict.get('raw_artifact') if raw_artifact: - artifact.packed_data = RawArtifact.from_dict(raw_artifact).value + data = RawArtifact.from_dict(raw_artifact).value + artifact.packed_data = str(data) artifact.type_ = artifact_dict.get('type') return artifact @@ -166,9 +198,11 @@ class Packaging(cybox.Entity): _namespace = 'http://cybox.mitre.org/objects#ArtifactObject-2' def pack(self, data): + """This should accept byte data and return byte data""" raise NotImplementedError() def unpack(self, packed_data): + """This should accept byte data and return byte data""" raise NotImplementedError() @@ -297,11 +331,6 @@ def get_object(mechanism, key): raise ValueError("Unsupported encryption mechanism: %s" % mechanism) -def xor(data, key): - key = int(key) - return ''.join([chr(ord(c) ^ key) for c in data]) - - class XOREncryption(Encryption): def __init__(self, key): diff --git a/cybox/test/common/extracted_string_test.py b/cybox/test/common/extracted_string_test.py index 44aa1d40..4c69a58f 100644 --- a/cybox/test/common/extracted_string_test.py +++ b/cybox/test/common/extracted_string_test.py @@ -1,12 +1,15 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. +import binascii import unittest from cybox.common import ExtractedString, Hash +from cybox.compat import str from cybox.test import EntityTestCase STRING = u"This is a string" +HEX_STRING = str(binascii.hexlify(STRING.encode("ascii"))) class TestExtractedString(EntityTestCase, unittest.TestCase): klass = ExtractedString @@ -14,7 +17,7 @@ class TestExtractedString(EntityTestCase, unittest.TestCase): _full_dict = { 'encoding': u"UTF-8", 'string_value': STRING, - 'byte_string_value': unicode(STRING.encode('hex')), + 'byte_string_value': HEX_STRING, 'hashes': [{'type': Hash.TYPE_MD5}], 'address': u"1a2b", 'length': len(STRING), diff --git a/cybox/test/common/hash_test.py b/cybox/test/common/hash_test.py index 4cffb426..5a6ad916 100644 --- a/cybox/test/common/hash_test.py +++ b/cybox/test/common/hash_test.py @@ -135,7 +135,7 @@ def test_xml_output(self): self.assertEqual(str(h2), EMPTY_MD5) s = h2.to_xml() - self.assertTrue(EMPTY_MD5 in s) + self.assertTrue(EMPTY_MD5.encode("utf-8") in s) def test_constructor(self): s = HexBinary(EMPTY_MD5) diff --git a/cybox/test/common/properties_test.py b/cybox/test/common/properties_test.py index 17a9ec6c..ff1314bf 100644 --- a/cybox/test/common/properties_test.py +++ b/cybox/test/common/properties_test.py @@ -7,6 +7,7 @@ from cybox.common import (BaseProperty, DateTime, Integer, Long, NonNegativeInteger, PositiveInteger, String, UnsignedInteger, UnsignedLong, BINDING_CLASS_MAPPING, DEFAULT_DELIM) +from cybox.compat import str import cybox.test from cybox.utils import normalize_to_xml @@ -43,8 +44,8 @@ def test_list_of_strings_with_comma(self): def test_delimiter(self): s = String(["string1", "string2"]) s.delimiter = "##delim##" - self.assertTrue("##comma##" not in s.to_xml()) - self.assertTrue("string1##delim##string2" in s.to_xml()) + self.assertTrue(b"##comma##" not in s.to_xml()) + self.assertTrue(b"string1##delim##string2" in s.to_xml()) def test_integer(self): i = Integer(42) @@ -54,8 +55,9 @@ def test_integer(self): def test_unicode_string(self): s = u"A Unicode \ufffd string" string = String(s) - self.assertEqual(s, unicode(string)) - self.assertEqual(s.encode("utf-8"), str(string)) + self.assertEqual(s, str(string)) + self.assertEqual(s.encode("utf-8"), str(string).encode("utf-8")) + self.assertTrue(s.encode("utf-8") in string.to_xml()) def test_cannot_create_abstract_obj(self): a = BaseProperty() @@ -261,32 +263,32 @@ class TestApplyCondition(unittest.TestCase): def test_instance_single(self): s = String("foo") # @apply_condition should not be set on instances. - self.assertFalse('apply_condition' in s.to_xml()) + self.assertFalse(b'apply_condition' in s.to_xml()) def test_instance_multiple(self): s = String(["foo", "bar", "baz"]) # @apply_condition should not be set on instances. - self.assertFalse('apply_condition' in s.to_xml()) + self.assertFalse(b'apply_condition' in s.to_xml()) def test_instance_multiple_all(self): s = String(["foo", "bar", "baz"]) s.apply_condition = "ALL" # Even though we set it, this is not a pattern so @apply_condition # shouldn't be output. - self.assertFalse('apply_condition' in s.to_xml()) + self.assertFalse(b'apply_condition' in s.to_xml()) def test_pattern_single(self): s = String("foo") s.condition = "Equals" # @apply_condition should not be set if the value is not a list. - self.assertFalse('apply_condition' in s.to_xml()) + self.assertFalse(b'apply_condition' in s.to_xml()) def test_pattern_multiple(self): s = String(["foo", "bar", "baz"]) s.condition = "Equals" # @apply_condition should be set when there is a @condition and the # value is a list. - self.assertTrue('apply_condition="ANY"' in s.to_xml()) + self.assertTrue(b'apply_condition="ANY"' in s.to_xml()) def test_pattern_multiple_all(self): s = String(["foo", "bar", "baz"]) @@ -294,7 +296,7 @@ def test_pattern_multiple_all(self): s.apply_condition = "ALL" # If we change @apply_condition from the default, it should match # that value. - self.assertTrue('apply_condition="ALL"' in s.to_xml()) + self.assertTrue(b'apply_condition="ALL"' in s.to_xml()) if __name__ == "__main__": unittest.main() diff --git a/cybox/test/common/structured_test_text.py b/cybox/test/common/structured_test_text.py index 5f486829..3b5a8025 100644 --- a/cybox/test/common/structured_test_text.py +++ b/cybox/test/common/structured_test_text.py @@ -3,13 +3,20 @@ import unittest +from six import u + from cybox.common import StructuredText import cybox.test -class TestStructuredText(unittest.TestCase): +class TestStructuredText(cybox.test.EntityTestCase, unittest.TestCase): + klass = StructuredText + _full_dict = { + 'value': u("

WARNING \u26A0: Here is some structured text."), + 'structuring_format': "HTML", + } - def test_round_trip(self): + def test_round_trip_manual(self): text = StructuredText() text.value = "some text" text.structuring_format = "plain" @@ -28,6 +35,11 @@ def test_plain(self): self.assertEqual(text.to_dict(), text3.to_dict()) + def test_unicode(self): + text = self.klass.from_dict(self._full_dict) + # This should not raise any errors + print(text) + if __name__ == "__main__": unittest.main() diff --git a/cybox/test/core/event_test.py b/cybox/test/core/event_test.py index 0d1be3b5..09f8cf18 100644 --- a/cybox/test/core/event_test.py +++ b/cybox/test/core/event_test.py @@ -32,7 +32,7 @@ def test_empty_recursive_event(self): e = Event() e.description = "Foo" e.event = None - self.assertTrue("Foo" in e.to_xml()) + self.assertTrue(b"Foo" in e.to_xml()) if __name__ == "__main__": diff --git a/cybox/test/core/observable_test.py b/cybox/test/core/observable_test.py index 42695365..ef8a0fcf 100644 --- a/cybox/test/core/observable_test.py +++ b/cybox/test/core/observable_test.py @@ -40,10 +40,10 @@ def test_keywords(self): o = Observable() o.title = "Test" - self.assertTrue("eyword" not in o.to_xml()) + self.assertTrue(b"eyword" not in o.to_xml()) o.add_keyword("Foo") print(o.to_xml()) - self.assertTrue("Foo" in o.to_xml()) + self.assertTrue(b"Foo" in o.to_xml()) o2 = round_trip(o) self.assertEqual(1, len(o2.keywords)) diff --git a/cybox/test/encoding_test.py b/cybox/test/encoding_test.py index 819cb8a2..3a7625f7 100644 --- a/cybox/test/encoding_test.py +++ b/cybox/test/encoding_test.py @@ -6,6 +6,8 @@ import unittest +from cybox.compat import str + import cybox.bindings as bindings from cybox.common import Contributor, String, MeasureSource from cybox.core import Observable @@ -59,7 +61,7 @@ def test_quote_xml(self): def test_quote_attrib(self): """Tests that the stix.bindings.quote_attrib method works properly - on unicode inputs. + on Unicode inputs. Note: The quote_attrib method (more specifically, saxutils.quoteattr()) @@ -83,29 +85,17 @@ def test_quote_attrib_bool(self): def test_quote_xml_int(self): i = 65536 s = bindings.quote_xml(i) - self.assertEqual(unicode(i), s) + self.assertEqual(str(i), s) def test_quote_xml_bool(self): b = True s = bindings.quote_xml(b) - self.assertEqual(unicode(b), s) - - def test_quote_xml_encoded(self): - encoding = bindings.ExternalEncoding - encoded = UNICODE_STR.encode(encoding) - quoted = bindings.quote_xml(encoded) - self.assertEqual(UNICODE_STR, quoted) - - def test_quote_attrib_encoded(self): - encoding = bindings.ExternalEncoding - encoded = UNICODE_STR.encode(encoding) - quoted = bindings.quote_attrib(encoded)[1:-1] - self.assertEqual(UNICODE_STR, quoted) + self.assertEqual(str(b), s) def test_quote_xml_zero(self): i = 0 s = bindings.quote_xml(i) - self.assertEqual(unicode(i), s) + self.assertEqual(str(i), s) def test_quote_attrib_zero(self): i = 0 @@ -149,7 +139,7 @@ def test_to_xml_no_encoding(self): o = Observable() o.title = UNICODE_STR xml = o.to_xml(encoding=None) - self.assertTrue(isinstance(xml, unicode)) + self.assertTrue(isinstance(xml, str)) self.assertTrue(UNICODE_STR in xml) if __name__ == "__main__": diff --git a/cybox/test/objects/artifact_test.py b/cybox/test/objects/artifact_test.py index 705fa201..a9de883f 100644 --- a/cybox/test/objects/artifact_test.py +++ b/cybox/test/objects/artifact_test.py @@ -1,36 +1,79 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. -import base64 -import bz2 -import zlib +from base64 import b64encode import unittest +from zlib import compress from cybox.objects.artifact_object import (Artifact, Base64Encoding, Bz2Compression, RawArtifact, XOREncryption, ZlibCompression) from cybox.test import round_trip from cybox.test.objects import ObjectTestCase +from cybox.compat import bytes, str + class TestRawArtifact(unittest.TestCase): def test_xml_output(self): - data = "0123456789abcdef" + data = b"0123456789abcdef" ra = RawArtifact(data) self.assertTrue(data in ra.to_xml()) +class TestArtifactEncoding(unittest.TestCase): + + def test_cannot_create_artifact_from_unicode_data(self): + self.assertRaises(ValueError, Artifact, u"abc123") + + def test_setting_ascii_artifact_data_no_packaging(self): + a = Artifact() + a.data = b"abc123" + self.assertEqual(bytes, type(a.data)) + self.assertEqual(str, type(a.packed_data)) + + def test_cannot_set_nonascii_data_with_no_packaging(self): + a = Artifact() + # You can set this data, but if you don't add any packaging, you should + # get an error when trying to get the packed data, since it can't be + # encoded as ASCII. + a.data = b"\x00abc123\xff" + self.assertEqual(bytes, type(a.data)) + self.assertRaises(ValueError, _get_packed_data, a) + + # With Base64 encoding, we can retrieve this. + a.packaging.append(Base64Encoding()) + self.assertEqual("AGFiYzEyM/8=", a.packed_data) + + def test_setting_ascii_artifact_packed_data_no_packaging(self): + a = Artifact() + a.packed_data = u"abc123" + self.assertEqual(bytes, type(a.data)) + self.assertEqual(str, type(a.packed_data)) + + def test_cannot_set_nonascii_artifact_packed_data(self): + a = Artifact() + a.packed_data = u"\x00abc123\xff" + self.assertEqual(str, type(a.packed_data)) + + #TODO: Should this raise an error sooner, since there's nothing we can + # do at this point? There's no reason that the packed_data should + # contain non-ascii characters. + self.assertRaises(UnicodeEncodeError, _get_data, a) + + class TestArtifact(ObjectTestCase, unittest.TestCase): object_type = "ArtifactObjectType" klass = Artifact - test_text_data = "Here is a blob of text" - test_binary_data = "Here is some \x99 binary \xbb data." + ascii_data = b"ABCDEFGHIJKLMNOPQRSTUVWZYZ0123456879" + binary_data = b"\xde\xad\xbe\xef Dead Beef" - #TODO: Test with binary data as well. + # The raw_artifact data in a JSON/dict representation should always be + # ASCII byte data (typically Base64-encoded, but this is not required). _full_dict = { - 'raw_artifact': test_text_data, + 'raw_artifact': "Here is a blob of text.", 'type': Artifact.TYPE_NETWORK, 'xsi:type': object_type, } @@ -40,53 +83,69 @@ def test_set_data_and_packed_data(self): self.assertEqual(a.data, None) self.assertEqual(a.packed_data, None) - a.data = "Blob" - self.assertRaises(ValueError, _set_packed_data, a, "blob") + a.data = b"Blob" + self.assertRaises(ValueError, _set_packed_data, a, u"blob") a.data = None - a.packed_data = "Blob" - self.assertRaises(ValueError, _set_data, a, "blob") + a.packed_data = u"Blob" + self.assertRaises(ValueError, _set_data, a, b"blob") a.packed_data = None def test_round_trip(self): - a = Artifact(self.test_text_data, Artifact.TYPE_GENERIC) + # Without any packaging, the only data an Artifact can encode + # successfully is ASCII data. + a = Artifact(self.ascii_data, Artifact.TYPE_GENERIC) a2 = round_trip(a, Artifact) self.assertEqual(a.to_dict(), a2.to_dict()) + def test_non_ascii_round_trip_raises_error(self): + a = Artifact(self.binary_data, Artifact.TYPE_GENERIC) + # Since the data is non-ASCII, this should raise an error. + self.assertRaises(ValueError, round_trip, a, Artifact) + def test_base64_encoding(self): - a = Artifact(self.test_binary_data) + a = Artifact(self.binary_data) a.packaging.append(Base64Encoding()) a2 = round_trip(a, Artifact) - self.assertEqual(self.test_binary_data, a2.data) + self.assertEqual(self.binary_data, a2.data) - expected = base64.b64encode(self.test_binary_data) + expected = b64encode(self.binary_data).decode('ascii') self.assertEqual(expected, a2.packed_data) def test_zlib_base64_encoding(self): - a = Artifact(self.test_binary_data) + a = Artifact(self.binary_data) a.packaging.append(ZlibCompression()) a.packaging.append(Base64Encoding()) a2 = round_trip(a, Artifact) - self.assertEqual(self.test_binary_data, a2.data) + self.assertEqual(self.binary_data, a2.data) - expected = base64.b64encode(zlib.compress(self.test_binary_data)) + expected = b64encode(compress(self.binary_data)).decode('ascii') self.assertEqual(expected, a2.packed_data) def test_encryption(self): - a = Artifact(self.test_binary_data) + a = Artifact(self.binary_data) a.packaging.append(XOREncryption(0x4a)) a.packaging.append(Base64Encoding()) a2 = round_trip(a, Artifact) - self.assertEqual(self.test_binary_data, a2.data) + self.assertEqual(self.binary_data, a2.data) + + +def _get_data(artifact): + return artifact.data def _set_data(artifact, data): artifact.data = data +def _get_packed_data(artifact): + return artifact.packed_data + + def _set_packed_data(artifact, packed_data): artifact.packed_data = packed_data + if __name__ == "__main__": unittest.main() diff --git a/cybox/test/objects/file_test.py b/cybox/test/objects/file_test.py index 561448c1..ec90c375 100644 --- a/cybox/test/objects/file_test.py +++ b/cybox/test/objects/file_test.py @@ -18,6 +18,7 @@ class TestFilePath(unittest.TestCase): def setUp(self): self.path = "C:\\WINDOWS\\system32\\" + self.path_bytes = b"C:\\WINDOWS\\system32\\" def test_round_trip(self): fp = FilePath(self.path) @@ -29,7 +30,7 @@ def test_round_trip(self): def test_xml_output(self): fp = FilePath(self.path) - self.assertTrue(self.path in fp.to_xml()) + self.assertTrue(self.path_bytes in fp.to_xml()) class TestFile(ObjectTestCase, unittest.TestCase): @@ -150,7 +151,7 @@ def test_file_name_delimiter(self): f = File() f.file_name = ["foo", "bar"] f.file_name.delimiter = "^^" - self.assertTrue("foo^^bar" in f.to_xml()) + self.assertTrue(b"foo^^bar" in f.to_xml()) class TestPacker(EntityTestCase, unittest.TestCase): diff --git a/cybox/test/objects/hostname_test.py b/cybox/test/objects/hostname_test.py index 0d14a5bb..50df7956 100644 --- a/cybox/test/objects/hostname_test.py +++ b/cybox/test/objects/hostname_test.py @@ -20,7 +20,7 @@ class TestHostname(ObjectTestCase, unittest.TestCase): def test_missing_naming_system(self): hn = Hostname.from_dict({'hostname_value': "www.example2.com"}) - self.assertTrue("www.example2.com" in hn.to_xml()) + self.assertTrue(b"www.example2.com" in hn.to_xml()) if __name__ == "__main__": unittest.main() diff --git a/cybox/test/objects/network_packet_test.py b/cybox/test/objects/network_packet_test.py index 5009449f..367b4b56 100644 --- a/cybox/test/objects/network_packet_test.py +++ b/cybox/test/objects/network_packet_test.py @@ -48,7 +48,7 @@ class TestNetworkPacket(ObjectTestCase, unittest.TestCase): # https://github.com/CybOXProject/python-cybox/issues/181 def test_round_trip_xml(self): np = NetworkPacket.from_dict(self._full_dict) - xml = Observables(np).to_xml() + xml = Observables(np).to_xml(encoding=None) new_obj = Observables.from_obj(parseString(xml)) new_dict = new_obj.observables[0].object_.properties.to_dict() From f6393a5f6e73f5afd134483555436eb2373039aa Mon Sep 17 00:00:00 2001 From: Greg Back Date: Tue, 17 Feb 2015 09:09:09 -0600 Subject: [PATCH 06/17] Remove compat.py module and replace with six --- cybox/__init__.py | 13 +- cybox/bindings/__init__.py | 13 +- cybox/bindings/account_object.py | 2 +- cybox/bindings/address_object.py | 2 +- cybox/bindings/api_object.py | 2 +- cybox/bindings/archive_file_object.py | 2 +- cybox/bindings/arp_cache_object.py | 2 +- cybox/bindings/artifact_object.py | 2 +- cybox/bindings/as_object.py | 2 +- cybox/bindings/code_object.py | 2 +- cybox/bindings/custom_object.py | 2 +- cybox/bindings/cybox_common.py | 2 +- cybox/bindings/cybox_core.py | 2 +- cybox/bindings/device_object.py | 2 +- cybox/bindings/disk_object.py | 2 +- cybox/bindings/disk_partition_object.py | 2 +- cybox/bindings/dns_cache_object.py | 2 +- cybox/bindings/dns_query_object.py | 2 +- cybox/bindings/dns_record_object.py | 2 +- cybox/bindings/domain_name_object.py | 2 +- cybox/bindings/email_message_object.py | 2 +- .../extensions/location/ciq_address_3_0.py | 2 +- cybox/bindings/file_object.py | 2 +- cybox/bindings/gui_dialogbox_object.py | 2 +- cybox/bindings/gui_object.py | 2 +- cybox/bindings/gui_window_object.py | 2 +- cybox/bindings/hostname_object.py | 2 +- cybox/bindings/http_session_object.py | 2 +- cybox/bindings/image_file_object.py | 2 +- cybox/bindings/library_object.py | 2 +- cybox/bindings/link_object.py | 2 +- cybox/bindings/linux_package_object.py | 2 +- cybox/bindings/memory_object.py | 2 +- cybox/bindings/mutex_object.py | 2 +- cybox/bindings/network_connection_object.py | 2 +- cybox/bindings/network_flow_object.py | 2 +- cybox/bindings/network_packet_object.py | 2 +- cybox/bindings/network_route_entry_object.py | 2 +- cybox/bindings/network_route_object.py | 2 +- cybox/bindings/network_socket_object.py | 2 +- cybox/bindings/network_subnet_object.py | 2 +- cybox/bindings/pdf_file_object.py | 2 +- cybox/bindings/pipe_object.py | 2 +- cybox/bindings/port_object.py | 2 +- cybox/bindings/process_object.py | 2 +- cybox/bindings/product_object.py | 2 +- cybox/bindings/semaphore_object.py | 2 +- cybox/bindings/sms_message_object.py | 2 +- cybox/bindings/socket_address_object.py | 2 +- cybox/bindings/system_object.py | 2 +- cybox/bindings/unix_file_object.py | 2 +- .../unix_network_route_entry_object.py | 2 +- cybox/bindings/unix_pipe_object.py | 2 +- cybox/bindings/unix_process_object.py | 2 +- cybox/bindings/unix_user_account_object.py | 2 +- cybox/bindings/unix_volume_object.py | 2 +- cybox/bindings/uri_object.py | 2 +- cybox/bindings/url_history_object.py | 2 +- cybox/bindings/user_account_object.py | 2 +- cybox/bindings/user_session_object.py | 2 +- cybox/bindings/volume_object.py | 2 +- cybox/bindings/whois_object.py | 2 +- cybox/bindings/win_computer_account_object.py | 2 +- cybox/bindings/win_critical_section_object.py | 2 +- cybox/bindings/win_driver_object.py | 2 +- cybox/bindings/win_event_log_object.py | 2 +- cybox/bindings/win_event_object.py | 2 +- cybox/bindings/win_executable_file_object.py | 2 +- cybox/bindings/win_file_object.py | 2 +- cybox/bindings/win_filemapping_object.py | 2 +- cybox/bindings/win_handle_object.py | 2 +- cybox/bindings/win_hook_object.py | 2 +- cybox/bindings/win_kernel_hook_object.py | 2 +- cybox/bindings/win_kernel_object.py | 2 +- cybox/bindings/win_mailslot_object.py | 2 +- .../bindings/win_memory_page_region_object.py | 2 +- cybox/bindings/win_mutex_object.py | 2 +- .../win_network_route_entry_object.py | 2 +- cybox/bindings/win_network_share_object.py | 2 +- cybox/bindings/win_pipe_object.py | 2 +- cybox/bindings/win_prefetch_object.py | 2 +- cybox/bindings/win_process_object.py | 2 +- cybox/bindings/win_registry_key_object.py | 2 +- cybox/bindings/win_semaphore_object.py | 2 +- cybox/bindings/win_service_object.py | 2 +- cybox/bindings/win_system_object.py | 2 +- cybox/bindings/win_system_restore_object.py | 2 +- cybox/bindings/win_task_object.py | 2 +- cybox/bindings/win_thread_object.py | 2 +- cybox/bindings/win_user_account_object.py | 2 +- cybox/bindings/win_volume_object.py | 2 +- cybox/bindings/win_waitable_timer_object.py | 2 +- cybox/bindings/x509_certificate_object.py | 2 +- cybox/common/hashes.py | 24 +- cybox/common/properties.py | 16 +- cybox/common/structured_text.py | 8 +- cybox/compat.py | 27 -- cybox/objects/address_object.py | 12 +- cybox/objects/artifact_object.py | 16 +- cybox/objects/uri_object.py | 10 +- cybox/test/__init__.py | 6 +- cybox/test/common/extracted_features_test.py | 14 +- cybox/test/common/extracted_string_test.py | 14 +- cybox/test/common/hash_test.py | 22 +- cybox/test/common/measuresource_test.py | 22 +- cybox/test/common/object_properties_test.py | 4 +- cybox/test/common/properties_test.py | 20 +- cybox/test/common/tools_test.py | 4 +- cybox/test/common/vocab_test.py | 9 +- cybox/test/core/action_test.py | 16 +- cybox/test/core/event_test.py | 6 +- cybox/test/core/frequency_test.py | 4 +- cybox/test/core/object_test.py | 14 +- cybox/test/core/observable_test.py | 4 +- cybox/test/encoding_test.py | 27 +- cybox/test/objects/address_test.py | 8 +- cybox/test/objects/archive_file_test.py | 52 ++-- cybox/test/objects/arp_cache_test.py | 26 +- cybox/test/objects/artifact_test.py | 34 ++- cybox/test/objects/as_test.py | 8 +- cybox/test/objects/code_test.py | 14 +- cybox/test/objects/domainname_test.py | 4 +- cybox/test/objects/email_message_test.py | 4 +- cybox/test/objects/file_test.py | 62 +++-- cybox/test/objects/http_session_test.py | 150 +++++----- cybox/test/objects/image_file_test.py | 46 ++-- cybox/test/objects/memory_test.py | 16 +- cybox/test/objects/network_connection_test.py | 30 +- cybox/test/objects/network_packet_test.py | 256 +++++++++--------- .../test/objects/network_route_entry_test.py | 16 +- cybox/test/objects/network_socket_test.py | 20 +- cybox/test/objects/socket_address_test.py | 8 +- cybox/test/objects/uri_test.py | 12 +- cybox/test/objects/user_account_test.py | 16 +- .../test/objects/win_computer_account_test.py | 10 +- .../test/objects/win_critical_section_test.py | 4 +- cybox/test/objects/win_file_test.py | 28 +- cybox/test/objects/win_filemapping_test.py | 12 +- cybox/test/objects/win_hook_test.py | 6 +- .../objects/win_memory_page_region_test.py | 22 +- .../objects/win_network_route_entry_test.py | 6 +- cybox/test/objects/win_prefetch_test.py | 8 +- cybox/test/objects/win_registry_key_test.py | 42 +-- cybox/test/objects/win_semaphore_test.py | 10 +- cybox/test/objects/win_system_restore_test.py | 36 +-- cybox/test/objects/win_task_test.py | 70 ++--- cybox/test/objects/win_thread_test.py | 18 +- cybox/test/objects/win_user_test.py | 20 +- cybox/test/objects/win_waitable_timer_test.py | 8 +- cybox/utils/__init__.py | 8 +- docs/conf.py | 8 +- docs/examples.rst | 65 +++-- setup.py | 2 +- tox.ini | 10 +- 154 files changed, 896 insertions(+), 786 deletions(-) diff --git a/cybox/__init__.py b/cybox/__init__.py index 7c11ead8..04b0c9fb 100644 --- a/cybox/__init__.py +++ b/cybox/__init__.py @@ -5,7 +5,7 @@ import inspect import json -from .compat import StringIO, basestring, str +import six import cybox.bindings as bindings import cybox.utils.idgen @@ -292,7 +292,7 @@ def to_xml(self, include_namespaces=True, namespace_dict=None, with bindings.save_encoding(encoding): - sio = StringIO() + sio = six.StringIO() self.to_obj().export( sio.write, 0, @@ -300,7 +300,7 @@ def to_xml(self, include_namespaces=True, namespace_dict=None, pretty_print=pretty ) - s = str(sio.getvalue()).strip() + s = six.text_type(sio.getvalue()).strip() if encoding: return s.encode(encoding) @@ -341,7 +341,8 @@ def _get_namespace_def(self, additional_ns_dict=None): if not namespaces: return "" - namespaces = sorted(namespaces, key=str) + #TODO: Is there a better `key` to use here? + namespaces = sorted(namespaces, key=six.text_type) return ('\n\t' + get_xmlns_string(namespaces) + '\n\txsi:schemaLocation="' + get_schemaloc_string(namespaces) + @@ -417,7 +418,7 @@ def value(self): @value.setter def value(self, value): - self._value = str(value) + self._value = six.text_type(value) def to_obj(self, return_obj=None, ns_info=None): self._collect_ns_info(ns_info) @@ -589,7 +590,7 @@ def from_dict(cls, ref_dict): class ReferenceList(EntityList): def _fix_value(self, value): - if isinstance(value, basestring): + if isinstance(value, six.string_types): return self._contained_type(value) diff --git a/cybox/bindings/__init__.py b/cybox/bindings/__init__.py index 0b2cd388..bf9d9495 100644 --- a/cybox/bindings/__init__.py +++ b/cybox/bindings/__init__.py @@ -2,14 +2,13 @@ # See LICENSE.txt for complete terms. import base64 +import contextlib from datetime import datetime, tzinfo, timedelta import re -import contextlib - from xml.sax import saxutils -from lxml import etree as etree_ -from cybox.compat import basestring, str +from lxml import etree as etree_ +import six CDATA_START = "" @@ -150,7 +149,7 @@ def gds_validate_datetime(self, input_data, node, input_name=''): return input_data def gds_format_datetime(self, input_data, input_name=''): - if isinstance(input_data, basestring): + if isinstance(input_data, six.string_types): return input_data if input_data.microsecond == 0: _svalue = input_data.strftime('%Y-%m-%dT%H:%M:%S') @@ -197,7 +196,7 @@ def gds_validate_date(self, input_data, node, input_name=''): return input_data def gds_format_date(self, input_data, input_name=''): - if isinstance(input_data, basestring): + if isinstance(input_data, six.string_types): return input_data _svalue = input_data.strftime('%Y-%m-%d') if input_data.tzinfo is not None: @@ -285,7 +284,7 @@ def _coerce_unicode(text): # This is mainly a catch-all for non # string/unicode types like bool and int. try: - text = str(text) + text = six.text_type(text) except UnicodeDecodeError: text = text.decode(ExternalEncoding) diff --git a/cybox/bindings/account_object.py b/cybox/bindings/account_object.py index 4578cd5d..a8d97b7d 100644 --- a/cybox/bindings/account_object.py +++ b/cybox/bindings/account_object.py @@ -472,7 +472,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/address_object.py b/cybox/bindings/address_object.py index 2846b4af..0b3cd798 100644 --- a/cybox/bindings/address_object.py +++ b/cybox/bindings/address_object.py @@ -305,7 +305,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/api_object.py b/cybox/bindings/api_object.py index 51e88148..26410ce6 100644 --- a/cybox/bindings/api_object.py +++ b/cybox/bindings/api_object.py @@ -266,7 +266,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/archive_file_object.py b/cybox/bindings/archive_file_object.py index afe32da4..741376cf 100644 --- a/cybox/bindings/archive_file_object.py +++ b/cybox/bindings/archive_file_object.py @@ -408,7 +408,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/arp_cache_object.py b/cybox/bindings/arp_cache_object.py index a8ce5edf..3e41edc0 100644 --- a/cybox/bindings/arp_cache_object.py +++ b/cybox/bindings/arp_cache_object.py @@ -449,7 +449,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/artifact_object.py b/cybox/bindings/artifact_object.py index cf32d345..71031144 100644 --- a/cybox/bindings/artifact_object.py +++ b/cybox/bindings/artifact_object.py @@ -762,7 +762,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/as_object.py b/cybox/bindings/as_object.py index 95ef7412..fa483623 100644 --- a/cybox/bindings/as_object.py +++ b/cybox/bindings/as_object.py @@ -270,7 +270,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/code_object.py b/cybox/bindings/code_object.py index ea932c86..6998ff00 100644 --- a/cybox/bindings/code_object.py +++ b/cybox/bindings/code_object.py @@ -789,7 +789,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/custom_object.py b/cybox/bindings/custom_object.py index c13e5273..7ee1062e 100644 --- a/cybox/bindings/custom_object.py +++ b/cybox/bindings/custom_object.py @@ -240,7 +240,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/cybox_common.py b/cybox/bindings/cybox_common.py index fcf01009..75902301 100644 --- a/cybox/bindings/cybox_common.py +++ b/cybox/bindings/cybox_common.py @@ -7821,7 +7821,7 @@ def parse(inFileName): def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/cybox_core.py b/cybox/bindings/cybox_core.py index 9954da06..a1a1c067 100644 --- a/cybox/bindings/cybox_core.py +++ b/cybox/bindings/cybox_core.py @@ -3937,7 +3937,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/device_object.py b/cybox/bindings/device_object.py index f47773d3..6e865e8f 100644 --- a/cybox/bindings/device_object.py +++ b/cybox/bindings/device_object.py @@ -299,7 +299,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/disk_object.py b/cybox/bindings/disk_object.py index f965c632..08dcec21 100644 --- a/cybox/bindings/disk_object.py +++ b/cybox/bindings/disk_object.py @@ -421,7 +421,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/disk_partition_object.py b/cybox/bindings/disk_partition_object.py index 8ad781f7..dffb1082 100644 --- a/cybox/bindings/disk_partition_object.py +++ b/cybox/bindings/disk_partition_object.py @@ -408,7 +408,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/dns_cache_object.py b/cybox/bindings/dns_cache_object.py index 3659f328..636a34a6 100644 --- a/cybox/bindings/dns_cache_object.py +++ b/cybox/bindings/dns_cache_object.py @@ -311,7 +311,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/dns_query_object.py b/cybox/bindings/dns_query_object.py index 6b40595f..8bf0d3cf 100644 --- a/cybox/bindings/dns_query_object.py +++ b/cybox/bindings/dns_query_object.py @@ -549,7 +549,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/dns_record_object.py b/cybox/bindings/dns_record_object.py index ec706d2e..8626a449 100644 --- a/cybox/bindings/dns_record_object.py +++ b/cybox/bindings/dns_record_object.py @@ -353,7 +353,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/domain_name_object.py b/cybox/bindings/domain_name_object.py index e6d6f004..c956eaea 100644 --- a/cybox/bindings/domain_name_object.py +++ b/cybox/bindings/domain_name_object.py @@ -243,7 +243,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/email_message_object.py b/cybox/bindings/email_message_object.py index b22c3020..bd6f8772 100644 --- a/cybox/bindings/email_message_object.py +++ b/cybox/bindings/email_message_object.py @@ -1095,7 +1095,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/extensions/location/ciq_address_3_0.py b/cybox/bindings/extensions/location/ciq_address_3_0.py index e2470f03..f4f46eb7 100644 --- a/cybox/bindings/extensions/location/ciq_address_3_0.py +++ b/cybox/bindings/extensions/location/ciq_address_3_0.py @@ -247,7 +247,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/file_object.py b/cybox/bindings/file_object.py index 64ee2741..f2b9d78b 100644 --- a/cybox/bindings/file_object.py +++ b/cybox/bindings/file_object.py @@ -1315,7 +1315,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/gui_dialogbox_object.py b/cybox/bindings/gui_dialogbox_object.py index f3258c1f..e5ac23d2 100644 --- a/cybox/bindings/gui_dialogbox_object.py +++ b/cybox/bindings/gui_dialogbox_object.py @@ -237,7 +237,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/gui_object.py b/cybox/bindings/gui_object.py index 3ee6ab22..3bec3619 100644 --- a/cybox/bindings/gui_object.py +++ b/cybox/bindings/gui_object.py @@ -233,7 +233,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/gui_window_object.py b/cybox/bindings/gui_window_object.py index 789c0f4b..9e4a5a2b 100644 --- a/cybox/bindings/gui_window_object.py +++ b/cybox/bindings/gui_window_object.py @@ -247,7 +247,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/hostname_object.py b/cybox/bindings/hostname_object.py index 4dccdf32..96b9df00 100644 --- a/cybox/bindings/hostname_object.py +++ b/cybox/bindings/hostname_object.py @@ -260,7 +260,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/http_session_object.py b/cybox/bindings/http_session_object.py index 3bea34d9..010a94df 100644 --- a/cybox/bindings/http_session_object.py +++ b/cybox/bindings/http_session_object.py @@ -1994,7 +1994,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/image_file_object.py b/cybox/bindings/image_file_object.py index 054435cd..e1fa41a5 100644 --- a/cybox/bindings/image_file_object.py +++ b/cybox/bindings/image_file_object.py @@ -400,7 +400,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/library_object.py b/cybox/bindings/library_object.py index 56187583..2994a537 100644 --- a/cybox/bindings/library_object.py +++ b/cybox/bindings/library_object.py @@ -362,7 +362,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/link_object.py b/cybox/bindings/link_object.py index 4caafec5..55b96db5 100644 --- a/cybox/bindings/link_object.py +++ b/cybox/bindings/link_object.py @@ -189,7 +189,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/linux_package_object.py b/cybox/bindings/linux_package_object.py index fe49040a..bc080c40 100644 --- a/cybox/bindings/linux_package_object.py +++ b/cybox/bindings/linux_package_object.py @@ -310,7 +310,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/memory_object.py b/cybox/bindings/memory_object.py index e7f866d1..3d1a4303 100644 --- a/cybox/bindings/memory_object.py +++ b/cybox/bindings/memory_object.py @@ -442,7 +442,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/mutex_object.py b/cybox/bindings/mutex_object.py index bfed3e83..cd9fa110 100644 --- a/cybox/bindings/mutex_object.py +++ b/cybox/bindings/mutex_object.py @@ -237,7 +237,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_connection_object.py b/cybox/bindings/network_connection_object.py index 97f504b6..26713ba7 100644 --- a/cybox/bindings/network_connection_object.py +++ b/cybox/bindings/network_connection_object.py @@ -658,7 +658,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_flow_object.py b/cybox/bindings/network_flow_object.py index 002a7e4c..33700c6d 100644 --- a/cybox/bindings/network_flow_object.py +++ b/cybox/bindings/network_flow_object.py @@ -5155,7 +5155,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_packet_object.py b/cybox/bindings/network_packet_object.py index 1863f015..b152df8a 100644 --- a/cybox/bindings/network_packet_object.py +++ b/cybox/bindings/network_packet_object.py @@ -9008,7 +9008,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_route_entry_object.py b/cybox/bindings/network_route_entry_object.py index 5aa77043..a8a1ec3e 100644 --- a/cybox/bindings/network_route_entry_object.py +++ b/cybox/bindings/network_route_entry_object.py @@ -500,7 +500,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_route_object.py b/cybox/bindings/network_route_object.py index ec7c4918..00753109 100644 --- a/cybox/bindings/network_route_object.py +++ b/cybox/bindings/network_route_object.py @@ -420,7 +420,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_socket_object.py b/cybox/bindings/network_socket_object.py index 4543acc9..94c08deb 100644 --- a/cybox/bindings/network_socket_object.py +++ b/cybox/bindings/network_socket_object.py @@ -982,7 +982,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_subnet_object.py b/cybox/bindings/network_subnet_object.py index 6ed1f2fc..b49fd7a6 100644 --- a/cybox/bindings/network_subnet_object.py +++ b/cybox/bindings/network_subnet_object.py @@ -339,7 +339,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/pdf_file_object.py b/cybox/bindings/pdf_file_object.py index 417b7cf2..35b5ac2b 100644 --- a/cybox/bindings/pdf_file_object.py +++ b/cybox/bindings/pdf_file_object.py @@ -2190,7 +2190,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/pipe_object.py b/cybox/bindings/pipe_object.py index f800ff0f..4a4246cc 100644 --- a/cybox/bindings/pipe_object.py +++ b/cybox/bindings/pipe_object.py @@ -236,7 +236,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/port_object.py b/cybox/bindings/port_object.py index a87b51e0..6dd05247 100644 --- a/cybox/bindings/port_object.py +++ b/cybox/bindings/port_object.py @@ -308,7 +308,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/process_object.py b/cybox/bindings/process_object.py index 61e1712d..53b7a21d 100644 --- a/cybox/bindings/process_object.py +++ b/cybox/bindings/process_object.py @@ -933,7 +933,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/product_object.py b/cybox/bindings/product_object.py index feee270d..55c74e5d 100644 --- a/cybox/bindings/product_object.py +++ b/cybox/bindings/product_object.py @@ -276,7 +276,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/semaphore_object.py b/cybox/bindings/semaphore_object.py index dd096541..5f33d575 100644 --- a/cybox/bindings/semaphore_object.py +++ b/cybox/bindings/semaphore_object.py @@ -265,7 +265,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/sms_message_object.py b/cybox/bindings/sms_message_object.py index 9c7a24ed..a5c20ed5 100644 --- a/cybox/bindings/sms_message_object.py +++ b/cybox/bindings/sms_message_object.py @@ -344,7 +344,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/socket_address_object.py b/cybox/bindings/socket_address_object.py index fc9127f8..a5cf1110 100644 --- a/cybox/bindings/socket_address_object.py +++ b/cybox/bindings/socket_address_object.py @@ -248,7 +248,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/system_object.py b/cybox/bindings/system_object.py index 3693c0f3..1b1d65a7 100644 --- a/cybox/bindings/system_object.py +++ b/cybox/bindings/system_object.py @@ -1272,7 +1272,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_file_object.py b/cybox/bindings/unix_file_object.py index 03b41efb..d840d69e 100644 --- a/cybox/bindings/unix_file_object.py +++ b/cybox/bindings/unix_file_object.py @@ -589,7 +589,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_network_route_entry_object.py b/cybox/bindings/unix_network_route_entry_object.py index a54b3b37..8113bc2f 100644 --- a/cybox/bindings/unix_network_route_entry_object.py +++ b/cybox/bindings/unix_network_route_entry_object.py @@ -282,7 +282,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_pipe_object.py b/cybox/bindings/unix_pipe_object.py index 8bc3d622..78007722 100644 --- a/cybox/bindings/unix_pipe_object.py +++ b/cybox/bindings/unix_pipe_object.py @@ -223,7 +223,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_process_object.py b/cybox/bindings/unix_process_object.py index 87404ec3..08d449fa 100644 --- a/cybox/bindings/unix_process_object.py +++ b/cybox/bindings/unix_process_object.py @@ -583,7 +583,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_user_account_object.py b/cybox/bindings/unix_user_account_object.py index 273088ca..aecc41c8 100644 --- a/cybox/bindings/unix_user_account_object.py +++ b/cybox/bindings/unix_user_account_object.py @@ -403,7 +403,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_volume_object.py b/cybox/bindings/unix_volume_object.py index f525177b..9eccc620 100644 --- a/cybox/bindings/unix_volume_object.py +++ b/cybox/bindings/unix_volume_object.py @@ -245,7 +245,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/uri_object.py b/cybox/bindings/uri_object.py index 2ee61529..91668ad2 100644 --- a/cybox/bindings/uri_object.py +++ b/cybox/bindings/uri_object.py @@ -232,7 +232,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/url_history_object.py b/cybox/bindings/url_history_object.py index 35ad630a..c7c88ce5 100644 --- a/cybox/bindings/url_history_object.py +++ b/cybox/bindings/url_history_object.py @@ -430,7 +430,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/user_account_object.py b/cybox/bindings/user_account_object.py index 8ad2fe72..ade961a1 100644 --- a/cybox/bindings/user_account_object.py +++ b/cybox/bindings/user_account_object.py @@ -594,7 +594,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/user_session_object.py b/cybox/bindings/user_session_object.py index b284ebba..097e2b85 100644 --- a/cybox/bindings/user_session_object.py +++ b/cybox/bindings/user_session_object.py @@ -280,7 +280,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/volume_object.py b/cybox/bindings/volume_object.py index 148da17e..eb6da25c 100644 --- a/cybox/bindings/volume_object.py +++ b/cybox/bindings/volume_object.py @@ -545,7 +545,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/whois_object.py b/cybox/bindings/whois_object.py index 0a944a7d..68b5241a 100644 --- a/cybox/bindings/whois_object.py +++ b/cybox/bindings/whois_object.py @@ -1165,7 +1165,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_computer_account_object.py b/cybox/bindings/win_computer_account_object.py index 66bffe49..3a445a24 100644 --- a/cybox/bindings/win_computer_account_object.py +++ b/cybox/bindings/win_computer_account_object.py @@ -603,7 +603,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_critical_section_object.py b/cybox/bindings/win_critical_section_object.py index 10fe77da..78ca545d 100644 --- a/cybox/bindings/win_critical_section_object.py +++ b/cybox/bindings/win_critical_section_object.py @@ -235,7 +235,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_driver_object.py b/cybox/bindings/win_driver_object.py index 7f3c3437..e89bb857 100644 --- a/cybox/bindings/win_driver_object.py +++ b/cybox/bindings/win_driver_object.py @@ -830,7 +830,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_event_log_object.py b/cybox/bindings/win_event_log_object.py index 013f18f5..e1b2c2c1 100644 --- a/cybox/bindings/win_event_log_object.py +++ b/cybox/bindings/win_event_log_object.py @@ -499,7 +499,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_event_object.py b/cybox/bindings/win_event_object.py index 5ea7feca..e735a870 100644 --- a/cybox/bindings/win_event_object.py +++ b/cybox/bindings/win_event_object.py @@ -324,7 +324,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_executable_file_object.py b/cybox/bindings/win_executable_file_object.py index 2289d1ef..27ae5374 100644 --- a/cybox/bindings/win_executable_file_object.py +++ b/cybox/bindings/win_executable_file_object.py @@ -3515,7 +3515,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_file_object.py b/cybox/bindings/win_file_object.py index c7eec32e..81617776 100644 --- a/cybox/bindings/win_file_object.py +++ b/cybox/bindings/win_file_object.py @@ -768,7 +768,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_filemapping_object.py b/cybox/bindings/win_filemapping_object.py index 4bf1cca7..d98a3912 100644 --- a/cybox/bindings/win_filemapping_object.py +++ b/cybox/bindings/win_filemapping_object.py @@ -452,7 +452,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_handle_object.py b/cybox/bindings/win_handle_object.py index 94099e8c..68d5a5a9 100644 --- a/cybox/bindings/win_handle_object.py +++ b/cybox/bindings/win_handle_object.py @@ -425,7 +425,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_hook_object.py b/cybox/bindings/win_hook_object.py index 0e4608c0..a98b37d5 100644 --- a/cybox/bindings/win_hook_object.py +++ b/cybox/bindings/win_hook_object.py @@ -357,7 +357,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_kernel_hook_object.py b/cybox/bindings/win_kernel_hook_object.py index b7f143ae..b0152294 100644 --- a/cybox/bindings/win_kernel_hook_object.py +++ b/cybox/bindings/win_kernel_hook_object.py @@ -377,7 +377,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_kernel_object.py b/cybox/bindings/win_kernel_object.py index e2c61611..d328aac7 100644 --- a/cybox/bindings/win_kernel_object.py +++ b/cybox/bindings/win_kernel_object.py @@ -596,7 +596,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_mailslot_object.py b/cybox/bindings/win_mailslot_object.py index c061f1db..d7d6a143 100644 --- a/cybox/bindings/win_mailslot_object.py +++ b/cybox/bindings/win_mailslot_object.py @@ -274,7 +274,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_memory_page_region_object.py b/cybox/bindings/win_memory_page_region_object.py index 2df0674f..e1392d0e 100644 --- a/cybox/bindings/win_memory_page_region_object.py +++ b/cybox/bindings/win_memory_page_region_object.py @@ -496,7 +496,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_mutex_object.py b/cybox/bindings/win_mutex_object.py index 6cf90244..6b843ab3 100644 --- a/cybox/bindings/win_mutex_object.py +++ b/cybox/bindings/win_mutex_object.py @@ -241,7 +241,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_network_route_entry_object.py b/cybox/bindings/win_network_route_entry_object.py index 39c2ff03..6c3064fc 100644 --- a/cybox/bindings/win_network_route_entry_object.py +++ b/cybox/bindings/win_network_route_entry_object.py @@ -398,7 +398,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_network_share_object.py b/cybox/bindings/win_network_share_object.py index c01dc138..0c2c71f4 100644 --- a/cybox/bindings/win_network_share_object.py +++ b/cybox/bindings/win_network_share_object.py @@ -465,7 +465,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_pipe_object.py b/cybox/bindings/win_pipe_object.py index 80e51d15..94213ffb 100644 --- a/cybox/bindings/win_pipe_object.py +++ b/cybox/bindings/win_pipe_object.py @@ -313,7 +313,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_prefetch_object.py b/cybox/bindings/win_prefetch_object.py index a36a9fd6..6371adfc 100644 --- a/cybox/bindings/win_prefetch_object.py +++ b/cybox/bindings/win_prefetch_object.py @@ -553,7 +553,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_process_object.py b/cybox/bindings/win_process_object.py index 0092eb70..eac1ecd6 100644 --- a/cybox/bindings/win_process_object.py +++ b/cybox/bindings/win_process_object.py @@ -731,7 +731,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_registry_key_object.py b/cybox/bindings/win_registry_key_object.py index e98f733b..03fbe824 100644 --- a/cybox/bindings/win_registry_key_object.py +++ b/cybox/bindings/win_registry_key_object.py @@ -716,7 +716,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_semaphore_object.py b/cybox/bindings/win_semaphore_object.py index abaa4f13..0ee5e51d 100644 --- a/cybox/bindings/win_semaphore_object.py +++ b/cybox/bindings/win_semaphore_object.py @@ -243,7 +243,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_service_object.py b/cybox/bindings/win_service_object.py index d9101c4c..23f6fdb6 100644 --- a/cybox/bindings/win_service_object.py +++ b/cybox/bindings/win_service_object.py @@ -805,7 +805,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_system_object.py b/cybox/bindings/win_system_object.py index 03117134..c3a018d0 100644 --- a/cybox/bindings/win_system_object.py +++ b/cybox/bindings/win_system_object.py @@ -550,7 +550,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_system_restore_object.py b/cybox/bindings/win_system_restore_object.py index 46341cb7..fda48109 100644 --- a/cybox/bindings/win_system_restore_object.py +++ b/cybox/bindings/win_system_restore_object.py @@ -569,7 +569,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_task_object.py b/cybox/bindings/win_task_object.py index 9dc621fc..6f523960 100644 --- a/cybox/bindings/win_task_object.py +++ b/cybox/bindings/win_task_object.py @@ -1581,7 +1581,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_thread_object.py b/cybox/bindings/win_thread_object.py index 56f45812..162469cb 100644 --- a/cybox/bindings/win_thread_object.py +++ b/cybox/bindings/win_thread_object.py @@ -427,7 +427,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_user_account_object.py b/cybox/bindings/win_user_account_object.py index 311b2f49..c521f8fb 100644 --- a/cybox/bindings/win_user_account_object.py +++ b/cybox/bindings/win_user_account_object.py @@ -389,7 +389,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_volume_object.py b/cybox/bindings/win_volume_object.py index 81fc079b..e3bdc4ec 100644 --- a/cybox/bindings/win_volume_object.py +++ b/cybox/bindings/win_volume_object.py @@ -474,7 +474,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_waitable_timer_object.py b/cybox/bindings/win_waitable_timer_object.py index 953412a1..95ad2597 100644 --- a/cybox/bindings/win_waitable_timer_object.py +++ b/cybox/bindings/win_waitable_timer_object.py @@ -335,7 +335,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/x509_certificate_object.py b/cybox/bindings/x509_certificate_object.py index 87dee5ba..c915b9b1 100644 --- a/cybox/bindings/x509_certificate_object.py +++ b/cybox/bindings/x509_certificate_object.py @@ -1032,7 +1032,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from cybox.compat import StringIO + from six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/common/hashes.py b/cybox/common/hashes.py index 5fbbab81..171b378d 100644 --- a/cybox/common/hashes.py +++ b/cybox/common/hashes.py @@ -1,8 +1,10 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. +import six +from six import u + import cybox -from cybox.compat import basestring import cybox.bindings.cybox_common as common_binding from cybox.common import vocabs, HexBinary, String, VocabString from cybox.common.vocabs import HashName @@ -40,15 +42,15 @@ def _auto_type(self): callback_hook=_auto_type) fuzzy_hash_value = cybox.TypedField("Fuzzy_Hash_Value", String) - TYPE_MD5 = u"MD5" - TYPE_MD6 = u"MD6" - TYPE_SHA1 = u"SHA1" - TYPE_SHA224 = u"SHA224" - TYPE_SHA256 = u"SHA256" - TYPE_SHA384 = u"SHA384" - TYPE_SHA512 = u"SHA512" - TYPE_SSDEEP = u"SSDEEP" - TYPE_OTHER = VocabString(u"Other") + TYPE_MD5 = u("MD5") + TYPE_MD6 = u("MD6") + TYPE_SHA1 = u("SHA1") + TYPE_SHA224 = u("SHA224") + TYPE_SHA256 = u("SHA256") + TYPE_SHA384 = u("SHA384") + TYPE_SHA512 = u("SHA512") + TYPE_SSDEEP = u("SSDEEP") + TYPE_OTHER = VocabString(u("Other")) def __init__(self, hash_value=None, type_=None, exact=False): """Create a new Hash Object @@ -129,7 +131,7 @@ class HashList(cybox.EntityList): def _fix_value(self, value): # If the user tries to put a string into a list, convert it to a Hash. - if isinstance(value, basestring): + if isinstance(value, six.string_types): return Hash(value) @property diff --git a/cybox/common/properties.py b/cybox/common/properties.py index b8c84b47..409ea850 100644 --- a/cybox/common/properties.py +++ b/cybox/common/properties.py @@ -4,9 +4,10 @@ from datetime import datetime import dateutil.parser +import six import cybox -from cybox.compat import basestring, long, str, UnicodeMixin +from cybox.compat import long import cybox.bindings.cybox_common as common_binding from cybox.common import PatternFieldGroup from cybox.utils import normalize_to_xml, denormalize_from_xml @@ -16,7 +17,8 @@ DATETIME_PRECISION_VALUES = DATE_PRECISION_VALUES + TIME_PRECISION_VALUES -class BaseProperty(PatternFieldGroup, cybox.Entity, UnicodeMixin): +@six.python_2_unicode_compatible +class BaseProperty(PatternFieldGroup, cybox.Entity): # Most Properties are defined in the "common" binding, so we'll just set # that here. Some BaseProperty subclasses might have to override this. _binding = common_binding @@ -43,8 +45,8 @@ def __init__(self, value=None): self.refanging_transform = None self.observed_encoding = None - def __unicode__(self): - return str(self.serialized_value) + def __str__(self): + return six.text_type(self.serialized_value) def __int__(self): return int(self.serialized_value) @@ -342,7 +344,7 @@ class String(BaseProperty): @staticmethod def _parse_value(value): - if value is not None and not isinstance(value, basestring): + if value is not None and not isinstance(value, six.string_types): raise ValueError("Cannot set String type to non-string value") return value @@ -355,7 +357,7 @@ class _IntegerBase(BaseProperty): def _parse_value(value): if value is None or value == '': return None - if isinstance(value, basestring): + if isinstance(value, six.string_types): return int(value, 0) else: return int(value) @@ -507,7 +509,7 @@ class _LongBase(BaseProperty): def _parse_value(value): if value is None or value == '': return None - if isinstance(value, basestring): + if isinstance(value, six.string_types): return long(value, 0) else: return long(value) diff --git a/cybox/common/structured_text.py b/cybox/common/structured_text.py index 5624099f..c9642861 100644 --- a/cybox/common/structured_text.py +++ b/cybox/common/structured_text.py @@ -5,10 +5,10 @@ import cybox import cybox.bindings.cybox_common as common_binding -from cybox.compat import UnicodeMixin -class StructuredText(cybox.Entity, UnicodeMixin): +@six.python_2_unicode_compatible +class StructuredText(cybox.Entity): _binding = common_binding _namespace = 'http://cybox.mitre.org/common-2' @@ -78,5 +78,5 @@ def from_dict(cls, text_dict, text=None): return text - def __unicode__(self): - return six.text_type(self.value) + def __str__(self): + return self.value diff --git a/cybox/compat.py b/cybox/compat.py index 75fcf7e8..b753b28b 100644 --- a/cybox/compat.py +++ b/cybox/compat.py @@ -3,9 +3,6 @@ import six if six.PY2: - from StringIO import StringIO - basestring = basestring - bytes = str long = long str = unicode chars = lambda x: x @@ -14,9 +11,6 @@ def xor(data, key): return b''.join([chr(ord(c) ^ key) for c in chars(data)]) elif six.PY3: - from io import StringIO - basestring = (str, bytes) - bytes = bytes long = int str = str chars = lambda x: [chr(y) for y in x] @@ -26,24 +20,3 @@ def xor(data, key): for i in range(len(b)): b[i] ^= key return bytes(b) - - -class UnicodeMixin(object): - """Make String functions work on Python 2 and 3. - - Classes using this mixin must define a `__unicode__` function that returns - the Unicode representation of the object (as a `str` on Python 3 and a - `unicode` on Python 2). - - Python 2 will use `__unicode__()` directly for `unicode()` calls, and - encode the output in UTF-8 when the `str()` function is called. - - Python 3 will use `__unicode__()` indirectly when `str()` is called. - - This code was adapted from: - http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/ - """ - if six.PY3: - __str__ = lambda x: x.__unicode__() - else: - __str__ = lambda x: x.__unicode__().encode('utf-8') diff --git a/cybox/objects/address_object.py b/cybox/objects/address_object.py index b5035bbf..487cd44f 100644 --- a/cybox/objects/address_object.py +++ b/cybox/objects/address_object.py @@ -1,14 +1,16 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. -import cybox.bindings.address_object as address_binding +import six + import cybox +import cybox.bindings.address_object as address_binding from cybox.common import ObjectProperties, String, Integer -from cybox.compat import str, UnicodeMixin -class Address(ObjectProperties, UnicodeMixin): +@six.python_2_unicode_compatible +class Address(ObjectProperties): _binding = address_binding _binding_class = address_binding.AddressObjectType _namespace = 'http://cybox.mitre.org/objects#AddressObject-2' @@ -41,8 +43,8 @@ def __init__(self, address_value=None, category=None): self.address_value = address_value self.category = category - def __unicode__(self): - return str(self.address_value) + def __str__(self): + return six.text_type(self.address_value) # Shortcuts @property diff --git a/cybox/objects/artifact_object.py b/cybox/objects/artifact_object.py index 39763cac..dcad405b 100644 --- a/cybox/objects/artifact_object.py +++ b/cybox/objects/artifact_object.py @@ -5,11 +5,12 @@ import bz2 import zlib +import six + import cybox import cybox.bindings.artifact_object as artifact_binding from cybox.common import ObjectProperties, String - -from cybox.compat import bytes, chars, str, xor +from cybox.compat import chars, xor class RawArtifact(String): @@ -74,7 +75,7 @@ def data(self): def data(self, value): if self._packed_data: raise ValueError("packed_data already set, can't set data") - if value is not None and not isinstance(value, bytes): + if value is not None and not isinstance(value, six.binary_type): msg = ("Artifact data must be either None or byte data, not a " "Unicode string.") raise ValueError(msg) @@ -97,7 +98,7 @@ def packed_data(self): def packed_data(self, value): if self._data: raise ValueError("data already set, can't set packed_data") - if value is not None and not isinstance(value, str): + if value is not None and not isinstance(value, six.text_type): msg = ("Artifact packed_data must be either None or a Unicode " "string, not byte data.") raise ValueError(msg) @@ -163,7 +164,7 @@ def from_obj(artifact_obj): raw_artifact = artifact_obj.Raw_Artifact if raw_artifact: data = RawArtifact.from_obj(raw_artifact).value - artifact.packed_data = str(data) + artifact.packed_data = six.text_type(data) artifact.type_ = artifact_obj.type_ return artifact @@ -187,7 +188,7 @@ def from_dict(artifact_dict): raw_artifact = artifact_dict.get('raw_artifact') if raw_artifact: data = RawArtifact.from_dict(raw_artifact).value - artifact.packed_data = str(data) + artifact.packed_data = six.text_type(data) artifact.type_ = artifact_dict.get('type') return artifact @@ -352,9 +353,8 @@ def __init__(self, key): def unpack(self, packed_data): from zipfile import ZipFile - from cybox.compat import StringIO - buf = StringIO(packed_data) + buf = six.StringIO(packed_data) with ZipFile(buf, 'r') as myzip: # Assume there is only one member in the archive, and that it # contains the artifact data. Ignore the name. diff --git a/cybox/objects/uri_object.py b/cybox/objects/uri_object.py index 02943df7..e95e8feb 100644 --- a/cybox/objects/uri_object.py +++ b/cybox/objects/uri_object.py @@ -1,13 +1,15 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. +import six + import cybox import cybox.bindings.uri_object as uri_binding from cybox.common import ObjectProperties, AnyURI -from cybox.compat import str, UnicodeMixin -class URI(ObjectProperties, UnicodeMixin): +@six.python_2_unicode_compatible +class URI(ObjectProperties): _binding = uri_binding _binding_class = uri_binding.URIObjectType _namespace = 'http://cybox.mitre.org/objects#URIObject-2' @@ -28,5 +30,5 @@ def __init__(self, value=None, type_=None): self.value = value self.type_ = type_ - def __unicode__(self): - return str(self.value) + def __str__(self): + return six.text_type(self.value) diff --git a/cybox/test/__init__.py b/cybox/test/__init__.py index 3a88460c..bc90afc5 100644 --- a/cybox/test/__init__.py +++ b/cybox/test/__init__.py @@ -4,7 +4,7 @@ import json import unittest -from cybox.compat import str +import six import cybox.bindings as bindings from cybox import Entity, EntityList, TypedField @@ -88,7 +88,9 @@ def round_trip(o, output=False, list_=False): # 6. Bindings Object -> XML String xml_string = o2.to_xml(encoding=bindings.ExternalEncoding) - if not isinstance(xml_string, str): + # Explicitly check to see if it's a Unicode string before trying to decode + # it. + if not isinstance(xml_string, six.text_type): xml_string = xml_string.decode(bindings.ExternalEncoding) if output: diff --git a/cybox/test/common/extracted_features_test.py b/cybox/test/common/extracted_features_test.py index 8a11de46..9c60e95a 100644 --- a/cybox/test/common/extracted_features_test.py +++ b/cybox/test/common/extracted_features_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.common import ExtractedFeatures from cybox.test import EntityTestCase @@ -16,15 +18,15 @@ class TestExtractedFeatures(EntityTestCase, unittest.TestCase): _full_dict = { 'strings': [ - {'encoding': u"ASCII", 'string_value': u"A String", 'length': 8}, - {'encoding': u"UTF-8", 'string_value': u"Another String"}, + {'encoding': u("ASCII"), 'string_value': u("A String"), 'length': 8}, + {'encoding': u("UTF-8"), 'string_value': u("Another String")}, ], - 'imports': [u"CreateFileA", u"LoadLibrary"], - 'functions': [u"DoSomething", u"DoSomethingElse"], + 'imports': [u("CreateFileA"), u("LoadLibrary")], + 'functions': [u("DoSomething"), u("DoSomethingElse")], #TODO: Use CodeObject instead of AddressObject 'code_snippets': [ - {'address_value': u"8.8.8.8", 'xsi:type': "AddressObjectType"}, - {'address_value': u"1.2.3.4", 'xsi:type': "AddressObjectType"}, + {'address_value': u("8.8.8.8"), 'xsi:type': "AddressObjectType"}, + {'address_value': u("1.2.3.4"), 'xsi:type': "AddressObjectType"}, ], } diff --git a/cybox/test/common/extracted_string_test.py b/cybox/test/common/extracted_string_test.py index 4c69a58f..dbe8e370 100644 --- a/cybox/test/common/extracted_string_test.py +++ b/cybox/test/common/extracted_string_test.py @@ -4,24 +4,26 @@ import binascii import unittest +import six +from six import u + from cybox.common import ExtractedString, Hash -from cybox.compat import str from cybox.test import EntityTestCase -STRING = u"This is a string" -HEX_STRING = str(binascii.hexlify(STRING.encode("ascii"))) +STRING = u("This is a string") +HEX_STRING = six.text_type(binascii.hexlify(STRING.encode("ascii"))) class TestExtractedString(EntityTestCase, unittest.TestCase): klass = ExtractedString _full_dict = { - 'encoding': u"UTF-8", + 'encoding': u("UTF-8"), 'string_value': STRING, 'byte_string_value': HEX_STRING, 'hashes': [{'type': Hash.TYPE_MD5}], - 'address': u"1a2b", + 'address': u("1a2b"), 'length': len(STRING), - 'language': u"English", + 'language': u("English"), 'english_translation': STRING, } diff --git a/cybox/test/common/hash_test.py b/cybox/test/common/hash_test.py index 5a6ad916..4abf37a9 100644 --- a/cybox/test/common/hash_test.py +++ b/cybox/test/common/hash_test.py @@ -3,20 +3,22 @@ import unittest +from six import u + from cybox.common import Hash, HashList, HashName, HexBinary import cybox.test -EMPTY_MD5 = u"d41d8cd98f00b204e9800998ecf8427e" -EMPTY_SHA1 = u"da39a3ee5e6b4b0d3255bfef95601890afd80709" -EMPTY_SHA224 = u"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" +EMPTY_MD5 = u("d41d8cd98f00b204e9800998ecf8427e") +EMPTY_SHA1 = u("da39a3ee5e6b4b0d3255bfef95601890afd80709") +EMPTY_SHA224 = u("d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f") EMPTY_SHA256 = \ - u"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" -EMPTY_SHA384 = ( - u"38b060a751ac96384cd9327eb1b1e36a21fdb71114be0743" - u"4c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b") -EMPTY_SHA512 = ( - u"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce" - u"47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e") + u("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") +EMPTY_SHA384 = u( + "38b060a751ac96384cd9327eb1b1e36a21fdb71114be0743" + "4c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b") +EMPTY_SHA512 = u( + "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce" + "47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e") TEST_HASH_LIST = [ {'simple_hash_value': EMPTY_MD5, diff --git a/cybox/test/common/measuresource_test.py b/cybox/test/common/measuresource_test.py index 75161efb..f1d4584e 100644 --- a/cybox/test/common/measuresource_test.py +++ b/cybox/test/common/measuresource_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.common import MeasureSource from cybox.test import EntityTestCase @@ -14,18 +16,18 @@ class TestMeasureSource(EntityTestCase, unittest.TestCase): 'class': "Software", 'source_type': "Information Source", 'name': "ASource", - 'information_source_type': u"Web Logs", - 'tool_type': u"Vulnerability Scanner", - 'description': u"A description of the source", + 'information_source_type': u("Web Logs"), + 'tool_type': u("Vulnerability Scanner"), + 'description': u("A description of the source"), 'contributors': [ { - 'name': u"An amazing dude", - 'email': u"amazing@dude.com", + 'name': u("An amazing dude"), + 'email': u("amazing@dude.com"), }, { - 'name': u"Another amazing dude", - 'role': u"President of Amazing", - 'organization': u"AmazingCo.", + 'name': u("Another amazing dude"), + 'role': u("President of Amazing"), + 'organization': u("AmazingCo."), }, ], 'time': { @@ -33,9 +35,9 @@ class TestMeasureSource(EntityTestCase, unittest.TestCase): 'end_time': "2014-03-11T06:22:17-05:00", }, 'tools': [ - {'name': u"AmazingTool (TM)"} + {'name': u("AmazingTool (TM)")} ], - 'platform': {'description': u"The best platform"}, + 'platform': {'description': u("The best platform")}, #TODO: Add System and Instance } diff --git a/cybox/test/common/object_properties_test.py b/cybox/test/common/object_properties_test.py index 0e2876b9..2e99633b 100644 --- a/cybox/test/common/object_properties_test.py +++ b/cybox/test/common/object_properties_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.common import ObjectProperties, Property from cybox.objects.address_object import Address from cybox.test import EntityTestCase @@ -15,7 +17,7 @@ class TestProperty(EntityTestCase, unittest.TestCase): 'id': "example:Property-1", 'name': "FilePurpose", 'description': "The purpose of the file", - 'value': u"Certificate", + 'value': u("Certificate"), } diff --git a/cybox/test/common/properties_test.py b/cybox/test/common/properties_test.py index ff1314bf..9d626416 100644 --- a/cybox/test/common/properties_test.py +++ b/cybox/test/common/properties_test.py @@ -4,10 +4,12 @@ import datetime import unittest +import six +from six import u + from cybox.common import (BaseProperty, DateTime, Integer, Long, NonNegativeInteger, PositiveInteger, String, UnsignedInteger, UnsignedLong, BINDING_CLASS_MAPPING, DEFAULT_DELIM) -from cybox.compat import str import cybox.test from cybox.utils import normalize_to_xml @@ -37,7 +39,7 @@ def test_string_with_comma(self): self.assertEqual(s, s2) def test_list_of_strings_with_comma(self): - s = String([u"string,1", u"string,1", u"string,3"]) + s = String([u("string,1"), u("string,1"), u("string,3")]) s2 = cybox.test.round_trip(s) self.assertEqual(s, s2) @@ -53,10 +55,12 @@ def test_integer(self): self.assertEqual(i.value, 42) def test_unicode_string(self): - s = u"A Unicode \ufffd string" + s = u("A Unicode \ufffd string") string = String(s) - self.assertEqual(s, str(string)) - self.assertEqual(s.encode("utf-8"), str(string).encode("utf-8")) + + unicode_string = six.text_type(string) + self.assertEqual(s, unicode_string) + self.assertEqual(s.encode("utf-8"), unicode_string.encode("utf-8")) self.assertTrue(s.encode("utf-8") in string.to_xml()) def test_cannot_create_abstract_obj(self): @@ -137,7 +141,7 @@ def test_coerce_to_string(self): val = "abc1234" s = String(val) self.assertEqual(val, s.value) - self.assertEqual(val, str(s)) + self.assertEqual(val, six.text_type(s)) def test_coerce_to_int(self): val = 42 @@ -236,13 +240,13 @@ def test_isodate(self): def test_parse_datetime(self): cybox_dt = DateTime(self.dt) self.assertEqual(self.dt, cybox_dt.value) - self.assertEqual(self.dt.isoformat(), str(cybox_dt)) + self.assertEqual(self.dt.isoformat(), six.text_type(cybox_dt)) def test_parse_date_string(self): cybox_dt2 = DateTime(self.dt_str) self.assertEqual(self.dt, cybox_dt2.value) self.assertEqual(self.dt.isoformat(), cybox_dt2.serialized_value) - self.assertEqual(self.dt.isoformat(), str(cybox_dt2)) + self.assertEqual(self.dt.isoformat(), six.text_type(cybox_dt2)) def test_list_dates(self): dt = DateTime([self.dt, self.dt, self.dt]) diff --git a/cybox/test/common/tools_test.py b/cybox/test/common/tools_test.py index 95a85a46..b3a3766c 100644 --- a/cybox/test/common/tools_test.py +++ b/cybox/test/common/tools_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.common import Hash, ToolInformation, ToolInformationList import cybox.test from cybox.test import EntityTestCase @@ -16,7 +18,7 @@ class TestToolInformation(EntityTestCase, unittest.TestCase): 'id': "example:Tool-A1", 'idref': "example:Tool-A1-ref", 'name': "AwesomeTool(tm)", - 'type': [u'NIDS', u'HIPS'], + 'type': [u('NIDS'), u('HIPS')], 'description': {'structuring_format': 'HTML', 'value': '

An awesome tool!

'}, diff --git a/cybox/test/common/vocab_test.py b/cybox/test/common/vocab_test.py index ba55de78..175a6968 100644 --- a/cybox/test/common/vocab_test.py +++ b/cybox/test/common/vocab_test.py @@ -3,9 +3,12 @@ import unittest +from six import u + from cybox.bindings import cybox_common as common_binding from cybox.common import HashName, VocabString, vocabs from cybox.common.vocabs import HashName + import cybox.test from cybox.utils import normalize_to_xml @@ -86,11 +89,11 @@ def test_round_trip(self): # https://github.com/CybOXProject/python-cybox/issues/158 def test_xsi_type_unicode(self): - string = u"test\u2010value" + string = u("test\u2010value") vocab_dict = { 'value': string, - 'condition': u"Equals", - 'xsi:type': u"some_xsi_type", + 'condition': u("Equals"), + 'xsi:type': u("some_xsi_type"), } vocab_dict2 = cybox.test.round_trip_dict(VocabString, vocab_dict) diff --git a/cybox/test/core/action_test.py b/cybox/test/core/action_test.py index f4c49d78..b133b0fb 100644 --- a/cybox/test/core/action_test.py +++ b/cybox/test/core/action_test.py @@ -4,6 +4,8 @@ import copy import unittest +from six import u + from cybox.bindings.cybox_core import parseString from cybox.core import Action, ActionRelationship from cybox.common import VocabString @@ -20,17 +22,17 @@ class TestAction(EntityTestCase, unittest.TestCase): 'action_status': "Success", 'context': "Host", 'timestamp': "2013-10-24T09:54:13", - 'type': u"Modify", - 'name': u"Modify File", + 'type': u("Modify"), + 'name': u("Modify File"), 'description': {'value': "An action!", 'structuring_format': "Text"}, 'action_aliases': ['an alias', 'another_alias'], 'action_arguments': [ { - 'argument_name': u"infile", + 'argument_name': u("infile"), 'argument_value': "/tmp/somefile.txt", }, { - 'argument_name': u"outfile", + 'argument_name': u("outfile"), 'argument_value': "/tmp/someotherfile.txt", } ], @@ -42,7 +44,7 @@ class TestAction(EntityTestCase, unittest.TestCase): ], 'relationships': [ { - 'type': u"Followed_By", + 'type': u("Followed_By"), 'action_reference': [{'action_id': "example:Action-2"}] } ], @@ -65,7 +67,7 @@ class TestActionRelationship(EntityTestCase, unittest.TestCase): klass = ActionRelationship _full_dict = { - 'type': u"Add", + 'type': u("Add"), 'action_reference': [ {'action_id': "example:Action-1"}, {'action_id': "example:Action-3"}, @@ -74,7 +76,7 @@ class TestActionRelationship(EntityTestCase, unittest.TestCase): def test_nonstandard_type_vocab(self): ar = ActionRelationship() - ar.type = VocabString(u"AddedMultipleTimes") + ar.type = VocabString(u("AddedMultipleTimes")) ar.type.vocab_reference = "http://example.com/action-types/" ar.type.xsi_type = None ar2 = round_trip(ar) diff --git a/cybox/test/core/event_test.py b/cybox/test/core/event_test.py index 09f8cf18..d91a9617 100644 --- a/cybox/test/core/event_test.py +++ b/cybox/test/core/event_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.core import Event from cybox.test import EntityTestCase @@ -13,8 +15,8 @@ class TestEvent(EntityTestCase, unittest.TestCase): _full_dict = { 'id': "example:Event-1", 'idref': "example:Event-2", - 'type': u"Port Scan", - 'description': u"This is a test event", + 'type': u("Port Scan"), + 'description': u("This is a test event"), 'observation_method': {'class': "Network"}, 'frequency': {'rate': 1.0}, 'actions': [ diff --git a/cybox/test/core/frequency_test.py b/cybox/test/core/frequency_test.py index f17f749a..00b953b9 100644 --- a/cybox/test/core/frequency_test.py +++ b/cybox/test/core/frequency_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.core import Frequency from cybox.test import EntityTestCase @@ -12,7 +14,7 @@ class TestFrequency(EntityTestCase, unittest.TestCase): _full_dict = { 'rate': 1.2, - 'units': u"per hour", + 'units': u("per hour"), 'scale': "weekly", 'trend': "Increasing", } diff --git a/cybox/test/core/object_test.py b/cybox/test/core/object_test.py index da86983f..637112d4 100644 --- a/cybox/test/core/object_test.py +++ b/cybox/test/core/object_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.core import Object, Observables, RelatedObject, Relationship from cybox.objects.address_object import Address from cybox.objects.email_message_object import EmailMessage @@ -17,13 +19,13 @@ class ObjectTest(EntityTestCase, unittest.TestCase): _full_dict = { 'id': "example:Object-1", 'properties': { - 'file_name': u"example.txt", + 'file_name': u("example.txt"), 'xsi:type': "FileObjectType" }, 'related_objects': [ { 'idref': "example:Object-2", - 'relationship': u"Same As", + 'relationship': u("Same As"), }, ], } @@ -51,7 +53,7 @@ class RelatedObjectTest(EntityTestCase, unittest.TestCase): _full_dict = { 'id': "example:Object-1", - 'relationship': u"Created", + 'relationship': u("Created"), } def setUp(self): @@ -123,7 +125,7 @@ def test_missing_related_object(self): def test_relationship_standard_xsitype(self): d = { 'id': "example:Object-1", - 'relationship': u"Created", + 'relationship': u("Created"), } self._test_round_trip_dict(d) @@ -131,7 +133,7 @@ def test_relationship_nonstandard_xsitype(self): d = { 'id': "example:Object-1", 'relationship': { - 'value': u"Created", + 'value': u("Created"), 'xsi:type': "Foo", } } @@ -141,7 +143,7 @@ def test_relationship_vocabnameref(self): d = { 'id': "example:Object-1", 'relationship': { - 'value': u"Created", + 'value': u("Created"), 'vocab_name': "Foo", 'vocab_reference': "http://example.com/FooVocab", } diff --git a/cybox/test/core/observable_test.py b/cybox/test/core/observable_test.py index ef8a0fcf..6d716da3 100644 --- a/cybox/test/core/observable_test.py +++ b/cybox/test/core/observable_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.common import MeasureSource, ObjectProperties, String, StructuredText from cybox.core import (Event, Object, Observable, ObservableComposition, Observables, PatternFidelity, ObfuscationTechniques, @@ -23,7 +25,7 @@ class TestObservable(EntityTestCase, unittest.TestCase): ], 'object': { 'properties': { - 'file_name': u"example.txt", + 'file_name': u("example.txt"), 'xsi:type': "FileObjectType" }, }, diff --git a/cybox/test/encoding_test.py b/cybox/test/encoding_test.py index 3a7625f7..7a5af9de 100644 --- a/cybox/test/encoding_test.py +++ b/cybox/test/encoding_test.py @@ -6,7 +6,8 @@ import unittest -from cybox.compat import str +import six +from six import u import cybox.bindings as bindings from cybox.common import Contributor, String, MeasureSource @@ -15,7 +16,7 @@ from cybox.objects.whois_object import WhoisEntry from cybox.test import round_trip -UNICODE_STR = u"❤ ♎ ☀ ★ ☂ ♞ ☯ ☭ ☢ €☎⚑ ❄♫✂" +UNICODE_STR = u("❤ ♎ ☀ ★ ☂ ♞ ☯ ☭ ☢ €☎⚑ ❄♫✂") class EncodingTests(unittest.TestCase): @@ -75,52 +76,52 @@ def test_quote_attrib(self): def test_quote_attrib_int(self): i = 65536 s = bindings.quote_attrib(i) - self.assertEqual(u'"65536"', s) + self.assertEqual(u('"65536"'), s) def test_quote_attrib_bool(self): b = True s = bindings.quote_attrib(b) - self.assertEqual(u'"True"', s) + self.assertEqual(u('"True"'), s) def test_quote_xml_int(self): i = 65536 s = bindings.quote_xml(i) - self.assertEqual(str(i), s) + self.assertEqual(six.text_type(i), s) def test_quote_xml_bool(self): b = True s = bindings.quote_xml(b) - self.assertEqual(str(b), s) + self.assertEqual(six.text_type(b), s) def test_quote_xml_zero(self): i = 0 s = bindings.quote_xml(i) - self.assertEqual(str(i), s) + self.assertEqual(six.text_type(i), s) def test_quote_attrib_zero(self): i = 0 s = bindings.quote_attrib(i) - self.assertEqual(u'"0"', s) + self.assertEqual(u('"0"'), s) def test_quote_xml_none(self): i = None s = bindings.quote_xml(i) - self.assertEqual(u'', s) + self.assertEqual(u(''), s) def test_quote_attrib_none(self): i = None s = bindings.quote_attrib(i) - self.assertEqual(u'""', s) + self.assertEqual(u('""'), s) def test_quote_attrib_empty(self): i = '' s = bindings.quote_attrib(i) - self.assertEqual(u'""', s) + self.assertEqual(u('""'), s) def test_quote_xml_empty(self): i = '' s = bindings.quote_xml(i) - self.assertEqual(u'', s) + self.assertEqual(u(''), s) def test_to_xml_utf16_encoded(self): encoding = 'utf-16' @@ -139,7 +140,7 @@ def test_to_xml_no_encoding(self): o = Observable() o.title = UNICODE_STR xml = o.to_xml(encoding=None) - self.assertTrue(isinstance(xml, str)) + self.assertTrue(isinstance(xml, six.text_type)) self.assertTrue(UNICODE_STR in xml) if __name__ == "__main__": diff --git a/cybox/test/objects/address_test.py b/cybox/test/objects/address_test.py index a3d8566c..23651021 100644 --- a/cybox/test/objects/address_test.py +++ b/cybox/test/objects/address_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.common import String from cybox.objects.address_object import Address, EmailAddress import cybox.test @@ -14,12 +16,12 @@ class TestAddress(ObjectTestCase, unittest.TestCase): klass = Address _full_dict = { - 'address_value': u"1.2.3.4", + 'address_value': u("1.2.3.4"), 'category': Address.CAT_IPV4, 'is_destination': True, 'is_source': False, 'is_spoofed' : True, - 'vlan_name': u"VLAN0", + 'vlan_name': u("VLAN0"), 'vlan_num': 0, 'xsi:type': object_type, } @@ -42,7 +44,7 @@ def test_round_trip(self): self.assertEqual(email, str(addr2)) def test_unicode(self): - a = u"\u00fc\u00f1\u00ed\u00e7ode@example.com" + a = u("\u00fc\u00f1\u00ed\u00e7ode@example.com") addr = Address(a, Address.CAT_EMAIL) addr2 = cybox.test.round_trip(addr) self.assertEqual(addr.to_dict(), addr2.to_dict()) diff --git a/cybox/test/objects/archive_file_test.py b/cybox/test/objects/archive_file_test.py index 23438b58..25fa5531 100644 --- a/cybox/test/objects/archive_file_test.py +++ b/cybox/test/objects/archive_file_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.archive_file_object import ArchiveFile from cybox.common import Hash, String @@ -16,57 +18,57 @@ class TestArchiveFile(ObjectTestCase, unittest.TestCase): klass = ArchiveFile _full_dict = { - 'archive_format': u"ZIP", - 'version': u"v2", + 'archive_format': u("ZIP"), + 'version': u("v2"), 'file_count': 10000, - 'encryption_algorithm': u"some algorithm", - 'decryption_key': u"abc123key", - 'comment': u"This is a test", + 'encryption_algorithm': u("some algorithm"), + 'decryption_key': u("abc123key"), + 'comment': u("This is a test"), #'archived_file': [], 'is_packed': False, 'is_masqueraded': True, - 'file_name': u"example.txt", - 'file_path': {'value': u"C:\\Temp", + 'file_name': u("example.txt"), + 'file_path': {'value': u("C:\\Temp"), 'fully_qualified': True}, - 'device_path': u"\\Device\\CdRom0", - 'full_path': u"C:\\Temp\\example.txt", - 'file_extension': u"txt", + 'device_path': u("\\Device\\CdRom0"), + 'full_path': u("C:\\Temp\\example.txt"), + 'file_extension': u("txt"), 'size_in_bytes': long(1024), - 'magic_number': u"D0CF11E0", - 'file_format': u"ASCII Text", + 'magic_number': u("D0CF11E0"), + 'file_format': u("ASCII Text"), 'hashes': [ { 'type': Hash.TYPE_MD5, - 'simple_hash_value': u"0123456789abcdef0123456789abcdef" + 'simple_hash_value': u("0123456789abcdef0123456789abcdef") } ], 'digital_signatures': [ { - 'certificate_issuer': u"Microsoft", - 'certificate_subject': u"Notepad", + 'certificate_issuer': u("Microsoft"), + 'certificate_subject': u("Notepad"), } ], 'modified_time': "2010-11-06T02:02:02+08:00", 'accessed_time': "2010-11-07T02:03:02+09:00", 'created_time': "2010-11-08T02:04:02+10:00", - 'user_owner': u"sballmer", + 'user_owner': u("sballmer"), 'packer_list': [ { - 'name': u"UPX", - 'version': u"3.91", + 'name': u("UPX"), + 'version': u("3.91"), } ], 'peak_entropy': 7.454352453, - 'sym_links': [u"../link_destination"], - 'byte_runs': [{'offset': 16, 'byte_run_data': u"1A2B3C4D"}], + 'sym_links': [u("../link_destination")], + 'byte_runs': [{'offset': 16, 'byte_run_data': u("1A2B3C4D")}], 'extracted_features': { - 'strings': [{'string_value': u"string from the file"}], + 'strings': [{'string_value': u("string from the file")}], }, - 'encryption_algorithm': u"RC4", - 'compression_method': u"deflate", - 'compression_version': u"1.0", - 'compression_comment': u"This has been compressed", + 'encryption_algorithm': u("RC4"), + 'compression_method': u("deflate"), + 'compression_version': u("1.0"), + 'compression_comment': u("This has been compressed"), 'xsi:type': object_type, } diff --git a/cybox/test/objects/arp_cache_test.py b/cybox/test/objects/arp_cache_test.py index da22e303..178a7dd5 100644 --- a/cybox/test/objects/arp_cache_test.py +++ b/cybox/test/objects/arp_cache_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.arp_cache_object import ARPCache from cybox.test import EntityTestCase, round_trip @@ -17,26 +19,26 @@ class TestARPCache(ObjectTestCase, unittest.TestCase): 'arp_cache_entry': [ { 'ip_address': { - 'address_value': u"100.200.100.1", + 'address_value': u("100.200.100.1"), 'xsi:type': 'AddressObjectType' - }, - 'physical_address': u"100.200.100.1", - 'type': u"Test", + }, + 'physical_address': u("100.200.100.1"), + 'type': u("Test"), 'network_interface': { - 'adapter': u'eth0', - 'description': u'a test' + 'adapter': u('eth0'), + 'description': u('a test') } }, { 'ip_address': { - 'address_value': u"100.200.100.2", + 'address_value': u("100.200.100.2"), 'xsi:type': 'AddressObjectType' - }, - 'physical_address': u"100.200.100.2", - 'type': u"Test 2", + }, + 'physical_address': u("100.200.100.2"), + 'type': u("Test 2"), 'network_interface': { - 'adapter': u'eth2', - 'description': u'a test 2' + 'adapter': u('eth2'), + 'description': u('a test 2') } } ], diff --git a/cybox/test/objects/artifact_test.py b/cybox/test/objects/artifact_test.py index a9de883f..063bf673 100644 --- a/cybox/test/objects/artifact_test.py +++ b/cybox/test/objects/artifact_test.py @@ -5,33 +5,37 @@ import unittest from zlib import compress +import six +from six import u + from cybox.objects.artifact_object import (Artifact, Base64Encoding, Bz2Compression, RawArtifact, XOREncryption, ZlibCompression) from cybox.test import round_trip from cybox.test.objects import ObjectTestCase -from cybox.compat import bytes, str - class TestRawArtifact(unittest.TestCase): def test_xml_output(self): - data = b"0123456789abcdef" + # A RawArtifact stores a Unicode string, even though it typically + # consists only of valid Base64 characters. + data = u("0123456789abcdef") ra = RawArtifact(data) - self.assertTrue(data in ra.to_xml()) + expected_data = data.encode('utf-8') + self.assertTrue(expected_data in ra.to_xml()) class TestArtifactEncoding(unittest.TestCase): def test_cannot_create_artifact_from_unicode_data(self): - self.assertRaises(ValueError, Artifact, u"abc123") + self.assertRaises(ValueError, Artifact, u("abc123")) def test_setting_ascii_artifact_data_no_packaging(self): a = Artifact() a.data = b"abc123" - self.assertEqual(bytes, type(a.data)) - self.assertEqual(str, type(a.packed_data)) + self.assertEqual(six.binary_type, type(a.data)) + self.assertEqual(six.text_type, type(a.packed_data)) def test_cannot_set_nonascii_data_with_no_packaging(self): a = Artifact() @@ -39,7 +43,7 @@ def test_cannot_set_nonascii_data_with_no_packaging(self): # get an error when trying to get the packed data, since it can't be # encoded as ASCII. a.data = b"\x00abc123\xff" - self.assertEqual(bytes, type(a.data)) + self.assertEqual(six.binary_type, type(a.data)) self.assertRaises(ValueError, _get_packed_data, a) # With Base64 encoding, we can retrieve this. @@ -48,14 +52,14 @@ def test_cannot_set_nonascii_data_with_no_packaging(self): def test_setting_ascii_artifact_packed_data_no_packaging(self): a = Artifact() - a.packed_data = u"abc123" - self.assertEqual(bytes, type(a.data)) - self.assertEqual(str, type(a.packed_data)) + a.packed_data = u("abc123") + self.assertEqual(six.binary_type, type(a.data)) + self.assertEqual(six.text_type, type(a.packed_data)) def test_cannot_set_nonascii_artifact_packed_data(self): a = Artifact() - a.packed_data = u"\x00abc123\xff" - self.assertEqual(str, type(a.packed_data)) + a.packed_data = u("\x00abc123\xff") + self.assertEqual(six.text_type, type(a.packed_data)) #TODO: Should this raise an error sooner, since there's nothing we can # do at this point? There's no reason that the packed_data should @@ -84,10 +88,10 @@ def test_set_data_and_packed_data(self): self.assertEqual(a.packed_data, None) a.data = b"Blob" - self.assertRaises(ValueError, _set_packed_data, a, u"blob") + self.assertRaises(ValueError, _set_packed_data, a, u("blob")) a.data = None - a.packed_data = u"Blob" + a.packed_data = u("Blob") self.assertRaises(ValueError, _set_data, a, b"blob") a.packed_data = None diff --git a/cybox/test/objects/as_test.py b/cybox/test/objects/as_test.py index 3966f917..814c3b13 100644 --- a/cybox/test/objects/as_test.py +++ b/cybox/test/objects/as_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.as_object import AutonomousSystem from cybox.test.objects import ObjectTestCase @@ -13,9 +15,9 @@ class TestAccount(ObjectTestCase, unittest.TestCase): _full_dict = { 'number': 22222, - 'name': u"OMAHASTEAKS", - 'handle': u"AS22222", - 'regional_internet_registry': u"ARIN", + 'name': u("OMAHASTEAKS"), + 'handle': u("AS22222"), + 'regional_internet_registry': u("ARIN"), 'xsi:type': object_type, } diff --git a/cybox/test/objects/code_test.py b/cybox/test/objects/code_test.py index 0ad7f731..56ce50f3 100644 --- a/cybox/test/objects/code_test.py +++ b/cybox/test/objects/code_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.code_object import Code from cybox.test.objects import ObjectTestCase @@ -13,12 +15,12 @@ class TestCode(ObjectTestCase, unittest.TestCase): _full_dict = { #TODO: add other fields - 'description': u"Some code", - 'type': u"Foo", - 'purpose': u"Demonstration", - 'code_language': u"C++", - 'start_address': u"00040000", - 'code_segment': u"int a = 1", + 'description': u("Some code"), + 'type': u("Foo"), + 'purpose': u("Demonstration"), + 'code_language': u("C++"), + 'start_address': u("00040000"), + 'code_segment': u("int a = 1"), 'code_segment_xor': { 'value': "1234", 'condition': "Equals", diff --git a/cybox/test/objects/domainname_test.py b/cybox/test/objects/domainname_test.py index af1057be..a806b524 100644 --- a/cybox/test/objects/domainname_test.py +++ b/cybox/test/objects/domainname_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.domain_name_object import DomainName from cybox.test.objects import ObjectTestCase @@ -12,7 +14,7 @@ class TestDomainName(ObjectTestCase, unittest.TestCase): klass = DomainName _full_dict = { - 'type': u"FQDN", + 'type': u("FQDN"), 'value': "www.example.com", 'xsi:type': object_type, } diff --git a/cybox/test/objects/email_message_test.py b/cybox/test/objects/email_message_test.py index f03f1570..8dbcd8eb 100644 --- a/cybox/test/objects/email_message_test.py +++ b/cybox/test/objects/email_message_test.py @@ -4,6 +4,8 @@ import datetime import unittest +from six import u + from cybox.common import String, DateTime from cybox.core import Observables from cybox.objects.address_object import Address, EmailAddress @@ -240,7 +242,7 @@ class TestEmailMessage(ObjectTestCase, unittest.TestCase): _full_dict = { #TODO: populate - 'raw_body': u"This has some unicode \ufffd characters", + 'raw_body': u("This has some unicode \ufffd characters"), 'xsi:type': object_type, } diff --git a/cybox/test/objects/file_test.py b/cybox/test/objects/file_test.py index ec90c375..12e164d8 100644 --- a/cybox/test/objects/file_test.py +++ b/cybox/test/objects/file_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.file_object import File, FilePath, Packer, SymLinksList from cybox.common import Hash, String @@ -40,47 +42,47 @@ class TestFile(ObjectTestCase, unittest.TestCase): _full_dict = { 'is_packed': False, 'is_masqueraded': True, - 'file_name': u"example.txt", - 'file_path': {'value': u"C:\\Temp", + 'file_name': u("example.txt"), + 'file_path': {'value': u("C:\\Temp"), 'fully_qualified': True}, - 'device_path': u"\\Device\\CdRom0", - 'full_path': u"C:\\Temp\\example.txt", - 'file_extension': u"txt", + 'device_path': u("\\Device\\CdRom0"), + 'full_path': u("C:\\Temp\\example.txt"), + 'file_extension': u("txt"), 'size_in_bytes': long(1024), - 'magic_number': u"D0CF11E0", - 'file_format': u"ASCII Text", + 'magic_number': u("D0CF11E0"), + 'file_format': u("ASCII Text"), 'hashes': [ { 'type': Hash.TYPE_MD5, - 'simple_hash_value': u"0123456789abcdef0123456789abcdef" + 'simple_hash_value': u("0123456789abcdef0123456789abcdef") } ], 'digital_signatures': [ { - 'certificate_issuer': u"Microsoft", - 'certificate_subject': u"Notepad", + 'certificate_issuer': u("Microsoft"), + 'certificate_subject': u("Notepad"), } ], 'modified_time': "2010-11-06T02:02:02+08:00", 'accessed_time': "2010-11-07T02:03:02+09:00", 'created_time': "2010-11-08T02:04:02+10:00", - 'user_owner': u"sballmer", + 'user_owner': u("sballmer"), 'packer_list': [ { - 'name': u"UPX", - 'version': u"3.91", + 'name': u("UPX"), + 'version': u("3.91"), } ], 'peak_entropy': 7.454352453, - 'sym_links': [u"../link_destination"], - 'byte_runs': [{'offset': 16, 'byte_run_data': u"1A2B3C4D"}], + 'sym_links': [u("../link_destination")], + 'byte_runs': [{'offset': 16, 'byte_run_data': u("1A2B3C4D")}], 'extracted_features': { - 'strings': [{'string_value': u"string from the file"}], + 'strings': [{'string_value': u("string from the file")}], }, - 'encryption_algorithm': u"RC4", - 'compression_method': u"deflate", - 'compression_version': u"1.0", - 'compression_comment': u"This has been compressed", + 'encryption_algorithm': u("RC4"), + 'compression_method': u("deflate"), + 'compression_version': u("1.0"), + 'compression_comment': u("This has been compressed"), 'xsi:type': object_type, } @@ -158,23 +160,23 @@ class TestPacker(EntityTestCase, unittest.TestCase): klass = Packer _full_dict = { - 'name': u"CrazyPack", - 'version': u"2.0.1", - 'entry_point': u"EB0FA192", - 'signature': u"xxCrAzYpAcKxx", - 'type': u"Protector", + 'name': u("CrazyPack"), + 'version': u("2.0.1"), + 'entry_point': u("EB0FA192"), + 'signature': u("xxCrAzYpAcKxx"), + 'type': u("Protector"), 'ep_jump_codes': { 'depth': 2, - 'opcodes': u"A B C" + 'opcodes': u("A B C") }, 'detected_entrypoint_signatures': [ { - 'name': u"test 1", - 'type' : u'type 1' + 'name': u("test 1"), + 'type' : u('type 1') }, { - 'name': u"test 2", - 'type' : u'type 2' + 'name': u("test 2"), + 'type' : u('type 2') } ], } diff --git a/cybox/test/objects/http_session_test.py b/cybox/test/objects/http_session_test.py index 330bcd2c..1dba085c 100644 --- a/cybox/test/objects/http_session_test.py +++ b/cybox/test/objects/http_session_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.address_object import Address from cybox.objects.http_session_object import HTTPSession from cybox.objects.uri_object import URI @@ -18,73 +20,73 @@ class TestHTTPSession(ObjectTestCase, unittest.TestCase): { 'http_client_request': { 'http_request_line': { - 'http_method': u"GET", - 'value': u"/index.html", - 'version': u"http/1.1", + 'http_method': u("GET"), + 'value': u("/index.html"), + 'version': u("http/1.1"), }, 'http_request_header': { - 'raw_header': u"...ALL THE REQUEST HEADERS...", + 'raw_header': u("...ALL THE REQUEST HEADERS..."), 'parsed_header': { - 'accept': u"text/plain", - 'accept_charset': u"utf-8", - 'accept_language': u"en-US", + 'accept': u("text/plain"), + 'accept_charset': u("utf-8"), + 'accept_language': u("en-US"), 'accept_datetime': - u"Thu, 31 May 2007 20:35:00 GMT", - 'accept_encoding': u"gzip, deflate", - 'authorization': u"Basic QWxhZGRbpjpvc", - 'cache_control': u"no-cache", - 'connection': u"keep-alive", - 'cookie': u"$Version=1; Skin=new;", + u("Thu, 31 May 2007 20:35:00 GMT"), + 'accept_encoding': u("gzip, deflate"), + 'authorization': u("Basic QWxhZGRbpjpvc"), + 'cache_control': u("no-cache"), + 'connection': u("keep-alive"), + 'cookie': u("$Version=1; Skin=new;"), 'content_length': 348, - 'content_md5': u"Q2hlY2sgSW50ZWdyaXR5IQ==", - 'content_type': u"application/xml", + 'content_md5': u("Q2hlY2sgSW50ZWdyaXR5IQ=="), + 'content_type': u("application/xml"), 'date': "1994-11-15T08:12:31+00:00", - 'expect': u"200-ok", - 'from': {'address_value': u"bob@example.com", + 'expect': u("200-ok"), + 'from': {'address_value': u("bob@example.com"), 'category': Address.CAT_EMAIL, 'xsi:type': "AddressObjectType"}, 'host': { 'domain_name': { - 'value': u"en.wikipedia.org", + 'value': u("en.wikipedia.org"), 'type': URI.TYPE_DOMAIN, 'xsi:type': "URIObjectType" }, 'port': { 'port_value': 80, - 'layer4_protocol': u"TCP", + 'layer4_protocol': u("TCP"), 'xsi:type': "PortObjectType" } }, 'if_match': - u"737060cd8c284d8af7ad3082f209582d", + u("737060cd8c284d8af7ad3082f209582d"), 'if_modified_since': "1994-10-29T19:43:31+00:00", 'if_none_match': - u"737060cd8c284d8af7ad3082f209582e", + u("737060cd8c284d8af7ad3082f209582e"), 'if_range': - u"737060cd8c284d8af7ad3082f209582f", + u("737060cd8c284d8af7ad3082f209582f"), 'if_unmodified_since': "1996-11-22T09:33:32+00:00", 'max_forwards': 10, - 'pragma': u"no-cache", - 'proxy_authorization': u"Basic QwxhZ==", - 'range': u"bytes=500-999", + 'pragma': u("no-cache"), + 'proxy_authorization': u("Basic QwxhZ=="), + 'range': u("bytes=500-999"), 'referer': { - 'value': u"http://en.wikipedia.org/wiki", + 'value': u("http://en.wikipedia.org/wiki"), 'type': URI.TYPE_URL, 'xsi:type': "URIObjectType", }, - 'te': u"trailers, deflate", - 'user_agent': u"Mozilla/5.0 Firefox/21.0", - 'via': u"1.0 fred, 1.1 example.com", - 'warning': u"199 Miscellaneous warning", - 'dnt': u"1 (Do Not Track Enabled)", - 'x_requested_with': u"XMLHttpRequest", - 'x_forwarded_for': u"client1, proxy1", - 'x_forwarded_proto': u"https", - 'x_att_deviceid': u"MakeModel/Firmware", + 'te': u("trailers, deflate"), + 'user_agent': u("Mozilla/5.0 Firefox/21.0"), + 'via': u("1.0 fred, 1.1 example.com"), + 'warning': u("199 Miscellaneous warning"), + 'dnt': u("1 (Do Not Track Enabled)"), + 'x_requested_with': u("XMLHttpRequest"), + 'x_forwarded_for': u("client1, proxy1"), + 'x_forwarded_proto': u("https"), + 'x_att_deviceid': u("MakeModel/Firmware"), 'x_wap_profile': { - 'value': u"http://samsung.com/SGHI777.xml", + 'value': u("http://samsung.com/SGHI777.xml"), 'type': URI.TYPE_URL, 'xsi:type': "URIObjectType", }, @@ -92,67 +94,67 @@ class TestHTTPSession(ObjectTestCase, unittest.TestCase): }, 'http_message_body': { 'length': 10, - 'message_body': u"Hi there!!", + 'message_body': u("Hi there!!"), } }, }, { 'http_server_response': { 'http_status_line': { - 'version': u"http/1.0", + 'version': u("http/1.0"), 'status_code': 200, - 'reason_phrase': u"OK" + 'reason_phrase': u("OK") }, 'http_response_header': { - 'raw_header': u"...ALL THE RESPONSE HEADERS...", + 'raw_header': u("...ALL THE RESPONSE HEADERS..."), 'parsed_header': { - 'access_control_allow_origin': u"*", - 'accept_ranges': u"bytes", + 'access_control_allow_origin': u("*"), + 'accept_ranges': u("bytes"), 'age': 12, - 'cache_control': u"max-age=3600", - 'connection': u"close", - 'content_encoding': u"gzip", - 'content_language': u"da", + 'cache_control': u("max-age=3600"), + 'connection': u("close"), + 'content_encoding': u("gzip"), + 'content_language': u("da"), 'content_length': 348, - 'content_location': u"/index.htm", - 'content_md5': u"Q2hlY2sgSW50ZWdyaXR5IQ==", - 'content_disposition': u"attachment; filename", - 'content_range': u"bytes 21010-47021", - 'content_type': u"text/html; charset=utf-8", + 'content_location': u("/index.htm"), + 'content_md5': u("Q2hlY2sgSW50ZWdyaXR5IQ=="), + 'content_disposition': u("attachment; filename"), + 'content_range': u("bytes 21010-47021"), + 'content_type': u("text/html; charset=utf-8"), 'date': "1994-11-15T08:12:31+00:00", - 'etag': u'"737060cd8c284d8af7ad3082f20"', + 'etag': u('"737060cd8c284d8af7ad3082f20"'), 'expires': "1994-12-01T16:00:00+00:00", 'last_modified': "1994-11-15T16:00:00+00:00", - 'link': u'1; rel="alternate"', + 'link': u('1; rel="alternate"'), 'location': { - 'value': u"http://www.w3c.org/pub/hi.html", + 'value': u("http://www.w3c.org/pub/hi.html"), 'type': URI.TYPE_URL, 'xsi:type': "URIObjectType", }, - 'p3p': u"CP=\"This is not a P3P policy!\"", - 'pragma': u"no-cache", - 'proxy_authenticate': u"Basic", - 'refresh': u"5", + 'p3p': u("CP=\"This is not a P3P policy!\""), + 'pragma': u("no-cache"), + 'proxy_authenticate': u("Basic"), + 'refresh': u("5"), 'retry_after': 120, - 'server': u"Apache/2.4.1 (Unix)", - 'set_cookie': u"UserID=JohnDoe, Version=1", - 'strict_transport_security': u"max-age=160740", - 'trailer': u"Max-Forwards", - 'transfer_encoding': u"chunked", - 'vary': u"*", - 'via': u"1.0 fred, 1.1 example.com", - 'warning': u"199 Miscellaneous warning", - 'www_authenticate': u"Basic", - 'x_frame_options': u"deny", - 'x_xss_protection': u"1; mode=block", - 'x_content_type_options': u"nosniff", - 'x_powered_by': u"PHP/5.4.0", - 'x_ua_compatible': u"Chrome=1", + 'server': u("Apache/2.4.1 (Unix)"), + 'set_cookie': u("UserID=JohnDoe, Version=1"), + 'strict_transport_security': u("max-age=160740"), + 'trailer': u("Max-Forwards"), + 'transfer_encoding': u("chunked"), + 'vary': u("*"), + 'via': u("1.0 fred, 1.1 example.com"), + 'warning': u("199 Miscellaneous warning"), + 'www_authenticate': u("Basic"), + 'x_frame_options': u("deny"), + 'x_xss_protection': u("1; mode=block"), + 'x_content_type_options': u("nosniff"), + 'x_powered_by': u("PHP/5.4.0"), + 'x_ua_compatible': u("Chrome=1"), } }, 'http_message_body': { 'length': 26, - 'message_body': u"", + 'message_body': u(""), } }, }, @@ -166,7 +168,7 @@ def test_object_reference(self, ref_dict=None): sess_dict = { 'http_request_response': [{ 'http_client_request': { - 'http_request_line': {'http_method': u"GET"} + 'http_request_line': {'http_method': u("GET")} } }] } diff --git a/cybox/test/objects/image_file_test.py b/cybox/test/objects/image_file_test.py index 0c7abb0e..dc6fae37 100644 --- a/cybox/test/objects/image_file_test.py +++ b/cybox/test/objects/image_file_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.image_file_object import ImageFile from cybox.common import Hash, String @@ -17,55 +19,55 @@ class TestImageFile(ObjectTestCase, unittest.TestCase): _full_dict = { 'image_is_compressed': True, - 'image_file_format': u"JPG", + 'image_file_format': u("JPG"), 'image_height': 10000, 'image_width': 3000, 'bits_per_pixel': 9000, - 'compression_algorithm': u"An algorithm", + 'compression_algorithm': u("An algorithm"), 'is_packed': False, 'is_masqueraded': True, - 'file_name': u"example.txt", - 'file_path': {'value': u"C:\\Temp", + 'file_name': u("example.txt"), + 'file_path': {'value': u("C:\\Temp"), 'fully_qualified': True}, - 'device_path': u"\\Device\\CdRom0", - 'full_path': u"C:\\Temp\\example.txt", - 'file_extension': u"txt", + 'device_path': u("\\Device\\CdRom0"), + 'full_path': u("C:\\Temp\\example.txt"), + 'file_extension': u("txt"), 'size_in_bytes': long(1024), - 'magic_number': u"D0CF11E0", - 'file_format': u"ASCII Text", + 'magic_number': u("D0CF11E0"), + 'file_format': u("ASCII Text"), 'hashes': [ { 'type': Hash.TYPE_MD5, - 'simple_hash_value': u"0123456789abcdef0123456789abcdef" + 'simple_hash_value': u("0123456789abcdef0123456789abcdef") } ], 'digital_signatures': [ { - 'certificate_issuer': u"Microsoft", - 'certificate_subject': u"Notepad", + 'certificate_issuer': u("Microsoft"), + 'certificate_subject': u("Notepad"), } ], 'modified_time': "2010-11-06T02:02:02+08:00", 'accessed_time': "2010-11-07T02:03:02+09:00", 'created_time': "2010-11-08T02:04:02+10:00", - 'user_owner': u"sballmer", + 'user_owner': u("sballmer"), 'packer_list': [ { - 'name': u"UPX", - 'version': u"3.91", + 'name': u("UPX"), + 'version': u("3.91"), } ], 'peak_entropy': 7.454352453, - 'sym_links': [u"../link_destination"], - 'byte_runs': [{'offset': 16, 'byte_run_data': u"1A2B3C4D"}], + 'sym_links': [u("../link_destination")], + 'byte_runs': [{'offset': 16, 'byte_run_data': u("1A2B3C4D")}], 'extracted_features': { - 'strings': [{'string_value': u"string from the file"}], + 'strings': [{'string_value': u("string from the file")}], }, - 'encryption_algorithm': u"RC4", - 'compression_method': u"deflate", - 'compression_version': u"1.0", - 'compression_comment': u"This has been compressed", + 'encryption_algorithm': u("RC4"), + 'compression_method': u("deflate"), + 'compression_version': u("1.0"), + 'compression_comment': u("This has been compressed"), 'xsi:type': object_type, } diff --git a/cybox/test/objects/memory_test.py b/cybox/test/objects/memory_test.py index 37825df7..c4fd1e32 100644 --- a/cybox/test/objects/memory_test.py +++ b/cybox/test/objects/memory_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.memory_object import Memory from cybox.compat import long @@ -23,14 +25,14 @@ class TestMemory(ObjectTestCase, unittest.TestCase): 'is_mapped': False, 'is_protected': True, 'is_volatile': False, - 'hashes': [{'type': u"MD5", 'simple_hash_value': EMPTY_MD5}], - 'name': u"A memory region", + 'hashes': [{'type': u("MD5"), 'simple_hash_value': EMPTY_MD5}], + 'name': u("A memory region"), 'region_size': long(65536), - 'memory_source': u".data", - 'block_type': u"Free", - 'region_start_address': u"00040000", - 'region_end_address': u"00048000", - 'extracted_features': {'functions': [u"StringA", u"StringB"]}, + 'memory_source': u(".data"), + 'block_type': u("Free"), + 'region_start_address': u("00040000"), + 'region_end_address': u("00048000"), + 'extracted_features': {'functions': [u("StringA"), u("StringB")]}, 'xsi:type': object_type, } diff --git a/cybox/test/objects/network_connection_test.py b/cybox/test/objects/network_connection_test.py index 66175d83..4866dfd0 100644 --- a/cybox/test/objects/network_connection_test.py +++ b/cybox/test/objects/network_connection_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.address_object import Address from cybox.objects.network_connection_object import (Layer7Connections, NetworkConnection) @@ -17,37 +19,37 @@ class TestNetworkConnection(ObjectTestCase, unittest.TestCase): _full_dict = { 'tls_used': False, 'creation_time': "2013-07-30T02:02:02+04:00", - 'layer3_protocol': u"IPV4", - 'layer4_protocol': u"TCP", - 'layer7_protocol': u"HTTP", + 'layer3_protocol': u("IPV4"), + 'layer4_protocol': u("TCP"), + 'layer7_protocol': u("HTTP"), 'source_socket_address': { 'ip_address': { 'category': Address.CAT_IPV4, - 'address_value': u"192.168.1.1", + 'address_value': u("192.168.1.1"), 'xsi:type': "AddressObjectType", }, 'port': { 'port_value': 4567, - 'layer4_protocol': u"TCP", + 'layer4_protocol': u("TCP"), 'xsi:type': "PortObjectType", }, 'xsi:type': "SocketAddressObjectType", }, - 'source_tcp_state': u"UNKNOWN", + 'source_tcp_state': u("UNKNOWN"), 'destination_socket_address': { 'ip_address': { 'category': Address.CAT_IPV4, - 'address_value': u"192.168.1.50", + 'address_value': u("192.168.1.50"), 'xsi:type': "AddressObjectType", }, 'port': { 'port_value': 80, - 'layer4_protocol': u"TCP", + 'layer4_protocol': u("TCP"), 'xsi:type': "PortObjectType", }, 'xsi:type': "SocketAddressObjectType", }, - 'destination_tcp_state': u"UNKNOWN", + 'destination_tcp_state': u("UNKNOWN"), 'layer7_connections': { 'http_session': { 'object_reference': "example:ABC-1", @@ -79,11 +81,11 @@ class TestLayer7Connections(EntityTestCase, unittest.TestCase): { 'question': { 'qname': { - 'value': u"www.example.com", + 'value': u("www.example.com"), 'xsi:type': "URIObjectType", }, - 'qtype': u"A", - 'qclass': u"IN", + 'qtype': u("A"), + 'qclass': u("IN"), }, 'successful': True, 'xsi:type': "DNSQueryObjectType", @@ -91,10 +93,10 @@ class TestLayer7Connections(EntityTestCase, unittest.TestCase): { 'question': { 'qname': { - 'value': u"www.example2.com", + 'value': u("www.example2.com"), 'xsi:type': "URIObjectType", }, - 'qtype': u"CNAME", + 'qtype': u("CNAME"), }, 'successful': False, 'xsi:type': "DNSQueryObjectType", diff --git a/cybox/test/objects/network_packet_test.py b/cybox/test/objects/network_packet_test.py index 367b4b56..89530f8e 100644 --- a/cybox/test/objects/network_packet_test.py +++ b/cybox/test/objects/network_packet_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.bindings.cybox_core import parseString from cybox.core import Observables from cybox.objects.address_object import Address @@ -62,15 +64,15 @@ class TestEthernetInterface(EntityTestCase, unittest.TestCase): _full_dict = { 'ethernet_header': { - 'destination_mac_addr': {'address_value': u"00:11:22:33:44:55", + 'destination_mac_addr': {'address_value': u("00:11:22:33:44:55"), 'category': Address.CAT_MAC, 'xsi:type': 'AddressObjectType'}, - 'source_mac_addr': {'address_value': u"aa:bb:cc:dd:ee:ff", + 'source_mac_addr': {'address_value': u("aa:bb:cc:dd:ee:ff"), 'category': Address.CAT_MAC, 'xsi:type': 'AddressObjectType'}, - 'type_or_length': {'length': u"1abf", - 'internet_layer_type': u"IPv4(0x0800)"}, - 'checksum': u"fa10", + 'type_or_length': {'length': u("1abf"), + 'internet_layer_type': u("IPv4(0x0800)")}, + 'checksum': u("fa10"), } } @@ -79,21 +81,21 @@ class TestARP(EntityTestCase, unittest.TestCase): klass = ARP _full_dict = { - 'hardware_addr_type': u"Ethernet(1)", - 'proto_addr_type': u"IPv4(0x0800)", - 'hardware_addr_size': u"6", - 'proto_addr_size': u"4", - 'op_type': u"ARP request(1)", - 'sender_hardware_addr': {'address_value': u"01:12:23:34:45:56", + 'hardware_addr_type': u("Ethernet(1)"), + 'proto_addr_type': u("IPv4(0x0800)"), + 'hardware_addr_size': u("6"), + 'proto_addr_size': u("4"), + 'op_type': u("ARP request(1)"), + 'sender_hardware_addr': {'address_value': u("01:12:23:34:45:56"), 'category': Address.CAT_MAC, 'xsi:type': 'AddressObjectType'}, - 'sender_protocol_addr': {'address_value': u"1.2.3.4", + 'sender_protocol_addr': {'address_value': u("1.2.3.4"), 'category': Address.CAT_IPV4, 'xsi:type': 'AddressObjectType'}, - 'recip_hardware_addr': {'address_value': u"a0:b0:c0:d0:e0:f0", + 'recip_hardware_addr': {'address_value': u("a0:b0:c0:d0:e0:f0"), 'category': Address.CAT_MAC, 'xsi:type': 'AddressObjectType'}, - 'recip_protocol_addr': {'address_value': u"9.10.11.12", + 'recip_protocol_addr': {'address_value': u("9.10.11.12"), 'category': Address.CAT_IPV4, 'xsi:type': 'AddressObjectType'}, } @@ -103,7 +105,7 @@ class TestNDPLinkAddr(EntityTestCase, unittest.TestCase): klass = NDPLinkAddr _full_dict = { 'length': 14, - 'link_layer_mac_addr': {'address_value': u"80:70:60:50:40:30", + 'link_layer_mac_addr': {'address_value': u("80:70:60:50:40:30"), 'category': Address.CAT_MAC, 'xsi:type': 'AddressObjectType'}, } @@ -120,10 +122,10 @@ class TestNDPPrefixInfo(EntityTestCase, unittest.TestCase): 'valid_lifetime': 123455, 'preferred_lifetime': 1000, 'prefix': { - 'ipv6_addr': {'address_value': u"2001:db8::ff00:42:832", + 'ipv6_addr': {'address_value': u("2001:db8::ff00:42:832"), 'category': Address.CAT_IPV6, 'xsi:type': 'AddressObjectType'}, - 'ip_addr_prefix': {'address_value': u"2001:0db8:85a3", + 'ip_addr_prefix': {'address_value': u("2001:0db8:85a3"), 'category': Address.CAT_IPV6, 'xsi:type': 'AddressObjectType'}, } @@ -135,9 +137,9 @@ class TestNDP(EntityTestCase, unittest.TestCase): _full_dict = { 'icmpv6_header': { - 'type': u"01", - 'code': u"07", - 'checksum': u"06BC", + 'type': u("01"), + 'code': u("07"), + 'checksum': u("06BC"), }, # This is normally a choice, but we can currently just check # them all at once. For X_link_addr, we are checking them above, @@ -158,7 +160,7 @@ class TestNDP(EntityTestCase, unittest.TestCase): } }, 'neighbor_solicitation': { - 'target_ipv6_addr': {'address_value': u"2001:db99::ff00:832", + 'target_ipv6_addr': {'address_value': u("2001:db99::ff00:832"), 'category': Address.CAT_IPV6, 'xsi:type': 'AddressObjectType'}, 'options': {'src_link_addr': {'length': 99}}, @@ -167,16 +169,16 @@ class TestNDP(EntityTestCase, unittest.TestCase): 'router_flag': True, 'solicited_flag': False, 'override_flag': True, - 'target_ipv6_addr': {'address_value': u"::1", + 'target_ipv6_addr': {'address_value': u("::1"), 'category': Address.CAT_IPV6, 'xsi:type': 'AddressObjectType'}, 'options': {'target_link_addr': {'length': 48}}, }, 'redirect': { - 'target_ipv6_addr': {'address_value': u"2001::1", + 'target_ipv6_addr': {'address_value': u("2001::1"), 'category': Address.CAT_IPV6, 'xsi:type': 'AddressObjectType'}, - 'dest_ipv6_addr': {'address_value': u"2001::dd88:1", + 'dest_ipv6_addr': {'address_value': u("2001::dd88:1"), 'category': Address.CAT_IPV6, 'xsi:type': 'AddressObjectType'}, 'options': { @@ -195,33 +197,33 @@ class TestIPv4Packet(EntityTestCase, unittest.TestCase): _full_dict = { 'ipv4_header': { - 'ip_version': u"IPv4(4)", + 'ip_version': u("IPv4(4)"), 'header_length': 32, - 'dscp': u"5fc1", - 'ecn': u"4ca6", - 'total_length': u"ffff", + 'dscp': u("5fc1"), + 'ecn': u("4ca6"), + 'total_length': u("ffff"), 'identification': 10, 'flags': { 'reserved': 0, - 'do_not_fragment': u"donotfragment(1)", - 'more_fragments': u"lastfragment(0)", + 'do_not_fragment': u("donotfragment(1)"), + 'more_fragments': u("lastfragment(0)"), }, - 'fragment_offset': u"7c", - 'ttl': u"fa", - 'protocol': u"TPC(6)", - 'checksum': u"0fca", - 'src_ipv4_addr': {'address_value': u"172.16.21.50", + 'fragment_offset': u("7c"), + 'ttl': u("fa"), + 'protocol': u("TPC(6)"), + 'checksum': u("0fca"), + 'src_ipv4_addr': {'address_value': u("172.16.21.50"), 'category': Address.CAT_IPV4, 'xsi:type': 'AddressObjectType'}, - 'dest_ipv4_addr': {'address_value': u"172.16.21.1", + 'dest_ipv4_addr': {'address_value': u("172.16.21.1"), 'category': Address.CAT_IPV4, 'xsi:type': 'AddressObjectType'}, 'option': [ - {'copy_flag': u"donotcopy(0)", 'class': u"control(0)"}, - {'class': u"reserved(3)", 'option': u"security(2)"}, + {'copy_flag': u("donotcopy(0)"), 'class': u("control(0)")}, + {'class': u("reserved(3)"), 'option': u("security(2)")}, ] }, - 'data': u"04fc3a3f67e4", + 'data': u("04fc3a3f67e4"), } @@ -230,8 +232,8 @@ class TestICMPv4(EntityTestCase, unittest.TestCase): _full_dict = { 'icmpv4_header': { - 'type': u"02", - 'code': u"06", 'checksum': u"06BC", }, + 'type': u("02"), + 'code': u("06"), 'checksum': u("06BC"), }, 'error_msg': { 'destination_unreachable': { 'destination_network_unreachable': True, @@ -240,7 +242,7 @@ class TestICMPv4(EntityTestCase, unittest.TestCase): 'destination_port_unreachable': True, 'fragmentation_required': { 'fragmentation_required': True, - 'next_hop_mtu': u"a150", + 'next_hop_mtu': u("a150"), }, 'source_route_failed': True, 'destination_network_unknown': True, @@ -262,7 +264,7 @@ class TestICMPv4(EntityTestCase, unittest.TestCase): 'host_redirect': True, 'tos_network_redirect': True, 'tos_host_redirect': True, - 'ip_address': {'address_value': u"10.3.4.5", + 'ip_address': {'address_value': u("10.3.4.5"), 'category': Address.CAT_IPV4, 'xsi:type': 'AddressObjectType'}, }, @@ -271,18 +273,18 @@ class TestICMPv4(EntityTestCase, unittest.TestCase): 'frag_reassembly_time_exceeded': True, }, 'error_msg_content': { - 'ip_header': {'ip_version': u"IPv4(4)"}, - 'first_eight_bytes': u"0123456789abcdef", + 'ip_header': {'ip_version': u("IPv4(4)")}, + 'first_eight_bytes': u("0123456789abcdef"), }, }, 'info_msg': { 'echo_reply': { 'echo_reply': True, - 'data': u"5f3dce41" + 'data': u("5f3dce41") }, 'echo_request': { 'echo_request': True, - 'data': u"14ecd3f5" + 'data': u("14ecd3f5") }, 'timestamp_request': { 'timestamp': True, @@ -296,29 +298,29 @@ class TestICMPv4(EntityTestCase, unittest.TestCase): }, 'address_mask_request': { 'address_mask_request': True, - 'address_mask': {'address_value': u"255.255.0.0", + 'address_mask': {'address_value': u("255.255.0.0"), 'category': Address.CAT_IPV4_NETMASK, 'xsi:type': 'AddressObjectType'}, }, 'address_mask_reply': { 'address_mask_reply': True, - 'address_mask': {'address_value': u"255.255.255.0", + 'address_mask': {'address_value': u("255.255.255.0"), 'category': Address.CAT_IPV4_NETMASK, 'xsi:type': 'AddressObjectType'}, }, 'info_msg_content': { - 'identifier': u"f198", - 'sequence_number': u"1dc9", + 'identifier': u("f198"), + 'sequence_number': u("1dc9"), }, }, 'traceroute': { 'outbound_packet_forward_success': True, 'outbound_packet_no_route': True, - 'identifier': u"1234", - 'outbound_hop_count': u"001f", - 'return_hop_count': u"001c", - 'output_link_speed': u"000f42f0", - 'output_link_mtu': u"00000000", + 'identifier': u("1234"), + 'outbound_hop_count': u("001f"), + 'return_hop_count': u("001c"), + 'output_link_speed': u("000f42f0"), + 'output_link_mtu': u("00000000"), }, } @@ -328,103 +330,103 @@ class TestIPv6(EntityTestCase, unittest.TestCase): _full_dict = { 'ipv6_header': { - 'ip_version': u"IPv6(6)", - 'traffic_class': u"ff", - 'flow_label': u"abcde", - 'payload_length': u"1000", - 'next_header': u"TCP(6)", + 'ip_version': u("IPv6(6)"), + 'traffic_class': u("ff"), + 'flow_label': u("abcde"), + 'payload_length': u("1000"), + 'next_header': u("TCP(6)"), 'ttl': 128, - 'src_ipv6_addr': {'address_value': u"2001:85a3::8a2e:370:734", + 'src_ipv6_addr': {'address_value': u("2001:85a3::8a2e:370:734"), 'category': Address.CAT_IPV6, 'xsi:type': 'AddressObjectType'}, - 'dest_ipv6_addr': {'address_value': u"2001:3a58::8a2e:370:734", + 'dest_ipv6_addr': {'address_value': u("2001:3a58::8a2e:370:734"), 'category': Address.CAT_IPV6, 'xsi:type': 'AddressObjectType'}, }, 'ext_headers': [ { 'hop_by_hop_options': { - 'next_header': u"IPv6routingheader(43)", - 'header_ext_len': u"1f", + 'next_header': u("IPv6routingheader(43)"), + 'header_ext_len': u("1f"), 'option_data': [ { 'option_type': { - 'do_not_recogn_action': u"skipoption(00)", - 'packet_change': u"change(1)", - 'option_byte': u"04", + 'do_not_recogn_action': u("skipoption(00)"), + 'packet_change': u("change(1)"), + 'option_byte': u("04"), }, - 'option_data_len': u"0100", - 'pad1': {'octet': u"00"}, - 'padn': {'octet': u"01", + 'option_data_len': u("0100"), + 'pad1': {'octet': u("00")}, + 'padn': {'octet': u("01"), 'option_data_length': 42, 'option_data': 00} }, { - 'option_type': {'option_byte': u"02"}, - 'option_data_len': u"007f", - 'pad1': {'octet': u"00"}, + 'option_type': {'option_byte': u("02")}, + 'option_data_len': u("007f"), + 'pad1': {'octet': u("00")}, }, ] }, }, { 'routing': { - 'next_header': u"IPv6routingheader(43)", + 'next_header': u("IPv6routingheader(43)"), 'header_ext_len': 32, - 'routing_type': u"4a", + 'routing_type': u("4a"), 'segments_left': 13, - 'type_specific_data': u"AAAAAAAA" + 'type_specific_data': u("AAAAAAAA") }, }, { 'fragment': { 'fragment_header': { - 'next_header': u"IPv6routingheader(43)", - 'fragment_offset': u"01fb", - 'm_flag': u"lastfragment(0)", - 'identification': u"aa", + 'next_header': u("IPv6routingheader(43)"), + 'fragment_offset': u("01fb"), + 'm_flag': u("lastfragment(0)"), + 'identification': u("aa"), }, - 'fragment': u"bc27648fbace" + 'fragment': u("bc27648fbace") }, }, { 'destination_options': [ { - 'next_header': u"IPv6routingheader(43)", - 'header_ext_len': u"1f", + 'next_header': u("IPv6routingheader(43)"), + 'header_ext_len': u("1f"), 'option_data': [ { - 'option_data_len': u"0100", - 'pad1': {'octet': u"00"}, + 'option_data_len': u("0100"), + 'pad1': {'octet': u("00")}, }, { - 'option_type': {'option_byte': u"02"}, + 'option_type': {'option_byte': u("02")}, }, ] }, { - 'header_ext_len': u"1f", + 'header_ext_len': u("1f"), }, ], }, { 'authentication_header': { - 'next_header': u"IPv6routingheader(43)", - 'header_ext_len': u"1f", - 'security_parameters_index': u"deadbeef", - 'sequence_number': u"feedbacc", - 'authentication_data': u"abcd0123fedc4567", + 'next_header': u("IPv6routingheader(43)"), + 'header_ext_len': u("1f"), + 'security_parameters_index': u("deadbeef"), + 'sequence_number': u("feedbacc"), + 'authentication_data': u("abcd0123fedc4567"), }, }, { 'encapsulating_security_payload': { - 'security_parameters_index': u"deadbeef", - 'sequence_number': u"feedbacc", - 'payload_data': u"777788889999aaaa", - 'padding': u"0000000", - 'padding_len': u"7", - 'next_header': u"IPv6routingheader(43)", - 'authentication_data': u"abcd0123fedc4567", + 'security_parameters_index': u("deadbeef"), + 'sequence_number': u("feedbacc"), + 'payload_data': u("777788889999aaaa"), + 'padding': u("0000000"), + 'padding_len': u("7"), + 'next_header': u("IPv6routingheader(43)"), + 'authentication_data': u("abcd0123fedc4567"), }, }, ], @@ -436,9 +438,9 @@ class TestICMPv6(EntityTestCase, unittest.TestCase): _full_dict = { 'icmpv6_header': { - 'type': u"02", - 'code': u"06", - 'checksum': u"06BC", + 'type': u("02"), + 'code': u("06"), + 'checksum': u("06BC"), }, 'error_msg': { 'destination_unreachable': { @@ -452,7 +454,7 @@ class TestICMPv6(EntityTestCase, unittest.TestCase): }, 'packet_too_big': { 'packet_too_big': True, - 'mtu': u"1f00", + 'mtu': u("1f00"), }, 'time_exceeded': { 'hop_limit_exceeded': True, @@ -462,22 +464,22 @@ class TestICMPv6(EntityTestCase, unittest.TestCase): 'erroneous_header_field': True, 'unrecognized_next_header_type': True, 'unrecognized_ipv6_option': True, - 'pointer': u"7fffaabb", + 'pointer': u("7fffaabb"), }, - 'invoking_packet': u"0f1e2d3c4b5a9687", + 'invoking_packet': u("0f1e2d3c4b5a9687"), }, 'info_msg': { 'echo_request': { 'echo_request': True, - 'data': u"2468ace0" + 'data': u("2468ace0") }, 'echo_reply': { 'echo_reply': True, - 'data': u"0eca8642" + 'data': u("0eca8642") }, 'info_msg_content': { - 'identifier': u"f198", - 'sequence_number': u"1dc9", + 'identifier': u("f198"), + 'sequence_number': u("1dc9"), }, }, } @@ -489,15 +491,15 @@ class TestTCP(EntityTestCase, unittest.TestCase): _full_dict = { 'tcp_header': { 'src_port': {'port_value': 1444, - 'layer4_protocol': u'TCP', + 'layer4_protocol': u('TCP'), 'xsi:type': 'PortObjectType'}, 'dest_port': {'port_value': 80, - 'layer4_protocol': u'TCP', + 'layer4_protocol': u('TCP'), 'xsi:type': 'PortObjectType'}, - 'seq_num': u"148f3b44", - 'ack_num': u"664d012a", - 'data_offset': u"20", - 'reserved': u"0", + 'seq_num': u("148f3b44"), + 'ack_num': u("664d012a"), + 'data_offset': u("20"), + 'reserved': u("0"), 'tcp_flags': { 'ns': True, 'cwr': True, @@ -509,15 +511,15 @@ class TestTCP(EntityTestCase, unittest.TestCase): 'syn': True, 'fin': True, }, - 'window': u"1460", - 'checksum': u"1fc1", - 'urg_ptr': u"0001" + 'window': u("1460"), + 'checksum': u("1fc1"), + 'urg_ptr': u("0001") }, - 'options': u"010305", + 'options': u("010305"), 'data': { 'data_format': "Text", - 'data_size': {"value": u"100", 'units': "Kilobytes"}, - 'data_segment': u"A long, long time ago...", + 'data_size': {"value": u("100"), 'units': "Kilobytes"}, + 'data_segment': u("A long, long time ago..."), 'offset': 100, 'search_distance': 200, 'search_within': 40, @@ -531,18 +533,18 @@ class TestUDP(EntityTestCase, unittest.TestCase): _full_dict = { 'udp_header': { 'srcport': {'port_value': 1664, - 'layer4_protocol': u'UDP', + 'layer4_protocol': u('UDP'), 'xsi:type': 'PortObjectType'}, 'destport': {'port_value': 53, - 'layer4_protocol': u'UDP', + 'layer4_protocol': u('UDP'), 'xsi:type': 'PortObjectType'}, 'length': 0x18, - 'checksum': u"1fc1", + 'checksum': u("1fc1"), }, 'data': { 'data_format': "Hex", - 'data_size': {"value": u"16", 'units': "Bytes"}, - 'data_segment': u"000102030405060708090a0b0c0d0e0f", + 'data_size': {"value": u("16"), 'units': "Bytes"}, + 'data_segment': u("000102030405060708090a0b0c0d0e0f"), } } diff --git a/cybox/test/objects/network_route_entry_test.py b/cybox/test/objects/network_route_entry_test.py index 57577692..1df79930 100644 --- a/cybox/test/objects/network_route_entry_test.py +++ b/cybox/test/objects/network_route_entry_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.network_route_entry_object import NetworkRouteEntry from cybox.compat import long @@ -21,25 +23,25 @@ class TestNetworkRouteEntry(ObjectTestCase, unittest.TestCase): 'is_loopback': False, 'is_publish': True, 'destination_address': { - 'address_value': u"1.2.3.4", + 'address_value': u("1.2.3.4"), 'xsi:type': 'AddressObjectType' }, 'origin': { - 'address_value': u"1.2.3.4", + 'address_value': u("1.2.3.4"), 'xsi:type': 'AddressObjectType' }, 'netmask': { - 'address_value': u"1.2.3.4", + 'address_value': u("1.2.3.4"), 'xsi:type': 'AddressObjectType' }, 'gateway_address': { - 'address_value': u"1.2.3.4", + 'address_value': u("1.2.3.4"), 'xsi:type': 'AddressObjectType' }, 'metric': long(1234), - 'type': u"A type", - 'protocol': u"A protocol", - 'interface': u"An interface", + 'type': u("A type"), + 'protocol': u("A protocol"), + 'interface': u("An interface"), #'preferred_lifetime' = cybox.TypedField("Preferred_Lifetime", Duration) #'valid_lifetime' = cybox.TypedField("Valid_Lifetime", Duration) #'route_age' = cybox.TypedField("Route_Age", Duration) diff --git a/cybox/test/objects/network_socket_test.py b/cybox/test/objects/network_socket_test.py index fa0c3952..0c92b3bf 100644 --- a/cybox/test/objects/network_socket_test.py +++ b/cybox/test/objects/network_socket_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.network_socket_object import NetworkSocket, SocketOptions from cybox.test import EntityTestCase from cybox.test.objects import ObjectTestCase @@ -12,10 +14,10 @@ class TestSocketOptions(EntityTestCase, unittest.TestCase): klass = SocketOptions _full_dict = { - 'ip_multicast_if': u"eth1", # Should probably be a boolean - 'ip_multicast_if2': u"wlan0", # Should probably be a boolean + 'ip_multicast_if': u("eth1"), # Should probably be a boolean + 'ip_multicast_if2': u("wlan0"), # Should probably be a boolean 'ip_multicast_loop': False, - 'ip_tos': u"true", # Should probably be a boolean + 'ip_tos': u("true"), # Should probably be a boolean 'so_broadcast': False, 'so_conditional_accept': True, 'so_keepalive': False, @@ -43,20 +45,20 @@ class TestNetworkSocket(ObjectTestCase, unittest.TestCase): _full_dict = { 'is_blocking': False, 'is_listening': True, - 'address_family': u"AF_INET", - 'domain': u"PF_INET", + 'address_family': u("AF_INET"), + 'domain': u("PF_INET"), 'local_address': { 'ip_address': { - 'address_value': u"192.168.1.4", + 'address_value': u("192.168.1.4"), 'xsi:type': "AddressObjectType", }, 'xsi:type': "SocketAddressObjectType", }, 'options': {'so_broadcast': False}, - 'protocol': u"IPPROTO_TCP", + 'protocol': u("IPPROTO_TCP"), 'remote_address': { 'ip_address': { - 'address_value': u"192.168.100.55", + 'address_value': u("192.168.100.55"), 'xsi:type': "AddressObjectType", }, 'port': { @@ -65,7 +67,7 @@ class TestNetworkSocket(ObjectTestCase, unittest.TestCase): }, 'xsi:type': "SocketAddressObjectType", }, - 'type': u"SOCK_STREAM", + 'type': u("SOCK_STREAM"), 'socket_descriptor': 567, 'xsi:type': object_type, } diff --git a/cybox/test/objects/socket_address_test.py b/cybox/test/objects/socket_address_test.py index 49f6691a..f03bd3fd 100644 --- a/cybox/test/objects/socket_address_test.py +++ b/cybox/test/objects/socket_address_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.address_object import Address from cybox.objects.socket_address_object import SocketAddress import cybox.test @@ -18,17 +20,17 @@ class TestSocketAddress(ObjectTestCase, unittest.TestCase): # but we don't enforce that, so we can test both here. 'ip_address': { 'category': Address.CAT_IPV4, - 'address_value': u"192.168.1.1", + 'address_value': u("192.168.1.1"), 'xsi:type': "AddressObjectType" }, 'hostname': { 'is_domain_name': True, - 'hostname_value': u"www.example.com", + 'hostname_value': u("www.example.com"), 'xsi:type': "HostnameObjectType" }, 'port': { 'port_value': 80, - 'layer4_protocol': u"TCP", + 'layer4_protocol': u("TCP"), 'xsi:type': "PortObjectType" }, 'xsi:type': object_type, diff --git a/cybox/test/objects/uri_test.py b/cybox/test/objects/uri_test.py index 3291b154..02efd0cd 100644 --- a/cybox/test/objects/uri_test.py +++ b/cybox/test/objects/uri_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.common import AnyURI from cybox.objects.uri_object import URI import cybox.test @@ -20,20 +22,20 @@ class TestURI(ObjectTestCase, unittest.TestCase): } def test_round_trip(self): - u = "http://www.example.com" + uri_str = "http://www.example.com" t = URI.TYPE_URL - uri = URI(AnyURI(u), t) + uri = URI(AnyURI(uri_str), t) uri2 = cybox.test.round_trip(uri) self.assertEqual(uri.to_dict(), uri2.to_dict()) - self.assertEqual(u, str(uri2)) + self.assertEqual(uri_str, str(uri2)) self.assertEqual(t, uri2.type_) def test_unicode(self): - u = u"www.\u0395\u03a7\u0391\u039c\u03a1LE.com" - uri = URI(u, URI.TYPE_DOMAIN) + unicode_uri = u("www.\u0395\u03a7\u0391\u039c\u03a1LE.com") + uri = URI(unicode_uri, URI.TYPE_DOMAIN) uri2 = cybox.test.round_trip(uri) self.assertEqual(uri.to_dict(), uri2.to_dict()) diff --git a/cybox/test/objects/user_account_test.py b/cybox/test/objects/user_account_test.py index f8c51323..c07329dc 100644 --- a/cybox/test/objects/user_account_test.py +++ b/cybox/test/objects/user_account_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.user_account_object import UserAccount from cybox.test.objects import ObjectTestCase @@ -15,18 +17,18 @@ class TestUserAccount(ObjectTestCase, unittest.TestCase): # Account-specific fields 'disabled': False, 'locked_out': True, - 'description': u'An account', - 'domain': u'ADMIN', + 'description': u('An account'), + 'domain': u('ADMIN'), # UserAccount-specific fields # (cannot test group_list of privilege_list since # they are abstract) 'password_required': True, - 'full_name': u"Guido van Rossum", - 'home_directory': u"/home/guido/", + 'full_name': u("Guido van Rossum"), + 'home_directory': u("/home/guido/"), 'last_login': "2001-01-01T06:56:50+04:00", - 'script_path': u"/bin/bash", - 'username': u"guido", - 'user_password_age': u"P90D", + 'script_path': u("/bin/bash"), + 'username': u("guido"), + 'user_password_age': u("P90D"), 'xsi:type': object_type, } diff --git a/cybox/test/objects/win_computer_account_test.py b/cybox/test/objects/win_computer_account_test.py index bb8a02fd..1780f0d9 100644 --- a/cybox/test/objects/win_computer_account_test.py +++ b/cybox/test/objects/win_computer_account_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.compat import long from cybox.objects.win_computer_account_object import WinComputerAccount from cybox.test.objects import ObjectTestCase @@ -13,11 +15,11 @@ class TestWinCriticalSection(ObjectTestCase, unittest.TestCase): klass = WinComputerAccount _full_dict = { - 'security_id': u"An ID", - 'type': u"A type", + 'security_id': u("An ID"), + 'type': u("A type"), 'fully_qualified_name': { - 'netbeui_name': u"A NetBEUI name", - 'full_name': u"A full name" + 'netbeui_name': u("A NetBEUI name"), + 'full_name': u("A full name") }, 'kerberos': { 'ticket': long(9000), diff --git a/cybox/test/objects/win_critical_section_test.py b/cybox/test/objects/win_critical_section_test.py index 058e9c96..ac526788 100644 --- a/cybox/test/objects/win_critical_section_test.py +++ b/cybox/test/objects/win_critical_section_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.win_critical_section_object import WinCriticalSection from cybox.test.objects import ObjectTestCase @@ -12,7 +14,7 @@ class TestWinCriticalSection(ObjectTestCase, unittest.TestCase): klass = WinCriticalSection _full_dict = { - 'address': u"deadbeef", + 'address': u("deadbeef"), 'spin_count': 12345, 'xsi:type': object_type } diff --git a/cybox/test/objects/win_file_test.py b/cybox/test/objects/win_file_test.py index 6b55f560..ae33acb1 100644 --- a/cybox/test/objects/win_file_test.py +++ b/cybox/test/objects/win_file_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.compat import long from cybox.objects.win_file_object import WinFile, Stream from cybox.test.common.hash_test import EMPTY_MD5 @@ -12,9 +14,9 @@ class TestStream(EntityTestCase, unittest.TestCase): klass = Stream - _full_dict = {'hashes': [{'type': u"MD5", + _full_dict = {'hashes': [{'type': u("MD5"), 'simple_hash_value': EMPTY_MD5}], - 'name': u"StreamB", + 'name': u("StreamB"), 'size_in_bytes': 204} @@ -24,26 +26,26 @@ class TestWinFile(ObjectTestCase, unittest.TestCase): _full_dict = { # File fields (only a few are included) - 'file_name': u"example.doc", - 'full_path': u"C:\\Temp\\example.doc", - 'file_extension': u"doc", + 'file_name': u("example.doc"), + 'full_path': u("C:\\Temp\\example.doc"), + 'file_extension': u("doc"), 'size_in_bytes': long(1024), - 'magic_number': u"D0CF11E0", + 'magic_number': u("D0CF11E0"), # WinFile-specific fields 'filename_accessed_time': "2012-05-12T07:14:02+07:00", 'filename_created_time': "2012-05-17T09:28:04+07:00", 'filename_modified_time': "2012-06-12T11:15:12+07:00", - 'drive': u"C:", - 'security_id': u"S-1-5-21-3623958015-3361044348-30300820-1013", - 'security_type': u"SidTypeFile", - 'stream_list': [{'name': u"StreamA"}, - {'hashes': [{'type': u"MD5", + 'drive': u("C:"), + 'security_id': u("S-1-5-21-3623958015-3361044348-30300820-1013"), + 'security_type': u("SidTypeFile"), + 'stream_list': [{'name': u("StreamA")}, + {'hashes': [{'type': u("MD5"), 'simple_hash_value': EMPTY_MD5}], - 'name': u"StreamB"}], + 'name': u("StreamB")}], # WinFile-specific implementations of abstract types. - 'file_attributes_list': [u"Hidden", u"System", u"Temporary"], + 'file_attributes_list': [u("Hidden"), u("System"), u("Temporary")], 'permissions': { 'full_control': False, 'modify': True, diff --git a/cybox/test/objects/win_filemapping_test.py b/cybox/test/objects/win_filemapping_test.py index 1bcfbdc1..635427f2 100644 --- a/cybox/test/objects/win_filemapping_test.py +++ b/cybox/test/objects/win_filemapping_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.compat import long from cybox.objects.win_filemapping_object import WinFilemapping from cybox.test.objects import ObjectTestCase @@ -15,8 +17,8 @@ class TestWinFilemapping(ObjectTestCase, unittest.TestCase): _full_dict = { 'handle': { 'id': 1234, - 'name': u"MyHandle", - 'type': u"Window", + 'name': u("MyHandle"), + 'type': u("Window"), 'object_address': long(0xdeadbeef), 'access_mask': long(0x70000000), 'pointer_count': long(3), @@ -24,14 +26,14 @@ class TestWinFilemapping(ObjectTestCase, unittest.TestCase): }, 'file_handle': { 'id': 5678, - 'name': u"MyHandle2", - 'type': u"Window", + 'name': u("MyHandle2"), + 'type': u("Window"), 'object_address': long(0xbeadbeef), 'access_mask': long(0x90009000), 'pointer_count': long(9), 'xsi:type': "WindowsHandleObjectType", }, - 'security_attributes': u"Attributes go here", + 'security_attributes': u("Attributes go here"), 'name': "A mapping name", 'maximum_size': 1000, 'actual_size': 250, diff --git a/cybox/test/objects/win_hook_test.py b/cybox/test/objects/win_hook_test.py index a1e45b8b..a98e602c 100644 --- a/cybox/test/objects/win_hook_test.py +++ b/cybox/test/objects/win_hook_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.win_hook_object import WinHook from cybox.test import EntityTestCase, round_trip @@ -14,9 +16,9 @@ class TestWinHook(ObjectTestCase, unittest.TestCase): klass = WinHook _full_dict = { - 'type': u"Test Hook", + 'type': u("Test Hook"), #'handle' = cybox.TypedField("Handle", WinHandle) - 'hooking_function_name': u"test_function", + 'hooking_function_name': u("test_function"), #'hooking_module' = cybox.TypedField("Hooking_Module", Library) 'thread_id': 2, 'xsi:type': object_type, diff --git a/cybox/test/objects/win_memory_page_region_test.py b/cybox/test/objects/win_memory_page_region_test.py index b984dc96..6ab217a0 100644 --- a/cybox/test/objects/win_memory_page_region_test.py +++ b/cybox/test/objects/win_memory_page_region_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.win_memory_page_region_object import WinMemoryPageRegion from cybox.compat import long @@ -19,17 +21,17 @@ class TestWinMemoryPageRegion(ObjectTestCase, unittest.TestCase): 'is_mapped': False, 'is_protected': True, 'is_volatile': False, - 'name': u"A page region", - 'memory_source': u"A source", + 'name': u("A page region"), + 'memory_source': u("A source"), 'region_size': long(10000), - 'block_type': u"A block type", - 'region_start_address': u"1234abcde", - 'region_end_address': u"1234abdde", - 'allocation_base_address': u"1234abbbe", - 'type': u"A type", - 'allocation_protect': u"allocate protection", - 'state': u"A state", - 'protect': u"protection", + 'block_type': u("A block type"), + 'region_start_address': u("1234abcde"), + 'region_end_address': u("1234abdde"), + 'allocation_base_address': u("1234abbbe"), + 'type': u("A type"), + 'allocation_protect': u("allocate protection"), + 'state': u("A state"), + 'protect': u("protection"), #'extracted_features' = cybox.TypedField("Extracted_Features", ExtractedFeatures) #'hashes' = cybox.TypedField("Hashes", HashList) 'xsi:type': object_type, diff --git a/cybox/test/objects/win_network_route_entry_test.py b/cybox/test/objects/win_network_route_entry_test.py index e80e8e52..f2260888 100644 --- a/cybox/test/objects/win_network_route_entry_test.py +++ b/cybox/test/objects/win_network_route_entry_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.win_network_route_entry_object import WinNetworkRouteEntry from cybox.test import EntityTestCase, round_trip @@ -14,8 +16,8 @@ class TestWinNetworkRouteEntry(ObjectTestCase, unittest.TestCase): klass = WinNetworkRouteEntry _full_dict = { - 'nl_route_protocol': u"A protocol", - 'nl_route_origin': u"An origin", + 'nl_route_protocol': u("A protocol"), + 'nl_route_origin': u("An origin"), 'xsi:type': object_type, } diff --git a/cybox/test/objects/win_prefetch_test.py b/cybox/test/objects/win_prefetch_test.py index a57a1bb2..3648778d 100644 --- a/cybox/test/objects/win_prefetch_test.py +++ b/cybox/test/objects/win_prefetch_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.win_prefetch_object import WinPrefetch from cybox.test import EntityTestCase, round_trip @@ -14,14 +16,14 @@ class TestWinPrefetch(ObjectTestCase, unittest.TestCase): klass = WinPrefetch _full_dict = { - 'application_file_name': u"A file name", - 'prefetch_hash': u"A hash", + 'application_file_name': u("A file name"), + 'prefetch_hash': u("A hash"), 'times_executed': 14, #'first_run' = cybox.TypedField("First_Run", DateTime) #'last_run' = cybox.TypedField("Last_Run", DateTime) #'volume' = cybox.TypedField("Volume", VolumeType) #'accessed_file_list' = cybox.TypedField("Accessed_File_List", AccessedFileListType) - #'accessed_directory_list' = cybox.TypedField("Accessed_Directory_List", AccessedDirectoryListType) + #'accessed_directory_list' = cybox.TypedField("Accessed_Directory_List", AccessedDirectoryListType) 'xsi:type': object_type, } diff --git a/cybox/test/objects/win_registry_key_test.py b/cybox/test/objects/win_registry_key_test.py index d00a3be7..dc86370f 100644 --- a/cybox/test/objects/win_registry_key_test.py +++ b/cybox/test/objects/win_registry_key_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.compat import long from cybox.objects.win_registry_key_object import WinRegistryKey from cybox.test.objects import ObjectTestCase @@ -13,50 +15,50 @@ class TestWinRegistryKey(ObjectTestCase, unittest.TestCase): klass = WinRegistryKey _full_dict = { - 'key': u"\\SOFTWARE\\Microsoft\\Windows\\Windows Error Reporting", - 'hive': u"HKEY_LOCAL_MACHINE", + 'key': u("\\SOFTWARE\\Microsoft\\Windows\\Windows Error Reporting"), + 'hive': u("HKEY_LOCAL_MACHINE"), 'number_values': 6, 'values': [ { - 'name': u"Disabled", - 'data': u"1", - 'datatype': u"REG_DWORD", - 'byte_runs': [{'length': 1, 'byte_run_data': u"A"}], + 'name': u("Disabled"), + 'data': u("1"), + 'datatype': u("REG_DWORD"), + 'byte_runs': [{'length': 1, 'byte_run_data': u("A")}], }, { - 'name': u"ErrorPort", - 'data': u"\\WindowsErrorReportingServicePort", - 'datatype': u"REG_SZ", + 'name': u("ErrorPort"), + 'data': u("\\WindowsErrorReportingServicePort"), + 'datatype': u("REG_SZ"), }, ], - 'modified_time': u"2013-08-08T15:15:15-04:00", - 'creator_username': u"gback", + 'modified_time': u("2013-08-08T15:15:15-04:00"), + 'creator_username': u("gback"), 'handle_list': [ { - 'name': u"RegHandle", + 'name': u("RegHandle"), 'pointer_count': long(1), - 'type': u"RegistryKey", - 'xsi:type': u'WindowsHandleObjectType', + 'type': u("RegistryKey"), + 'xsi:type': u('WindowsHandleObjectType'), }, ], 'number_subkeys': 1, 'subkeys': [ { - 'key': u"Consent", + 'key': u("Consent"), 'number_values': 1, 'values': [ { - 'name': u"NewUserDefaultConsent", - 'data': u"1", - 'datatype': u"REG_DWORD", + 'name': u("NewUserDefaultConsent"), + 'data': u("1"), + 'datatype': u("REG_DWORD"), }, ], 'xsi:type': 'WindowsRegistryKeyObjectType', }, ], 'byte_runs': [ - {'length': 4, 'byte_run_data': u"z!%f"}, - {'offset': 0x1000, 'length': 8, 'byte_run_data': u"%40V.,2@"}, + {'length': 4, 'byte_run_data': u("z!%f")}, + {'offset': 0x1000, 'length': 8, 'byte_run_data': u("%40V.,2@")}, ], 'xsi:type': object_type, } diff --git a/cybox/test/objects/win_semaphore_test.py b/cybox/test/objects/win_semaphore_test.py index cd2e2cf2..cb57e624 100644 --- a/cybox/test/objects/win_semaphore_test.py +++ b/cybox/test/objects/win_semaphore_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.compat import long from cybox.objects.win_semaphore_object import WinSemaphore from cybox.test.objects import ObjectTestCase @@ -15,18 +17,18 @@ class TestWinSemaphore(ObjectTestCase, unittest.TestCase): _full_dict = { 'handle': { 'id': 1234, - 'name': u"MyHandle", - 'type': u"Window", + 'name': u("MyHandle"), + 'type': u("Window"), 'object_address': long(0xdeadbeef), 'access_mask': long(0x70000000), 'pointer_count': long(3), 'xsi:type': "WindowsHandleObjectType", }, - 'security_attributes': u"Attributes go here", + 'security_attributes': u("Attributes go here"), 'named': False, 'current_count': 100, 'maximum_count': 250, - 'name': u"A Test", + 'name': u("A Test"), 'xsi:type': object_type } diff --git a/cybox/test/objects/win_system_restore_test.py b/cybox/test/objects/win_system_restore_test.py index e05f0021..a68e15f7 100644 --- a/cybox/test/objects/win_system_restore_test.py +++ b/cybox/test/objects/win_system_restore_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.win_system_restore_object import WinSystemRestore from cybox.test import EntityTestCase, round_trip @@ -14,26 +16,26 @@ class TestWinSystemRestore(ObjectTestCase, unittest.TestCase): klass = WinSystemRestore _full_dict = { - 'restore_point_description': u"restore desc", - 'restore_point_full_path': u"restore path", - 'acl_change_username': u"username", - 'restore_point_name': u"pont name", - 'restore_point_type': u"point type", - 'backup_file_name': u"backup name", - 'acl_change_sid': u"an SID", - 'changelog_entry_flags': u"entry flags", + 'restore_point_description': u("restore desc"), + 'restore_point_full_path': u("restore path"), + 'acl_change_username': u("username"), + 'restore_point_name': u("pont name"), + 'restore_point_type': u("point type"), + 'backup_file_name': u("backup name"), + 'acl_change_sid': u("an SID"), + 'changelog_entry_flags': u("entry flags"), 'changelog_entry_sequence_number': 1234, #'created' = cybox.TypedField("Created", DateTime) - 'file_attributes': u"RWX", - 'new_file_name': u"New name", - 'original_file_name': u"original file name", - 'original_short_file_name': u"org fname", - 'process_name': u"A process name", - 'change_event': u"some event", - 'changelog_entry_type': u"entry type", + 'file_attributes': u("RWX"), + 'new_file_name': u("New name"), + 'original_file_name': u("original file name"), + 'original_short_file_name': u("org fname"), + 'process_name': u("A process name"), + 'change_event': u("some event"), + 'changelog_entry_type': u("entry type"), 'registry_hive_list': [ - u"hive 1", - u"hive 2" + u("hive 1"), + u("hive 2") ], 'xsi:type': object_type, } diff --git a/cybox/test/objects/win_task_test.py b/cybox/test/objects/win_task_test.py index 6b849466..2022ca4e 100644 --- a/cybox/test/objects/win_task_test.py +++ b/cybox/test/objects/win_task_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.compat import long from cybox.objects.win_task_object import WinTask from cybox.test.common.hash_test import TEST_HASH_LIST @@ -14,16 +16,16 @@ class TestWinTask(ObjectTestCase, unittest.TestCase): klass = WinTask _full_dict = { - 'status': u"SCHED_S_TASK_RUNNING", - 'priority': u"NORMAL_PRIORITY_CLASS", - 'name': u"Find all the malware", - 'application_name': u"Windows Defender", - 'parameters': u"C:\\", - 'flags': u"/DEEP", - 'account_name': u"SYSTEM", - 'account_run_level': u"ARunLevel", - 'account_logon_type': u"S4U", - 'creator': u"TheCreator", + 'status': u("SCHED_S_TASK_RUNNING"), + 'priority': u("NORMAL_PRIORITY_CLASS"), + 'name': u("Find all the malware"), + 'application_name': u("Windows Defender"), + 'parameters': u("C:\\\\"), + 'flags': u("/DEEP"), + 'account_name': u("SYSTEM"), + 'account_run_level': u("ARunLevel"), + 'account_logon_type': u("S4U"), + 'creator': u("TheCreator"), 'creation_date': "2012-04-26T15:30:45-05:00", 'most_recent_run_time': "2013-06-26T10:20:30-05:00", 'exit_code': long(0), @@ -31,59 +33,59 @@ class TestWinTask(ObjectTestCase, unittest.TestCase): 'next_run_time': "2013-06-27T10:20:30-05:00", 'action_list': [ { - 'action_type': u"TASK_ACTION_SEND_EMAIL", - 'action_id': u"Action #1", + 'action_type': u("TASK_ACTION_SEND_EMAIL"), + 'action_id': u("Action #1"), 'iemailaction': { - 'raw_body': u"Task Completed!", + 'raw_body': u("Task Completed!"), 'xsi:type': "EmailMessageObjectType", }, }, { - 'action_type': u"TASK_ACTION_COM_HANDLER", - 'action_id': u"Action #2", + 'action_type': u("TASK_ACTION_COM_HANDLER"), + 'action_id': u("Action #2"), 'icomhandleraction': { - 'com_data': u"COMDATA", - 'com_class_id': u"CLASSID" + 'com_data': u("COMDATA"), + 'com_class_id': u("CLASSID") }, }, { - 'action_type': u"TASK_ACTION_EXEC", - 'action_id': u"Action #3", + 'action_type': u("TASK_ACTION_EXEC"), + 'action_id': u("Action #3"), 'iexecaction': { - 'exec_arguments': u"ARGS", - 'exec_program_path': u"C:\\temp\\cmd.exe", - 'exec_working_directory': u"C:\\temp\\", + 'exec_arguments': u("ARGS"), + 'exec_program_path': u("C:\\\\temp\\\\cmd.exe"), + 'exec_working_directory': u("C:\\\\temp\\\\"), 'exec_program_hashes': TEST_HASH_LIST, }, }, { - 'action_type': u"TASK_ACTION_SHOW_MESSAGE", - 'action_id': u"Action #4", + 'action_type': u("TASK_ACTION_SHOW_MESSAGE"), + 'action_id': u("Action #4"), 'ishowmessageaction': { - 'show_message_body': u"Task completed.", - 'show_message_title': u"Task Complete", + 'show_message_body': u("Task completed."), + 'show_message_title': u("Task Complete"), }, }, ], 'trigger_list': [ { 'trigger_begin': "2013-05-05T01:02:03-04:00", - 'trigger_delay': u"PT5M", + 'trigger_delay': u("PT5M"), 'trigger_end': "2013-05-05T01:02:10-04:00", 'trigger_frequency': - u"TASK_TIME_TRIGGER_DAILY", - 'trigger_max_run_time': u"PT1M", + u("TASK_TIME_TRIGGER_DAILY"), + 'trigger_max_run_time': u("PT1M"), 'trigger_session_change_type': - u"TASK_REMOTE_CONNECT", + u("TASK_REMOTE_CONNECT"), #TODO: Add trigger_type }, { - 'trigger_max_run_time': u"PT10M", + 'trigger_max_run_time': u("PT10M"), }, ], - 'comment': u"This is a useless task.", - 'working_directory': u"C:\\WINDOWS\\system32\\", - 'work_item_data': u"AAAAn34lq21b4m2nbvoi345", + 'comment': u("This is a useless task."), + 'working_directory': u("C:\\\\WINDOWS\\\\system32\\\\"), + 'work_item_data': u("AAAAn34lq21b4m2nbvoi345"), 'xsi:type': object_type, } diff --git a/cybox/test/objects/win_thread_test.py b/cybox/test/objects/win_thread_test.py index 2646d12e..e7fa4a5a 100644 --- a/cybox/test/objects/win_thread_test.py +++ b/cybox/test/objects/win_thread_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.win_thread_object import WinThread from cybox.test.objects import ObjectTestCase @@ -14,18 +16,18 @@ class TestWinThread(ObjectTestCase, unittest.TestCase): _full_dict = { 'thread_id': 1234, 'handle': { - 'name': u"Thread Handle", - 'type': u"Thread", + 'name': u("Thread Handle"), + 'type': u("Thread"), 'xsi:type': "WindowsHandleObjectType", }, - 'running_status': u"Ready", - 'context': u"My Context", + 'running_status': u("Ready"), + 'context': u("My Context"), 'priority': 15, - 'creation_flags': u"FFF0", + 'creation_flags': u("FFF0"), 'creation_time': "2013-07-31T14:08:10+05:00", - 'start_address': u"00400000", - 'parameter_address': u"01234567", - 'security_attributes': u"Some Attributes", + 'start_address': u("00400000"), + 'parameter_address': u("01234567"), + 'security_attributes': u("Some Attributes"), 'stack_size': 0x1000, 'xsi:type': object_type, } diff --git a/cybox/test/objects/win_user_test.py b/cybox/test/objects/win_user_test.py index 7803adea..4b6b8dd2 100644 --- a/cybox/test/objects/win_user_test.py +++ b/cybox/test/objects/win_user_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.win_user_object import WinUser from cybox.test.objects import ObjectTestCase @@ -14,21 +16,21 @@ class TestWinUser(ObjectTestCase, unittest.TestCase): _full_dict = { # Account-specific fields 'disabled': False, - 'domain': u'ADMIN', + 'domain': u('ADMIN'), # UserAccount-specific fields 'password_required': True, - 'full_name': u"Steve Ballmer", - 'group_list': [{'name': u"LocalAdministrators"}], - 'home_directory': u"C:\\Users\\ballmer\\", + 'full_name': u("Steve Ballmer"), + 'group_list': [{'name': u("LocalAdministrators")}], + 'home_directory': u("C:\\\\Users\\\\ballmer\\\\"), 'last_login': "2011-05-12T07:14:01+07:00", 'privilege_list': [ - {'user_right': u"SeDebugPrivilege"} + {'user_right': u("SeDebugPrivilege")} ], - 'username': u"ballmer", - 'user_password_age': u"P180D", + 'username': u("ballmer"), + 'user_password_age': u("P180D"), # WinUser-specific fields - 'security_id': u"S-1-5-21-3623811015-3361044348-30300820-1013", - 'security_type': u"SidTypeUser", + 'security_id': u("S-1-5-21-3623811015-3361044348-30300820-1013"), + 'security_type': u("SidTypeUser"), 'xsi:type': object_type, } diff --git a/cybox/test/objects/win_waitable_timer_test.py b/cybox/test/objects/win_waitable_timer_test.py index 7cb86353..3d38ea57 100644 --- a/cybox/test/objects/win_waitable_timer_test.py +++ b/cybox/test/objects/win_waitable_timer_test.py @@ -3,6 +3,8 @@ import unittest +from six import u + from cybox.objects.win_waitable_timer_object import WinWaitableTimer from cybox.test import EntityTestCase, round_trip @@ -14,9 +16,9 @@ class TestWinWaitableTimer(ObjectTestCase, unittest.TestCase): klass = WinWaitableTimer _full_dict = { - 'security_attributes': u"timer attributes", - 'name': u"timer name", - 'type': u"timer type", + 'security_attributes': u("timer attributes"), + 'name': u("timer name"), + 'type': u("timer type"), 'xsi:type': object_type, } diff --git a/cybox/utils/__init__.py b/cybox/utils/__init__.py index 2bcc7dec..2fec31f0 100644 --- a/cybox/utils/__init__.py +++ b/cybox/utils/__init__.py @@ -7,12 +7,12 @@ import os import xml.sax.saxutils +import six + from .caches import * from .idgen import * from .nsparser import * -from cybox.compat import str - def get_class_for_object_type(object_type): return META.get_class_for_object_type(object_type) @@ -37,12 +37,12 @@ def normalize_to_xml(value, delimiter): raise ValueError("delimiter must not be None") if isinstance(value, list): - normalized_list = [str(x) for x in value] + normalized_list = [six.text_type(x) for x in value] if any(delimiter in x for x in normalized_list): raise ValueError("list items cannot contain delimiter") normalized = delimiter.join(normalized_list) else: - normalized = str(value) + normalized = six.text_type(value) if delimiter in normalized: raise ValueError("value cannot contain delimiter") diff --git a/docs/conf.py b/docs/conf.py index cf56fed9..8bf2b638 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,8 +2,8 @@ import cybox -project = u'python-cybox' -copyright = u'2015, The MITRE Corporation' +project = 'python-cybox' +copyright = '2015, The MITRE Corporation' version = cybox.__version__ release = version @@ -43,6 +43,6 @@ latex_elements = {} latex_documents = [ - ('index', 'python-cybox.tex', u'python-cybox Documentation', - u'The MITRE Corporation', 'manual'), + ('index', 'python-cybox.tex', 'python-cybox Documentation', + 'The MITRE Corporation', 'manual'), ] diff --git a/docs/examples.rst b/docs/examples.rst index a6d5a405..60734d90 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -21,6 +21,17 @@ that shouldn't be done in production code: be created instead, or create explicit IDs yourself for objects and observables. +.. testsetup:: + + # This is necessary because Python 3 won't consider the UTF-8 encoded byte + # literals returned from to_xml() to be equivalent to the `testoutput::` + # blocks, and this prevents us from needing to pass `encoding=None` to each + # `to_xml()` call and explain to people why we've done that, but they don't + # need to. + # builtin_print = print + # def print(s): + # builtin_print(s.decode('utf-8')) + Creating Objects ------------------- @@ -35,7 +46,7 @@ properties on it. f = File() f.file_name = "malware.exe" f.file_path = "C:\Windows\Temp\malware.exe" - print f.to_xml(include_namespaces=False) + print(f.to_xml(include_namespaces=False, encoding=None)) Which outputs: @@ -54,7 +65,7 @@ into the constructor. from cybox.objects.address_object import Address a = Address("1.2.3.4", Address.CAT_IPV4) - print a.to_xml(include_namespaces=False) + print(a.to_xml(include_namespaces=False, encoding=None)) .. testoutput:: @@ -79,7 +90,7 @@ proper XML. f = File() f.file_name = "malware.exe" f.file_path = "C:\Windows\Temp\malware.exe" - print Observables(f).to_xml(include_namespaces=False) + print(Observables(f).to_xml(include_namespaces=False, encoding=None)) .. testoutput:: @@ -107,7 +118,7 @@ can pass them as a list to the Observables constructor. set_id_method(IDGenerator.METHOD_INT) a = Address("1.2.3.4", Address.CAT_IPV4) u = URI("http://cybox.mitre.org/") - print Observables([a, u]).to_xml(include_namespaces=False) + print(Observables([a, u]).to_xml(include_namespaces=False, encoding=None)) .. testoutput:: @@ -135,13 +146,20 @@ HTTP Message Body When outputing XML, by default, reserved XML characters such as < and > are escaped by default. +.. testsetup:: http + + from cybox.objects.http_session_object import HTTPMessage + m = HTTPMessage() + m.message_body = "An HTML page

Body text

" + + .. testcode:: from cybox.objects.http_session_object import HTTPMessage m = HTTPMessage() m.message_body = "An HTML page

Body text

" m.length = len(m.message_body.value) - print m.to_xml(include_namespaces=False) + print(m.to_xml(include_namespaces=False, encoding=None)) .. testoutput:: @@ -153,11 +171,12 @@ escaped by default. When you parse this content, these characters are converted back. + .. testcode:: from cybox.bindings.http_session_object import parseString - m2 = HTTPMessage.from_obj(parseString(m.to_xml())) - print m2.message_body + m2 = HTTPMessage.from_obj(parseString(m.to_xml(encoding=None))) + print(m2.message_body) .. testoutput:: @@ -170,7 +189,7 @@ HTTP User Agent .. testcode:: - from cybox.objects.http_session_object import * + from cybox.objects.http_session_object import * fields = HTTPRequestHeaderFields() fields.user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0' @@ -186,7 +205,7 @@ HTTP User Agent session = HTTPSession() session.http_request_response = [req_res] - print session.to_xml(include_namespaces=False) + print(session.to_xml(include_namespaces=False, encoding=None)) .. testoutput:: @@ -217,7 +236,7 @@ to parse strings into dates, so a wide variety of formats is supported. e.from_ = "spammer@spam.com" e.subject = "This is not spam" e.date = datetime.datetime(2012, 1, 17, 8, 35, 6) - print e.to_xml(include_namespaces=False) + print(e.to_xml(include_namespaces=False, encoding=None)) .. testoutput:: @@ -236,7 +255,7 @@ to parse strings into dates, so a wide variety of formats is supported. from cybox.objects.email_message_object import EmailMessage e = EmailMessage() e.date = "Mon, 14 Oct, 2013 12:32:03 -0500" - print e.to_xml(include_namespaces=False) + print(e.to_xml(include_namespaces=False, encoding=None)) .. testoutput:: @@ -257,7 +276,7 @@ CybOX type. from cybox.common import HashList h = HashList.from_list([{'type' : 'MD5', 'simple_hash_value' : 'FFFFFF'}, {'type' : 'SHA1', 'simple_hash_value' : 'FFFFFF'}]) - print h.to_xml(include_namespaces=False) + print(h.to_xml(include_namespaces=False, encoding=None)) .. testoutput:: @@ -281,7 +300,7 @@ This can easily be incorporated into constructing objects as well. f.file_name = "foo.exe" f.drive = "C:\\" f.hashes = h - print f.to_xml(include_namespaces=False) + print(f.to_xml(include_namespaces=False, encoding=None)) .. testoutput:: @@ -313,7 +332,7 @@ the correct namepaces for the various properties are set. f = WinFile() f.file_name = "blah.exe" f.drive = "C:\\" - print f.to_xml(include_namespaces=False) + print(f.to_xml(include_namespaces=False, encoding=None)) .. testoutput:: @@ -332,20 +351,20 @@ these can be constructed from a dictionary representation. winuser_dict = { # Account-specific fields 'disabled': False, - 'domain': u'ADMIN', + 'domain': 'ADMIN', # UserAccount-specific fields 'password_required': True, - 'full_name': u"Steve Ballmer", - 'home_directory': u"C:\\Users\\ballmer\\", + 'full_name': "Steve Ballmer", + 'home_directory': "C:\\Users\\ballmer\\", 'last_login': "2011-05-12T07:14:01+07:00", - 'username': u"ballmer", - 'user_password_age': u"P180D", + 'username': "ballmer", + 'user_password_age': "P180D", # WinUser-specific fields - 'security_id': u"S-1-5-21-3623811015-3361044348-30300820-1013", + 'security_id': "S-1-5-21-3623811015-3361044348-30300820-1013", 'security_type': "SidTypeUser", 'xsi:type': 'WindowsUserAccountObjectType', } - print WinUser.from_dict(winuser_dict).to_xml(include_namespaces=False) + print(WinUser.from_dict(winuser_dict).to_xml(include_namespaces=False, encoding=None)) .. testoutput:: :options: +NORMALIZE_WHITESPACE @@ -403,7 +422,7 @@ ObservableCompositions o_comp.add(ofile_ref) observables.add(Observable(o_comp)) - print observables.to_xml(include_namespaces=False) + print(observables.to_xml(include_namespaces=False, encoding=None)) .. testoutput:: @@ -448,7 +467,7 @@ to parse an XML string. >>> import cybox.bindings.file_object as file_binding >>> from cybox.objects.file_object import File >>> a = """ - ... diff --git a/setup.py b/setup.py index 5619e83a..e8949480 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def get_version(): with open('README.rst') as f: readme = f.read() -install_requires = ['lxml>=2.2.3', 'python-dateutil'] +install_requires = ['lxml>=2.2.3', 'python-dateutil', 'six>=1.9.0'] try: import importlib except ImportError: diff --git a/tox.ini b/tox.ini index 0a3121ba..18c0ddd2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26, py27, rhel6 +envlist = py26, py27, py32, py33, py34, rhel6 [testenv] commands = @@ -8,6 +8,13 @@ commands = sphinx-build -b html docs docs/_build/html deps = -rrequirements.txt +# Don't try building documentation on Python 3.2, due to conflicts with Pygments. +[testenv:py32] +commands = + nosetests cybox +deps = -rrequirements.txt + +#NOTE: RHEL 6 bundles six==1.7.3, but we need 1.9.0 [testenv:rhel6] basepython=python2.6 commands = @@ -15,4 +22,5 @@ commands = deps = lxml==2.2.3 python-dateutil==1.4.1 + six>=1.9.0 nose From f1ad2987641995063a4ad47fa72329341e6c25a8 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Mon, 9 Mar 2015 16:51:08 -0500 Subject: [PATCH 07/17] More cleanup of compat module. --- cybox/compat.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cybox/compat.py b/cybox/compat.py index b753b28b..e84f1c7e 100644 --- a/cybox/compat.py +++ b/cybox/compat.py @@ -1,10 +1,16 @@ -import sys +# Copyright (c) 2015, The MITRE Corporation. All rights reserved. +# See LICENSE.txt for complete terms. + +""" +Compatibility library for python-cybox. + +Only covers things that aren't already present in `six`. +""" import six if six.PY2: long = long - str = unicode chars = lambda x: x def xor(data, key): key = int(key) @@ -12,7 +18,6 @@ def xor(data, key): elif six.PY3: long = int - str = str chars = lambda x: [chr(y) for y in x] def xor(data, key): key = int(key) From b38c19bc526db8aef0374228c6a4139706c1f5ce Mon Sep 17 00:00:00 2001 From: Greg Back Date: Tue, 10 Mar 2015 14:14:51 -0500 Subject: [PATCH 08/17] Clean up some landscape.io warnings --- cybox/__init__.py | 6 +++--- cybox/compat.py | 4 +--- cybox/objects/artifact_object.py | 2 +- cybox/utils/__init__.py | 1 - 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cybox/__init__.py b/cybox/__init__.py index 04b0c9fb..d1f996a1 100644 --- a/cybox/__init__.py +++ b/cybox/__init__.py @@ -138,7 +138,7 @@ def to_obj(self, return_obj=None, ns_info=None): break members.update(vars(klass)) - for name, field in members.items(): + for field in six.itervalues(members): if isinstance(field, TypedField): val = getattr(self, field.attr_name) @@ -177,7 +177,7 @@ def to_dict(self): break members.update(vars(klass)) - for name, field in members.items(): + for field in six.itervalues(members): if isinstance(field, TypedField): val = getattr(self, field.attr_name) @@ -375,7 +375,7 @@ def _get_children(self): members.update(vars(self)) members.update(self._fields) - for k, v in members.items(): + for v in six.itervalues(members): if isinstance(v, Entity): yield v elif isinstance(v, list): diff --git a/cybox/compat.py b/cybox/compat.py index e84f1c7e..cfad3f45 100644 --- a/cybox/compat.py +++ b/cybox/compat.py @@ -11,14 +11,12 @@ if six.PY2: long = long - chars = lambda x: x def xor(data, key): key = int(key) - return b''.join([chr(ord(c) ^ key) for c in chars(data)]) + return b''.join([chr(ord(c) ^ key) for c in data]) elif six.PY3: long = int - chars = lambda x: [chr(y) for y in x] def xor(data, key): key = int(key) b = bytearray(data) diff --git a/cybox/objects/artifact_object.py b/cybox/objects/artifact_object.py index dcad405b..fa70f67f 100644 --- a/cybox/objects/artifact_object.py +++ b/cybox/objects/artifact_object.py @@ -10,7 +10,7 @@ import cybox import cybox.bindings.artifact_object as artifact_binding from cybox.common import ObjectProperties, String -from cybox.compat import chars, xor +from cybox.compat import xor class RawArtifact(String): diff --git a/cybox/utils/__init__.py b/cybox/utils/__init__.py index 2fec31f0..781d9be7 100644 --- a/cybox/utils/__init__.py +++ b/cybox/utils/__init__.py @@ -5,7 +5,6 @@ #importlib is imported below import os -import xml.sax.saxutils import six From 8a88c9125264b85a086317cd833dbd0d4039abc8 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Tue, 10 Mar 2015 14:19:33 -0500 Subject: [PATCH 09/17] Clean up example script. --- examples/parse_xml.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/examples/parse_xml.py b/examples/parse_xml.py index 34585700..ba2b6f03 100755 --- a/examples/parse_xml.py +++ b/examples/parse_xml.py @@ -1,30 +1,39 @@ #!/usr/bin/env python - # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. -# -"""Parses a CybOX Observables document and creates a python-cybox Observables instance. -Once parsed, the dictionary representation of the object is printed to stdout. + +""" +Example script for parsing CybOX XML documents. + +Usage: parse_xml.py example.xml + +The CybOX XML document is parsed into a python-cybox Observables instance. Once +parsed, the dictionary representation of the object is printed to stdout. """ import sys import cybox.bindings.cybox_core as cybox_core_binding -from cybox.core import Observables +from cybox.core import Observables + def parse(xml_file): - observables_obj = cybox_core_binding.parse(xml_file) # create binding object from xml file - observables = Observables.from_obj(observables_obj) # convert binding object into python-cybox object + # create binding object from xml file + observables_obj = cybox_core_binding.parse(xml_file) + + # convert binding object into python-cybox object + observables = Observables.from_obj(observables_obj) return observables + def main(): if len(sys.argv) != 2: - print("[!] Please provide an xml file" ) + print("[!] Please provide an xml file") exit(1) - + xml_file = sys.argv[-1] - observables = parse(xml_file) - print(observables.to_dict() # example to_dict() call on returned object) + observables = parse(xml_file) + print(observables.to_dict()) # example to_dict() call on returned object + if __name__ == "__main__": main() - From 54dd9a19c109f432b66aa9745f299df00ac94e06 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Tue, 17 Feb 2015 09:45:52 -0600 Subject: [PATCH 10/17] Add missing TOX_ENVs to .travis.yml --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5d588831..8b2423d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ language: python env: - TOXENV=py26 - TOXENV=py27 + - TOXENV=py32 + - TOXENV=py33 + - TOXENV=py34 - TOXENV=rhel6 install: From 726377d9f61d2fc7b0281a1ecbeadba4c8964229 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Wed, 11 Mar 2015 11:43:25 -0500 Subject: [PATCH 11/17] Remove common binding code and move to mixbox library; adjust code correspondingly. --- cybox/__init__.py | 4 +- cybox/bindings/__init__.py | 394 ------------------ cybox/bindings/account_object.py | 2 +- cybox/bindings/address_object.py | 2 +- cybox/bindings/api_object.py | 2 +- cybox/bindings/archive_file_object.py | 2 +- cybox/bindings/arp_cache_object.py | 2 +- cybox/bindings/artifact_object.py | 2 +- cybox/bindings/as_object.py | 2 +- cybox/bindings/code_object.py | 2 +- cybox/bindings/custom_object.py | 2 +- cybox/bindings/cybox_common.py | 2 +- cybox/bindings/cybox_core.py | 2 +- cybox/bindings/device_object.py | 2 +- cybox/bindings/disk_object.py | 2 +- cybox/bindings/disk_partition_object.py | 2 +- cybox/bindings/dns_cache_object.py | 2 +- cybox/bindings/dns_query_object.py | 2 +- cybox/bindings/dns_record_object.py | 2 +- cybox/bindings/domain_name_object.py | 2 +- cybox/bindings/email_message_object.py | 2 +- cybox/bindings/file_object.py | 2 +- cybox/bindings/gui_dialogbox_object.py | 2 +- cybox/bindings/gui_object.py | 2 +- cybox/bindings/gui_window_object.py | 2 +- cybox/bindings/hostname_object.py | 2 +- cybox/bindings/http_session_object.py | 2 +- cybox/bindings/image_file_object.py | 2 +- cybox/bindings/library_object.py | 2 +- cybox/bindings/link_object.py | 2 +- cybox/bindings/linux_package_object.py | 2 +- cybox/bindings/memory_object.py | 2 +- cybox/bindings/mutex_object.py | 2 +- cybox/bindings/network_connection_object.py | 2 +- cybox/bindings/network_flow_object.py | 2 +- cybox/bindings/network_packet_object.py | 2 +- cybox/bindings/network_route_entry_object.py | 2 +- cybox/bindings/network_route_object.py | 2 +- cybox/bindings/network_socket_object.py | 2 +- cybox/bindings/network_subnet_object.py | 2 +- cybox/bindings/pdf_file_object.py | 2 +- cybox/bindings/pipe_object.py | 2 +- cybox/bindings/port_object.py | 2 +- cybox/bindings/process_object.py | 2 +- cybox/bindings/product_object.py | 2 +- cybox/bindings/semaphore_object.py | 2 +- cybox/bindings/sms_message_object.py | 2 +- cybox/bindings/socket_address_object.py | 2 +- cybox/bindings/system_object.py | 2 +- cybox/bindings/unix_file_object.py | 2 +- .../unix_network_route_entry_object.py | 2 +- cybox/bindings/unix_pipe_object.py | 2 +- cybox/bindings/unix_process_object.py | 2 +- cybox/bindings/unix_user_account_object.py | 2 +- cybox/bindings/unix_volume_object.py | 2 +- cybox/bindings/uri_object.py | 2 +- cybox/bindings/url_history_object.py | 2 +- cybox/bindings/user_account_object.py | 2 +- cybox/bindings/user_session_object.py | 2 +- cybox/bindings/volume_object.py | 2 +- cybox/bindings/whois_object.py | 2 +- cybox/bindings/win_computer_account_object.py | 2 +- cybox/bindings/win_critical_section_object.py | 2 +- cybox/bindings/win_driver_object.py | 2 +- cybox/bindings/win_event_log_object.py | 2 +- cybox/bindings/win_event_object.py | 2 +- cybox/bindings/win_executable_file_object.py | 2 +- cybox/bindings/win_file_object.py | 2 +- cybox/bindings/win_filemapping_object.py | 2 +- cybox/bindings/win_handle_object.py | 2 +- cybox/bindings/win_hook_object.py | 2 +- cybox/bindings/win_kernel_hook_object.py | 2 +- cybox/bindings/win_kernel_object.py | 2 +- cybox/bindings/win_mailslot_object.py | 2 +- .../bindings/win_memory_page_region_object.py | 2 +- cybox/bindings/win_mutex_object.py | 2 +- .../win_network_route_entry_object.py | 2 +- cybox/bindings/win_network_share_object.py | 2 +- cybox/bindings/win_pipe_object.py | 2 +- cybox/bindings/win_prefetch_object.py | 2 +- cybox/bindings/win_process_object.py | 2 +- cybox/bindings/win_registry_key_object.py | 2 +- cybox/bindings/win_semaphore_object.py | 2 +- cybox/bindings/win_service_object.py | 2 +- cybox/bindings/win_system_object.py | 2 +- cybox/bindings/win_system_restore_object.py | 2 +- cybox/bindings/win_task_object.py | 2 +- cybox/bindings/win_thread_object.py | 2 +- cybox/bindings/win_user_account_object.py | 2 +- cybox/bindings/win_volume_object.py | 2 +- cybox/bindings/win_waitable_timer_object.py | 2 +- cybox/bindings/x509_certificate_object.py | 2 +- cybox/test/__init__.py | 6 +- cybox/test/encoding_test.py | 67 --- 94 files changed, 95 insertions(+), 556 deletions(-) diff --git a/cybox/__init__.py b/cybox/__init__.py index d1f996a1..63ace6b1 100644 --- a/cybox/__init__.py +++ b/cybox/__init__.py @@ -5,9 +5,9 @@ import inspect import json +from mixbox.binding_utils import save_encoding import six -import cybox.bindings as bindings import cybox.utils.idgen from cybox.utils import Namespace, META, is_sequence @@ -291,7 +291,7 @@ def to_xml(self, include_namespaces=True, namespace_dict=None, namespace_def = namespace_def.replace('\n\t', ' ') - with bindings.save_encoding(encoding): + with save_encoding(encoding): sio = six.StringIO() self.to_obj().export( sio.write, diff --git a/cybox/bindings/__init__.py b/cybox/bindings/__init__.py index bf9d9495..e69de29b 100644 --- a/cybox/bindings/__init__.py +++ b/cybox/bindings/__init__.py @@ -1,394 +0,0 @@ -# Copyright (c) 2015, The MITRE Corporation. All rights reserved. -# See LICENSE.txt for complete terms. - -import base64 -import contextlib -from datetime import datetime, tzinfo, timedelta -import re -from xml.sax import saxutils - -from lxml import etree as etree_ -import six - -CDATA_START = "" - -ExternalEncoding = 'utf-8' -Tag_pattern_ = re.compile(r'({.*})?(.*)') - -# These are only used internally -_tzoff_pattern = re.compile(r'(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$') -_Tag_strip_pattern_ = re.compile(r'\{.*\}') - - -@contextlib.contextmanager -def save_encoding(encoding='utf-8'): - global ExternalEncoding - - try: - orig_encoding = ExternalEncoding - ExternalEncoding = encoding - yield - finally: - ExternalEncoding = orig_encoding - - -def parsexml_(*args, **kwargs): - if 'parser' not in kwargs: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - kwargs['parser'] = etree_.ETCompatXMLParser(huge_tree=True) - return etree_.parse(*args, **kwargs) - - -class _FixedOffsetTZ(tzinfo): - - def __init__(self, offset, name): - self.__offset = timedelta(minutes = offset) - self.__name = name - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return self.__name - - def dst(self, dt): - return None - - __reduce__ = object.__reduce__ - - -class GeneratedsSuper(object): - - def gds_format_string(self, input_data, input_name=''): - return input_data - - def gds_validate_string(self, input_data, node, input_name=''): - return input_data - - def gds_format_base64(self, input_data, input_name=''): - return base64.b64encode(input_data) - - def gds_validate_base64(self, input_data, node, input_name=''): - return input_data - - def gds_format_integer(self, input_data, input_name=''): - return '%d' % input_data - - def gds_validate_integer(self, input_data, node, input_name=''): - return input_data - - def gds_format_integer_list(self, input_data, input_name=''): - return '%s' % input_data - - def gds_validate_integer_list(self, input_data, node, input_name=''): - values = input_data.split() - for value in values: - try: - fvalue = float(value) - except (TypeError, ValueError) as exp: - raise_parse_error(node, 'Requires sequence of integers') - return input_data - - def gds_format_float(self, input_data, input_name=''): - return '%f' % input_data - - def gds_validate_float(self, input_data, node, input_name=''): - return input_data - - def gds_format_float_list(self, input_data, input_name=''): - return '%s' % input_data - - def gds_validate_float_list(self, input_data, node, input_name=''): - values = input_data.split() - for value in values: - try: - fvalue = float(value) - except (TypeError, ValueError) as exp: - raise_parse_error(node, 'Requires sequence of floats') - return input_data - - def gds_format_double(self, input_data, input_name=''): - return '%e' % input_data - - def gds_validate_double(self, input_data, node, input_name=''): - return input_data - - def gds_format_double_list(self, input_data, input_name=''): - return '%s' % input_data - - def gds_validate_double_list(self, input_data, node, input_name=''): - values = input_data.split() - for value in values: - try: - fvalue = float(value) - except (TypeError, ValueError) as exp: - raise_parse_error(node, 'Requires sequence of doubles') - return input_data - - def gds_format_boolean(self, input_data, input_name=''): - return ('%s' % input_data).lower() - - def gds_validate_boolean(self, input_data, node, input_name=''): - return input_data - - def gds_format_boolean_list(self, input_data, input_name=''): - return '%s' % input_data - - def gds_validate_boolean_list(self, input_data, node, input_name=''): - values = input_data.split() - for value in values: - if value not in ('true', '1', 'false', '0', ): - raise_parse_error(node, - 'Requires sequence of booleans ' - '("true", "1", "false", "0")') - return input_data - - def gds_validate_datetime(self, input_data, node, input_name=''): - return input_data - - def gds_format_datetime(self, input_data, input_name=''): - if isinstance(input_data, six.string_types): - return input_data - if input_data.microsecond == 0: - _svalue = input_data.strftime('%Y-%m-%dT%H:%M:%S') - else: - _svalue = input_data.strftime('%Y-%m-%dT%H:%M:%S.%f') - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += 'Z' - else: - if total_seconds < 0: - _svalue += '-' - total_seconds *= -1 - else: - _svalue += '+' - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += '{0:02d}:{1:02d}'.format(hours, minutes) - return _svalue - - def gds_parse_datetime(self, input_data, node, input_name=''): - tz = None - if input_data[-1] == 'Z': - tz = _FixedOffsetTZ(0, 'GMT') - input_data = input_data[:-1] - else: - results = _tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(':') - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == '-': - tzoff *= -1 - tz = _FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - if len(input_data.split('.')) > 1: - dt = datetime.strptime(input_data, '%Y-%m-%dT%H:%M:%S.%f') - else: - dt = datetime.strptime(input_data, '%Y-%m-%dT%H:%M:%S') - return dt.replace(tzinfo = tz) - - def gds_validate_date(self, input_data, node, input_name=''): - return input_data - - def gds_format_date(self, input_data, input_name=''): - if isinstance(input_data, six.string_types): - return input_data - _svalue = input_data.strftime('%Y-%m-%d') - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += 'Z' - else: - if total_seconds < 0: - _svalue += '-' - total_seconds *= -1 - else: - _svalue += '+' - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += '{0:02d}:{1:02d}'.format(hours, minutes) - return _svalue - - def gds_parse_date(self, input_data, node, input_name=''): - tz = None - if input_data[-1] == 'Z': - tz = _FixedOffsetTZ(0, 'GMT') - input_data = input_data[:-1] - else: - results = _tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(':') - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == '-': - tzoff *= -1 - tz = _FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - return datetime.strptime(input_data, '%Y-%m-%d').replace(tzinfo = tz) - - def gds_str_lower(self, instring): - return instring.lower() - - def get_path_(self, node): - path_list = [] - self.get_path_list_(node, path_list) - path_list.reverse() - path = '/'.join(path_list) - return path - - def get_path_list_(self, node, path_list): - if node is None: - return - tag = _Tag_strip_pattern_.sub('', node.tag) - if tag: - path_list.append(tag) - self.get_path_list_(node.getparent(), path_list) - - def get_class_obj_(self, node, default_class=None): - class_obj1 = default_class - if 'xsi' in node.nsmap: - classname = node.get('{%s}type' % node.nsmap['xsi']) - if classname is not None: - names = classname.split(':') - if len(names) == 2: - classname = names[1] - class_obj2 = globals().get(classname) - if class_obj2 is not None: - class_obj1 = class_obj2 - return class_obj1 - - def gds_build_any(self, node, type_name=None): - return None - - -def showIndent(lwrite, level, pretty_print=True): - if pretty_print: - lwrite(' ' * level) - - -def _coerce_unicode(text): - # Convert `text` to Unicode string. - - if text is None: - text = "" - - if isinstance(text, str): - return text - - # This is mainly a catch-all for non - # string/unicode types like bool and int. - try: - text = six.text_type(text) - except UnicodeDecodeError: - text = text.decode(ExternalEncoding) - - return text - - -def quote_xml(text): - """Format a value for display as an XML text node. - - Returns: - Unicode string (str on Python 3, unicode on Python 2) - """ - text = _coerce_unicode(text) - - # If it's a CDATA block, return the text as is. - if text.startswith(CDATA_START): - return text - - # If it's not a CDATA block, escape the XML and return the character - # encoded string. - return saxutils.escape(text) - - -def quote_attrib(text): - """Format a value for display as an XML attribute. - - Returns: - Unicode string (str on Python 3, unicode on Python 2) - """ - text = _coerce_unicode(text) - - # Return the escaped the value of text. - # Note: This wraps the escaped text in quotation marks. - return saxutils.quoteattr(text) - - -def quote_python(inStr): - s1 = inStr - if s1.find("'") == -1: - if s1.find('\n') == -1: - return "'%s'" % s1 - else: - return "'''%s'''" % s1 - else: - if s1.find('"') != -1: - s1 = s1.replace('"', '\\"') - if s1.find('\n') == -1: - return '"%s"' % s1 - else: - return '"""%s"""' % s1 - - -def get_all_text_(node): - if node.text is not None: - text = node.text - else: - text = '' - for child in node: - if child.tail is not None: - text += child.tail - return text - - -def find_attr_value_(attr_name, node): - attrs = node.attrib - attr_parts = attr_name.split(':') - value = None - if len(attr_parts) == 1: - value = attrs.get(attr_name) - elif len(attr_parts) == 2: - prefix, name = attr_parts - namespace = node.nsmap.get(prefix) - if namespace is not None: - value = attrs.get('{%s}%s' % (namespace, name, )) - return value - - -class GDSParseError(Exception): - pass - - -def raise_parse_error(node, msg): - msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, ) - raise GDSParseError(msg) - - -def _cast(typ, value): - if typ is None or value is None: - return value - return typ(value) - - -__all__ = [ - '_cast', - 'etree_', - 'ExternalEncoding', - 'find_attr_value_', - 'get_all_text_', - 'parsexml_', - 'quote_xml', - 'quote_attrib', - 'quote_python', - 'raise_parse_error', - 'showIndent', - 'Tag_pattern_', - 'GeneratedsSuper', -] diff --git a/cybox/bindings/account_object.py b/cybox/bindings/account_object.py index a8d97b7d..aa6f7663 100644 --- a/cybox/bindings/account_object.py +++ b/cybox/bindings/account_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/address_object.py b/cybox/bindings/address_object.py index 0b3cd798..37e328e4 100644 --- a/cybox/bindings/address_object.py +++ b/cybox/bindings/address_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/api_object.py b/cybox/bindings/api_object.py index 26410ce6..9e710a46 100644 --- a/cybox/bindings/api_object.py +++ b/cybox/bindings/api_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/archive_file_object.py b/cybox/bindings/archive_file_object.py index 741376cf..5af4be09 100644 --- a/cybox/bindings/archive_file_object.py +++ b/cybox/bindings/archive_file_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import file_object diff --git a/cybox/bindings/arp_cache_object.py b/cybox/bindings/arp_cache_object.py index 3e41edc0..9bafa328 100644 --- a/cybox/bindings/arp_cache_object.py +++ b/cybox/bindings/arp_cache_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object from . import system_object diff --git a/cybox/bindings/artifact_object.py b/cybox/bindings/artifact_object.py index 71031144..1d1ae9e7 100644 --- a/cybox/bindings/artifact_object.py +++ b/cybox/bindings/artifact_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/as_object.py b/cybox/bindings/as_object.py index fa483623..8280d353 100644 --- a/cybox/bindings/as_object.py +++ b/cybox/bindings/as_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/code_object.py b/cybox/bindings/code_object.py index 6998ff00..35a2b67e 100644 --- a/cybox/bindings/code_object.py +++ b/cybox/bindings/code_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/custom_object.py b/cybox/bindings/custom_object.py index 7ee1062e..1c65f483 100644 --- a/cybox/bindings/custom_object.py +++ b/cybox/bindings/custom_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/cybox_common.py b/cybox/bindings/cybox_common.py index 75902301..12d21366 100644 --- a/cybox/bindings/cybox_common.py +++ b/cybox/bindings/cybox_common.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * #List delimiter value for lists captured in *ObjectPropertyTypes __LIST_DELIMITER__ = "##comma##" diff --git a/cybox/bindings/cybox_core.py b/cybox/bindings/cybox_core.py index a1a1c067..ccd09823 100644 --- a/cybox/bindings/cybox_core.py +++ b/cybox/bindings/cybox_core.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common #Object Imports diff --git a/cybox/bindings/device_object.py b/cybox/bindings/device_object.py index 6e865e8f..275dcde1 100644 --- a/cybox/bindings/device_object.py +++ b/cybox/bindings/device_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/disk_object.py b/cybox/bindings/disk_object.py index 08dcec21..d84557b8 100644 --- a/cybox/bindings/disk_object.py +++ b/cybox/bindings/disk_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import disk_partition_object diff --git a/cybox/bindings/disk_partition_object.py b/cybox/bindings/disk_partition_object.py index dffb1082..3c43c94f 100644 --- a/cybox/bindings/disk_partition_object.py +++ b/cybox/bindings/disk_partition_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/dns_cache_object.py b/cybox/bindings/dns_cache_object.py index 636a34a6..00332a1c 100644 --- a/cybox/bindings/dns_cache_object.py +++ b/cybox/bindings/dns_cache_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import dns_record_object diff --git a/cybox/bindings/dns_query_object.py b/cybox/bindings/dns_query_object.py index 8bf0d3cf..c183a749 100644 --- a/cybox/bindings/dns_query_object.py +++ b/cybox/bindings/dns_query_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import dns_record_object from . import uri_object diff --git a/cybox/bindings/dns_record_object.py b/cybox/bindings/dns_record_object.py index 8626a449..ad095756 100644 --- a/cybox/bindings/dns_record_object.py +++ b/cybox/bindings/dns_record_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object from . import uri_object diff --git a/cybox/bindings/domain_name_object.py b/cybox/bindings/domain_name_object.py index c956eaea..c983dd25 100644 --- a/cybox/bindings/domain_name_object.py +++ b/cybox/bindings/domain_name_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/email_message_object.py b/cybox/bindings/email_message_object.py index bd6f8772..c29ef9a7 100644 --- a/cybox/bindings/email_message_object.py +++ b/cybox/bindings/email_message_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object diff --git a/cybox/bindings/file_object.py b/cybox/bindings/file_object.py index f2b9d78b..ed5aad69 100644 --- a/cybox/bindings/file_object.py +++ b/cybox/bindings/file_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/gui_dialogbox_object.py b/cybox/bindings/gui_dialogbox_object.py index e5ac23d2..32cbdb38 100644 --- a/cybox/bindings/gui_dialogbox_object.py +++ b/cybox/bindings/gui_dialogbox_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import gui_object diff --git a/cybox/bindings/gui_object.py b/cybox/bindings/gui_object.py index 3bec3619..2c5fdf64 100644 --- a/cybox/bindings/gui_object.py +++ b/cybox/bindings/gui_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/gui_window_object.py b/cybox/bindings/gui_window_object.py index 9e4a5a2b..d3513564 100644 --- a/cybox/bindings/gui_window_object.py +++ b/cybox/bindings/gui_window_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import gui_object diff --git a/cybox/bindings/hostname_object.py b/cybox/bindings/hostname_object.py index 96b9df00..eb7e165a 100644 --- a/cybox/bindings/hostname_object.py +++ b/cybox/bindings/hostname_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/http_session_object.py b/cybox/bindings/http_session_object.py index 010a94df..a08f3fd0 100644 --- a/cybox/bindings/http_session_object.py +++ b/cybox/bindings/http_session_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object from . import port_object diff --git a/cybox/bindings/image_file_object.py b/cybox/bindings/image_file_object.py index e1fa41a5..faff5ffe 100644 --- a/cybox/bindings/image_file_object.py +++ b/cybox/bindings/image_file_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import file_object diff --git a/cybox/bindings/library_object.py b/cybox/bindings/library_object.py index 2994a537..0ebaf209 100644 --- a/cybox/bindings/library_object.py +++ b/cybox/bindings/library_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/link_object.py b/cybox/bindings/link_object.py index 55b96db5..9095b412 100644 --- a/cybox/bindings/link_object.py +++ b/cybox/bindings/link_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import uri_object diff --git a/cybox/bindings/linux_package_object.py b/cybox/bindings/linux_package_object.py index bc080c40..ab74c80e 100644 --- a/cybox/bindings/linux_package_object.py +++ b/cybox/bindings/linux_package_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/memory_object.py b/cybox/bindings/memory_object.py index 3d1a4303..7e6dc7cf 100644 --- a/cybox/bindings/memory_object.py +++ b/cybox/bindings/memory_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/mutex_object.py b/cybox/bindings/mutex_object.py index cd9fa110..ecd5d6b0 100644 --- a/cybox/bindings/mutex_object.py +++ b/cybox/bindings/mutex_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/network_connection_object.py b/cybox/bindings/network_connection_object.py index 26713ba7..2000144a 100644 --- a/cybox/bindings/network_connection_object.py +++ b/cybox/bindings/network_connection_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import dns_query_object from . import http_session_object diff --git a/cybox/bindings/network_flow_object.py b/cybox/bindings/network_flow_object.py index 33700c6d..1b8c90b8 100644 --- a/cybox/bindings/network_flow_object.py +++ b/cybox/bindings/network_flow_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object from . import network_packet_object diff --git a/cybox/bindings/network_packet_object.py b/cybox/bindings/network_packet_object.py index b152df8a..c4af75b0 100644 --- a/cybox/bindings/network_packet_object.py +++ b/cybox/bindings/network_packet_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object from . import port_object diff --git a/cybox/bindings/network_route_entry_object.py b/cybox/bindings/network_route_entry_object.py index a8a1ec3e..2e2c5143 100644 --- a/cybox/bindings/network_route_entry_object.py +++ b/cybox/bindings/network_route_entry_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object diff --git a/cybox/bindings/network_route_object.py b/cybox/bindings/network_route_object.py index 00753109..b34c5b34 100644 --- a/cybox/bindings/network_route_object.py +++ b/cybox/bindings/network_route_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import network_route_entry_object diff --git a/cybox/bindings/network_socket_object.py b/cybox/bindings/network_socket_object.py index 94c08deb..e73f6e03 100644 --- a/cybox/bindings/network_socket_object.py +++ b/cybox/bindings/network_socket_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import socket_address_object diff --git a/cybox/bindings/network_subnet_object.py b/cybox/bindings/network_subnet_object.py index b49fd7a6..834bb2e8 100644 --- a/cybox/bindings/network_subnet_object.py +++ b/cybox/bindings/network_subnet_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object from . import network_route_entry_object diff --git a/cybox/bindings/pdf_file_object.py b/cybox/bindings/pdf_file_object.py index 35b5ac2b..5c307d0b 100644 --- a/cybox/bindings/pdf_file_object.py +++ b/cybox/bindings/pdf_file_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import file_object diff --git a/cybox/bindings/pipe_object.py b/cybox/bindings/pipe_object.py index 4a4246cc..0dd86d31 100644 --- a/cybox/bindings/pipe_object.py +++ b/cybox/bindings/pipe_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/port_object.py b/cybox/bindings/port_object.py index 6dd05247..ca64eb00 100644 --- a/cybox/bindings/port_object.py +++ b/cybox/bindings/port_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/process_object.py b/cybox/bindings/process_object.py index 53b7a21d..71504cba 100644 --- a/cybox/bindings/process_object.py +++ b/cybox/bindings/process_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import network_connection_object from . import port_object diff --git a/cybox/bindings/product_object.py b/cybox/bindings/product_object.py index 55c74e5d..07866d30 100644 --- a/cybox/bindings/product_object.py +++ b/cybox/bindings/product_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/semaphore_object.py b/cybox/bindings/semaphore_object.py index 5f33d575..4bf99dad 100644 --- a/cybox/bindings/semaphore_object.py +++ b/cybox/bindings/semaphore_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/sms_message_object.py b/cybox/bindings/sms_message_object.py index a5c20ed5..8ecfb7a4 100644 --- a/cybox/bindings/sms_message_object.py +++ b/cybox/bindings/sms_message_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/socket_address_object.py b/cybox/bindings/socket_address_object.py index a5cf1110..3dd7365f 100644 --- a/cybox/bindings/socket_address_object.py +++ b/cybox/bindings/socket_address_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object from . import hostname_object diff --git a/cybox/bindings/system_object.py b/cybox/bindings/system_object.py index 1b1d65a7..fbc68c0c 100644 --- a/cybox/bindings/system_object.py +++ b/cybox/bindings/system_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object diff --git a/cybox/bindings/unix_file_object.py b/cybox/bindings/unix_file_object.py index d840d69e..53321c18 100644 --- a/cybox/bindings/unix_file_object.py +++ b/cybox/bindings/unix_file_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import file_object diff --git a/cybox/bindings/unix_network_route_entry_object.py b/cybox/bindings/unix_network_route_entry_object.py index 8113bc2f..6c246a92 100644 --- a/cybox/bindings/unix_network_route_entry_object.py +++ b/cybox/bindings/unix_network_route_entry_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import network_route_entry_object diff --git a/cybox/bindings/unix_pipe_object.py b/cybox/bindings/unix_pipe_object.py index 78007722..171403ff 100644 --- a/cybox/bindings/unix_pipe_object.py +++ b/cybox/bindings/unix_pipe_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import pipe_object diff --git a/cybox/bindings/unix_process_object.py b/cybox/bindings/unix_process_object.py index 08d449fa..17d24ebb 100644 --- a/cybox/bindings/unix_process_object.py +++ b/cybox/bindings/unix_process_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import process_object diff --git a/cybox/bindings/unix_user_account_object.py b/cybox/bindings/unix_user_account_object.py index aecc41c8..4aee8159 100644 --- a/cybox/bindings/unix_user_account_object.py +++ b/cybox/bindings/unix_user_account_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import user_account_object diff --git a/cybox/bindings/unix_volume_object.py b/cybox/bindings/unix_volume_object.py index 9eccc620..06e0f16d 100644 --- a/cybox/bindings/unix_volume_object.py +++ b/cybox/bindings/unix_volume_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import volume_object diff --git a/cybox/bindings/uri_object.py b/cybox/bindings/uri_object.py index 91668ad2..ed64784a 100644 --- a/cybox/bindings/uri_object.py +++ b/cybox/bindings/uri_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/url_history_object.py b/cybox/bindings/url_history_object.py index c7c88ce5..f88690cd 100644 --- a/cybox/bindings/url_history_object.py +++ b/cybox/bindings/url_history_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import hostname_object from . import uri_object diff --git a/cybox/bindings/user_account_object.py b/cybox/bindings/user_account_object.py index ade961a1..c20cb1bb 100644 --- a/cybox/bindings/user_account_object.py +++ b/cybox/bindings/user_account_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import account_object diff --git a/cybox/bindings/user_session_object.py b/cybox/bindings/user_session_object.py index 097e2b85..1241287d 100644 --- a/cybox/bindings/user_session_object.py +++ b/cybox/bindings/user_session_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/volume_object.py b/cybox/bindings/volume_object.py index eb6da25c..34b2babd 100644 --- a/cybox/bindings/volume_object.py +++ b/cybox/bindings/volume_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/whois_object.py b/cybox/bindings/whois_object.py index 68b5241a..a05049d1 100644 --- a/cybox/bindings/whois_object.py +++ b/cybox/bindings/whois_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object from . import uri_object diff --git a/cybox/bindings/win_computer_account_object.py b/cybox/bindings/win_computer_account_object.py index 3a445a24..1fffa05f 100644 --- a/cybox/bindings/win_computer_account_object.py +++ b/cybox/bindings/win_computer_account_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import account_object from . import port_object diff --git a/cybox/bindings/win_critical_section_object.py b/cybox/bindings/win_critical_section_object.py index 78ca545d..2d93189d 100644 --- a/cybox/bindings/win_critical_section_object.py +++ b/cybox/bindings/win_critical_section_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/win_driver_object.py b/cybox/bindings/win_driver_object.py index e89bb857..e63c58a1 100644 --- a/cybox/bindings/win_driver_object.py +++ b/cybox/bindings/win_driver_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import win_executable_file_object diff --git a/cybox/bindings/win_event_log_object.py b/cybox/bindings/win_event_log_object.py index e1b2c2c1..f52e3e07 100644 --- a/cybox/bindings/win_event_log_object.py +++ b/cybox/bindings/win_event_log_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/win_event_object.py b/cybox/bindings/win_event_object.py index e735a870..ed320d1d 100644 --- a/cybox/bindings/win_event_object.py +++ b/cybox/bindings/win_event_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import win_handle_object diff --git a/cybox/bindings/win_executable_file_object.py b/cybox/bindings/win_executable_file_object.py index 27ae5374..3697c2ff 100644 --- a/cybox/bindings/win_executable_file_object.py +++ b/cybox/bindings/win_executable_file_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import win_file_object diff --git a/cybox/bindings/win_file_object.py b/cybox/bindings/win_file_object.py index 81617776..f2d8bf65 100644 --- a/cybox/bindings/win_file_object.py +++ b/cybox/bindings/win_file_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import file_object diff --git a/cybox/bindings/win_filemapping_object.py b/cybox/bindings/win_filemapping_object.py index d98a3912..cbda4783 100644 --- a/cybox/bindings/win_filemapping_object.py +++ b/cybox/bindings/win_filemapping_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import win_handle_object diff --git a/cybox/bindings/win_handle_object.py b/cybox/bindings/win_handle_object.py index 68d5a5a9..09c5b3b9 100644 --- a/cybox/bindings/win_handle_object.py +++ b/cybox/bindings/win_handle_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/win_hook_object.py b/cybox/bindings/win_hook_object.py index a98b37d5..96f9638b 100644 --- a/cybox/bindings/win_hook_object.py +++ b/cybox/bindings/win_hook_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import library_object from . import win_handle_object diff --git a/cybox/bindings/win_kernel_hook_object.py b/cybox/bindings/win_kernel_hook_object.py index b0152294..e38f6fc3 100644 --- a/cybox/bindings/win_kernel_hook_object.py +++ b/cybox/bindings/win_kernel_hook_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/win_kernel_object.py b/cybox/bindings/win_kernel_object.py index d328aac7..bd0cadb6 100644 --- a/cybox/bindings/win_kernel_object.py +++ b/cybox/bindings/win_kernel_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/win_mailslot_object.py b/cybox/bindings/win_mailslot_object.py index d7d6a143..0af75a93 100644 --- a/cybox/bindings/win_mailslot_object.py +++ b/cybox/bindings/win_mailslot_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import win_handle_object diff --git a/cybox/bindings/win_memory_page_region_object.py b/cybox/bindings/win_memory_page_region_object.py index e1392d0e..df8bb020 100644 --- a/cybox/bindings/win_memory_page_region_object.py +++ b/cybox/bindings/win_memory_page_region_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import memory_object diff --git a/cybox/bindings/win_mutex_object.py b/cybox/bindings/win_mutex_object.py index 6b843ab3..d5e7aed7 100644 --- a/cybox/bindings/win_mutex_object.py +++ b/cybox/bindings/win_mutex_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import mutex_object from . import win_handle_object diff --git a/cybox/bindings/win_network_route_entry_object.py b/cybox/bindings/win_network_route_entry_object.py index 6c3064fc..0b0f8f33 100644 --- a/cybox/bindings/win_network_route_entry_object.py +++ b/cybox/bindings/win_network_route_entry_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import address_object from . import network_route_entry_object diff --git a/cybox/bindings/win_network_share_object.py b/cybox/bindings/win_network_share_object.py index 0c2c71f4..feb6a72f 100644 --- a/cybox/bindings/win_network_share_object.py +++ b/cybox/bindings/win_network_share_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/win_pipe_object.py b/cybox/bindings/win_pipe_object.py index 94213ffb..7976d350 100644 --- a/cybox/bindings/win_pipe_object.py +++ b/cybox/bindings/win_pipe_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import pipe_object from . import win_handle_object diff --git a/cybox/bindings/win_prefetch_object.py b/cybox/bindings/win_prefetch_object.py index 6371adfc..509f98dc 100644 --- a/cybox/bindings/win_prefetch_object.py +++ b/cybox/bindings/win_prefetch_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import device_object from . import win_volume_object diff --git a/cybox/bindings/win_process_object.py b/cybox/bindings/win_process_object.py index eac1ecd6..4368bbf3 100644 --- a/cybox/bindings/win_process_object.py +++ b/cybox/bindings/win_process_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import memory_object from . import process_object diff --git a/cybox/bindings/win_registry_key_object.py b/cybox/bindings/win_registry_key_object.py index 03fbe824..894f5792 100644 --- a/cybox/bindings/win_registry_key_object.py +++ b/cybox/bindings/win_registry_key_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import win_handle_object diff --git a/cybox/bindings/win_semaphore_object.py b/cybox/bindings/win_semaphore_object.py index 0ee5e51d..cc20347c 100644 --- a/cybox/bindings/win_semaphore_object.py +++ b/cybox/bindings/win_semaphore_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import semaphore_object from . import win_handle_object diff --git a/cybox/bindings/win_service_object.py b/cybox/bindings/win_service_object.py index 23f6fdb6..6d284749 100644 --- a/cybox/bindings/win_service_object.py +++ b/cybox/bindings/win_service_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import win_process_object diff --git a/cybox/bindings/win_system_object.py b/cybox/bindings/win_system_object.py index c3a018d0..733bacba 100644 --- a/cybox/bindings/win_system_object.py +++ b/cybox/bindings/win_system_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import system_object from . import win_handle_object diff --git a/cybox/bindings/win_system_restore_object.py b/cybox/bindings/win_system_restore_object.py index fda48109..3a62b96f 100644 --- a/cybox/bindings/win_system_restore_object.py +++ b/cybox/bindings/win_system_restore_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/bindings/win_task_object.py b/cybox/bindings/win_task_object.py index 6f523960..6ef3c25a 100644 --- a/cybox/bindings/win_task_object.py +++ b/cybox/bindings/win_task_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import email_message_object diff --git a/cybox/bindings/win_thread_object.py b/cybox/bindings/win_thread_object.py index 162469cb..c4c57dac 100644 --- a/cybox/bindings/win_thread_object.py +++ b/cybox/bindings/win_thread_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import win_handle_object diff --git a/cybox/bindings/win_user_account_object.py b/cybox/bindings/win_user_account_object.py index c521f8fb..fb94609a 100644 --- a/cybox/bindings/win_user_account_object.py +++ b/cybox/bindings/win_user_account_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import user_account_object diff --git a/cybox/bindings/win_volume_object.py b/cybox/bindings/win_volume_object.py index e3bdc4ec..909addd2 100644 --- a/cybox/bindings/win_volume_object.py +++ b/cybox/bindings/win_volume_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import volume_object diff --git a/cybox/bindings/win_waitable_timer_object.py b/cybox/bindings/win_waitable_timer_object.py index 95ad2597..ba6d44cb 100644 --- a/cybox/bindings/win_waitable_timer_object.py +++ b/cybox/bindings/win_waitable_timer_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common from . import win_handle_object diff --git a/cybox/bindings/x509_certificate_object.py b/cybox/bindings/x509_certificate_object.py index c915b9b1..4bb75871 100644 --- a/cybox/bindings/x509_certificate_object.py +++ b/cybox/bindings/x509_certificate_object.py @@ -3,7 +3,7 @@ import sys -from cybox.bindings import * +from mixbox.binding_utils import * from . import cybox_common diff --git a/cybox/test/__init__.py b/cybox/test/__init__.py index bc90afc5..939e9280 100644 --- a/cybox/test/__init__.py +++ b/cybox/test/__init__.py @@ -4,9 +4,9 @@ import json import unittest +from mixbox.binding_utils import ExternalEncoding import six -import cybox.bindings as bindings from cybox import Entity, EntityList, TypedField import cybox.bindings.cybox_core as core_binding from cybox.core import Observables @@ -86,12 +86,12 @@ def round_trip(o, output=False, list_=False): xobj = o2.to_obj() # 6. Bindings Object -> XML String - xml_string = o2.to_xml(encoding=bindings.ExternalEncoding) + xml_string = o2.to_xml(encoding=ExternalEncoding) # Explicitly check to see if it's a Unicode string before trying to decode # it. if not isinstance(xml_string, six.text_type): - xml_string = xml_string.decode(bindings.ExternalEncoding) + xml_string = xml_string.decode(ExternalEncoding) if output: print(xml_string) diff --git a/cybox/test/encoding_test.py b/cybox/test/encoding_test.py index 7a5af9de..8d6ec52f 100644 --- a/cybox/test/encoding_test.py +++ b/cybox/test/encoding_test.py @@ -56,73 +56,6 @@ def test_whois(self): o.dnssec = UNICODE_STR o2 = round_trip(o) - def test_quote_xml(self): - s = bindings.quote_xml(UNICODE_STR) - self.assertEqual(s, UNICODE_STR) - - def test_quote_attrib(self): - """Tests that the stix.bindings.quote_attrib method works properly - on Unicode inputs. - - Note: - The quote_attrib method (more specifically, saxutils.quoteattr()) - adds quotation marks around the input data, so we need to strip - the leading and trailing chars to test effectively - """ - s = bindings.quote_attrib(UNICODE_STR) - s = s[1:-1] - self.assertEqual(s, UNICODE_STR) - - def test_quote_attrib_int(self): - i = 65536 - s = bindings.quote_attrib(i) - self.assertEqual(u('"65536"'), s) - - def test_quote_attrib_bool(self): - b = True - s = bindings.quote_attrib(b) - self.assertEqual(u('"True"'), s) - - def test_quote_xml_int(self): - i = 65536 - s = bindings.quote_xml(i) - self.assertEqual(six.text_type(i), s) - - def test_quote_xml_bool(self): - b = True - s = bindings.quote_xml(b) - self.assertEqual(six.text_type(b), s) - - def test_quote_xml_zero(self): - i = 0 - s = bindings.quote_xml(i) - self.assertEqual(six.text_type(i), s) - - def test_quote_attrib_zero(self): - i = 0 - s = bindings.quote_attrib(i) - self.assertEqual(u('"0"'), s) - - def test_quote_xml_none(self): - i = None - s = bindings.quote_xml(i) - self.assertEqual(u(''), s) - - def test_quote_attrib_none(self): - i = None - s = bindings.quote_attrib(i) - self.assertEqual(u('""'), s) - - def test_quote_attrib_empty(self): - i = '' - s = bindings.quote_attrib(i) - self.assertEqual(u('""'), s) - - def test_quote_xml_empty(self): - i = '' - s = bindings.quote_xml(i) - self.assertEqual(u(''), s) - def test_to_xml_utf16_encoded(self): encoding = 'utf-16' o = Observable() From f677c897b60e91d8ed01a884857113dd5de438fd Mon Sep 17 00:00:00 2001 From: Greg Back Date: Mon, 4 May 2015 20:27:42 -0500 Subject: [PATCH 12/17] Add mixbox to dependencies --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e8949480..af93fe4e 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def get_version(): with open('README.rst') as f: readme = f.read() -install_requires = ['lxml>=2.2.3', 'python-dateutil', 'six>=1.9.0'] +install_requires = ['mixbox', 'lxml>=2.2.3', 'python-dateutil', 'six>=1.9.0'] try: import importlib except ImportError: From d40ca1c8af8f31e35d493ea59bbe840828f69ab8 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 14 May 2015 14:17:55 -0500 Subject: [PATCH 13/17] Use mixbox's copy of six --- cybox/__init__.py | 2 +- cybox/bindings/account_object.py | 2 +- cybox/bindings/address_object.py | 2 +- cybox/bindings/api_object.py | 2 +- cybox/bindings/archive_file_object.py | 2 +- cybox/bindings/arp_cache_object.py | 2 +- cybox/bindings/artifact_object.py | 2 +- cybox/bindings/as_object.py | 2 +- cybox/bindings/code_object.py | 2 +- cybox/bindings/custom_object.py | 2 +- cybox/bindings/cybox_common.py | 2 +- cybox/bindings/cybox_core.py | 2 +- cybox/bindings/device_object.py | 2 +- cybox/bindings/disk_object.py | 2 +- cybox/bindings/disk_partition_object.py | 2 +- cybox/bindings/dns_cache_object.py | 2 +- cybox/bindings/dns_query_object.py | 2 +- cybox/bindings/dns_record_object.py | 2 +- cybox/bindings/domain_name_object.py | 2 +- cybox/bindings/email_message_object.py | 2 +- cybox/bindings/extensions/location/ciq_address_3_0.py | 2 +- cybox/bindings/file_object.py | 2 +- cybox/bindings/gui_dialogbox_object.py | 2 +- cybox/bindings/gui_object.py | 2 +- cybox/bindings/gui_window_object.py | 2 +- cybox/bindings/hostname_object.py | 2 +- cybox/bindings/http_session_object.py | 2 +- cybox/bindings/image_file_object.py | 2 +- cybox/bindings/library_object.py | 2 +- cybox/bindings/link_object.py | 2 +- cybox/bindings/linux_package_object.py | 2 +- cybox/bindings/memory_object.py | 2 +- cybox/bindings/mutex_object.py | 2 +- cybox/bindings/network_connection_object.py | 2 +- cybox/bindings/network_flow_object.py | 2 +- cybox/bindings/network_packet_object.py | 2 +- cybox/bindings/network_route_entry_object.py | 2 +- cybox/bindings/network_route_object.py | 2 +- cybox/bindings/network_socket_object.py | 2 +- cybox/bindings/network_subnet_object.py | 2 +- cybox/bindings/pdf_file_object.py | 2 +- cybox/bindings/pipe_object.py | 2 +- cybox/bindings/port_object.py | 2 +- cybox/bindings/process_object.py | 2 +- cybox/bindings/product_object.py | 2 +- cybox/bindings/semaphore_object.py | 2 +- cybox/bindings/sms_message_object.py | 2 +- cybox/bindings/socket_address_object.py | 2 +- cybox/bindings/system_object.py | 2 +- cybox/bindings/unix_file_object.py | 2 +- cybox/bindings/unix_network_route_entry_object.py | 2 +- cybox/bindings/unix_pipe_object.py | 2 +- cybox/bindings/unix_process_object.py | 2 +- cybox/bindings/unix_user_account_object.py | 2 +- cybox/bindings/unix_volume_object.py | 2 +- cybox/bindings/uri_object.py | 2 +- cybox/bindings/url_history_object.py | 2 +- cybox/bindings/user_account_object.py | 2 +- cybox/bindings/user_session_object.py | 2 +- cybox/bindings/volume_object.py | 2 +- cybox/bindings/whois_object.py | 2 +- cybox/bindings/win_computer_account_object.py | 2 +- cybox/bindings/win_critical_section_object.py | 2 +- cybox/bindings/win_driver_object.py | 2 +- cybox/bindings/win_event_log_object.py | 2 +- cybox/bindings/win_event_object.py | 2 +- cybox/bindings/win_executable_file_object.py | 2 +- cybox/bindings/win_file_object.py | 2 +- cybox/bindings/win_filemapping_object.py | 2 +- cybox/bindings/win_handle_object.py | 2 +- cybox/bindings/win_hook_object.py | 2 +- cybox/bindings/win_kernel_hook_object.py | 2 +- cybox/bindings/win_kernel_object.py | 2 +- cybox/bindings/win_mailslot_object.py | 2 +- cybox/bindings/win_memory_page_region_object.py | 2 +- cybox/bindings/win_mutex_object.py | 2 +- cybox/bindings/win_network_route_entry_object.py | 2 +- cybox/bindings/win_network_share_object.py | 2 +- cybox/bindings/win_pipe_object.py | 2 +- cybox/bindings/win_prefetch_object.py | 2 +- cybox/bindings/win_process_object.py | 2 +- cybox/bindings/win_registry_key_object.py | 2 +- cybox/bindings/win_semaphore_object.py | 2 +- cybox/bindings/win_service_object.py | 2 +- cybox/bindings/win_system_object.py | 2 +- cybox/bindings/win_system_restore_object.py | 2 +- cybox/bindings/win_task_object.py | 2 +- cybox/bindings/win_thread_object.py | 2 +- cybox/bindings/win_user_account_object.py | 2 +- cybox/bindings/win_volume_object.py | 2 +- cybox/bindings/win_waitable_timer_object.py | 2 +- cybox/bindings/x509_certificate_object.py | 2 +- cybox/common/hashes.py | 4 ++-- cybox/common/properties.py | 2 +- cybox/common/structured_text.py | 2 +- cybox/compat.py | 2 +- cybox/objects/address_object.py | 2 +- cybox/objects/artifact_object.py | 2 +- cybox/objects/uri_object.py | 2 +- cybox/test/__init__.py | 2 +- cybox/test/common/extracted_features_test.py | 2 +- cybox/test/common/extracted_string_test.py | 4 ++-- cybox/test/common/hash_test.py | 2 +- cybox/test/common/measuresource_test.py | 2 +- cybox/test/common/object_properties_test.py | 2 +- cybox/test/common/properties_test.py | 4 ++-- cybox/test/common/structured_test_text.py | 2 +- cybox/test/common/tools_test.py | 2 +- cybox/test/common/vocab_test.py | 2 +- cybox/test/core/action_test.py | 2 +- cybox/test/core/event_test.py | 2 +- cybox/test/core/frequency_test.py | 2 +- cybox/test/core/object_test.py | 2 +- cybox/test/core/observable_test.py | 2 +- cybox/test/encoding_test.py | 4 ++-- cybox/test/objects/address_test.py | 2 +- cybox/test/objects/archive_file_test.py | 2 +- cybox/test/objects/arp_cache_test.py | 2 +- cybox/test/objects/artifact_test.py | 4 ++-- cybox/test/objects/as_test.py | 2 +- cybox/test/objects/code_test.py | 2 +- cybox/test/objects/domainname_test.py | 2 +- cybox/test/objects/email_message_test.py | 2 +- cybox/test/objects/file_test.py | 2 +- cybox/test/objects/http_session_test.py | 2 +- cybox/test/objects/image_file_test.py | 2 +- cybox/test/objects/memory_test.py | 2 +- cybox/test/objects/network_connection_test.py | 2 +- cybox/test/objects/network_packet_test.py | 2 +- cybox/test/objects/network_route_entry_test.py | 2 +- cybox/test/objects/network_socket_test.py | 2 +- cybox/test/objects/socket_address_test.py | 2 +- cybox/test/objects/uri_test.py | 2 +- cybox/test/objects/user_account_test.py | 2 +- cybox/test/objects/win_computer_account_test.py | 2 +- cybox/test/objects/win_critical_section_test.py | 2 +- cybox/test/objects/win_file_test.py | 2 +- cybox/test/objects/win_filemapping_test.py | 2 +- cybox/test/objects/win_hook_test.py | 2 +- cybox/test/objects/win_memory_page_region_test.py | 2 +- cybox/test/objects/win_network_route_entry_test.py | 2 +- cybox/test/objects/win_prefetch_test.py | 2 +- cybox/test/objects/win_registry_key_test.py | 2 +- cybox/test/objects/win_semaphore_test.py | 2 +- cybox/test/objects/win_system_restore_test.py | 2 +- cybox/test/objects/win_task_test.py | 2 +- cybox/test/objects/win_thread_test.py | 2 +- cybox/test/objects/win_user_test.py | 2 +- cybox/test/objects/win_waitable_timer_test.py | 2 +- cybox/utils/__init__.py | 2 +- setup.py | 2 +- 151 files changed, 156 insertions(+), 156 deletions(-) diff --git a/cybox/__init__.py b/cybox/__init__.py index 63ace6b1..18adba00 100644 --- a/cybox/__init__.py +++ b/cybox/__init__.py @@ -6,7 +6,7 @@ import json from mixbox.binding_utils import save_encoding -import six +from mixbox.vendor import six import cybox.utils.idgen from cybox.utils import Namespace, META, is_sequence diff --git a/cybox/bindings/account_object.py b/cybox/bindings/account_object.py index aa6f7663..94495e33 100644 --- a/cybox/bindings/account_object.py +++ b/cybox/bindings/account_object.py @@ -472,7 +472,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/address_object.py b/cybox/bindings/address_object.py index 37e328e4..13aa438a 100644 --- a/cybox/bindings/address_object.py +++ b/cybox/bindings/address_object.py @@ -305,7 +305,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/api_object.py b/cybox/bindings/api_object.py index 9e710a46..68c55988 100644 --- a/cybox/bindings/api_object.py +++ b/cybox/bindings/api_object.py @@ -266,7 +266,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/archive_file_object.py b/cybox/bindings/archive_file_object.py index 5af4be09..c38c1949 100644 --- a/cybox/bindings/archive_file_object.py +++ b/cybox/bindings/archive_file_object.py @@ -408,7 +408,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/arp_cache_object.py b/cybox/bindings/arp_cache_object.py index 9bafa328..5a3cb8e3 100644 --- a/cybox/bindings/arp_cache_object.py +++ b/cybox/bindings/arp_cache_object.py @@ -449,7 +449,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/artifact_object.py b/cybox/bindings/artifact_object.py index 1d1ae9e7..c4fa175c 100644 --- a/cybox/bindings/artifact_object.py +++ b/cybox/bindings/artifact_object.py @@ -762,7 +762,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/as_object.py b/cybox/bindings/as_object.py index 8280d353..e7e77eff 100644 --- a/cybox/bindings/as_object.py +++ b/cybox/bindings/as_object.py @@ -270,7 +270,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/code_object.py b/cybox/bindings/code_object.py index 35a2b67e..c61af331 100644 --- a/cybox/bindings/code_object.py +++ b/cybox/bindings/code_object.py @@ -789,7 +789,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/custom_object.py b/cybox/bindings/custom_object.py index 1c65f483..f773bc32 100644 --- a/cybox/bindings/custom_object.py +++ b/cybox/bindings/custom_object.py @@ -240,7 +240,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/cybox_common.py b/cybox/bindings/cybox_common.py index 12d21366..fa2fc98a 100644 --- a/cybox/bindings/cybox_common.py +++ b/cybox/bindings/cybox_common.py @@ -7821,7 +7821,7 @@ def parse(inFileName): def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/cybox_core.py b/cybox/bindings/cybox_core.py index ccd09823..c439b59d 100644 --- a/cybox/bindings/cybox_core.py +++ b/cybox/bindings/cybox_core.py @@ -3937,7 +3937,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/device_object.py b/cybox/bindings/device_object.py index 275dcde1..d50e1b7a 100644 --- a/cybox/bindings/device_object.py +++ b/cybox/bindings/device_object.py @@ -299,7 +299,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/disk_object.py b/cybox/bindings/disk_object.py index d84557b8..a1cb9d48 100644 --- a/cybox/bindings/disk_object.py +++ b/cybox/bindings/disk_object.py @@ -421,7 +421,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/disk_partition_object.py b/cybox/bindings/disk_partition_object.py index 3c43c94f..df44e564 100644 --- a/cybox/bindings/disk_partition_object.py +++ b/cybox/bindings/disk_partition_object.py @@ -408,7 +408,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/dns_cache_object.py b/cybox/bindings/dns_cache_object.py index 00332a1c..7aa0c2ba 100644 --- a/cybox/bindings/dns_cache_object.py +++ b/cybox/bindings/dns_cache_object.py @@ -311,7 +311,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/dns_query_object.py b/cybox/bindings/dns_query_object.py index c183a749..72209c8c 100644 --- a/cybox/bindings/dns_query_object.py +++ b/cybox/bindings/dns_query_object.py @@ -549,7 +549,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/dns_record_object.py b/cybox/bindings/dns_record_object.py index ad095756..b39696da 100644 --- a/cybox/bindings/dns_record_object.py +++ b/cybox/bindings/dns_record_object.py @@ -353,7 +353,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/domain_name_object.py b/cybox/bindings/domain_name_object.py index c983dd25..0d22f8d3 100644 --- a/cybox/bindings/domain_name_object.py +++ b/cybox/bindings/domain_name_object.py @@ -243,7 +243,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/email_message_object.py b/cybox/bindings/email_message_object.py index c29ef9a7..69eaf219 100644 --- a/cybox/bindings/email_message_object.py +++ b/cybox/bindings/email_message_object.py @@ -1095,7 +1095,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/extensions/location/ciq_address_3_0.py b/cybox/bindings/extensions/location/ciq_address_3_0.py index f4f46eb7..ae0ad707 100644 --- a/cybox/bindings/extensions/location/ciq_address_3_0.py +++ b/cybox/bindings/extensions/location/ciq_address_3_0.py @@ -247,7 +247,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/file_object.py b/cybox/bindings/file_object.py index ed5aad69..73a4d41c 100644 --- a/cybox/bindings/file_object.py +++ b/cybox/bindings/file_object.py @@ -1315,7 +1315,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/gui_dialogbox_object.py b/cybox/bindings/gui_dialogbox_object.py index 32cbdb38..9cd07ff2 100644 --- a/cybox/bindings/gui_dialogbox_object.py +++ b/cybox/bindings/gui_dialogbox_object.py @@ -237,7 +237,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/gui_object.py b/cybox/bindings/gui_object.py index 2c5fdf64..793800c2 100644 --- a/cybox/bindings/gui_object.py +++ b/cybox/bindings/gui_object.py @@ -233,7 +233,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/gui_window_object.py b/cybox/bindings/gui_window_object.py index d3513564..f12082b4 100644 --- a/cybox/bindings/gui_window_object.py +++ b/cybox/bindings/gui_window_object.py @@ -247,7 +247,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/hostname_object.py b/cybox/bindings/hostname_object.py index eb7e165a..46374ba3 100644 --- a/cybox/bindings/hostname_object.py +++ b/cybox/bindings/hostname_object.py @@ -260,7 +260,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/http_session_object.py b/cybox/bindings/http_session_object.py index a08f3fd0..f2c6ed0d 100644 --- a/cybox/bindings/http_session_object.py +++ b/cybox/bindings/http_session_object.py @@ -1994,7 +1994,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/image_file_object.py b/cybox/bindings/image_file_object.py index faff5ffe..49fc46d0 100644 --- a/cybox/bindings/image_file_object.py +++ b/cybox/bindings/image_file_object.py @@ -400,7 +400,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/library_object.py b/cybox/bindings/library_object.py index 0ebaf209..cf5a0d36 100644 --- a/cybox/bindings/library_object.py +++ b/cybox/bindings/library_object.py @@ -362,7 +362,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/link_object.py b/cybox/bindings/link_object.py index 9095b412..72418875 100644 --- a/cybox/bindings/link_object.py +++ b/cybox/bindings/link_object.py @@ -189,7 +189,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/linux_package_object.py b/cybox/bindings/linux_package_object.py index ab74c80e..901b0630 100644 --- a/cybox/bindings/linux_package_object.py +++ b/cybox/bindings/linux_package_object.py @@ -310,7 +310,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/memory_object.py b/cybox/bindings/memory_object.py index 7e6dc7cf..ff210a90 100644 --- a/cybox/bindings/memory_object.py +++ b/cybox/bindings/memory_object.py @@ -442,7 +442,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/mutex_object.py b/cybox/bindings/mutex_object.py index ecd5d6b0..acf3af9b 100644 --- a/cybox/bindings/mutex_object.py +++ b/cybox/bindings/mutex_object.py @@ -237,7 +237,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_connection_object.py b/cybox/bindings/network_connection_object.py index 2000144a..7f0f35f5 100644 --- a/cybox/bindings/network_connection_object.py +++ b/cybox/bindings/network_connection_object.py @@ -658,7 +658,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_flow_object.py b/cybox/bindings/network_flow_object.py index 1b8c90b8..efc40ccc 100644 --- a/cybox/bindings/network_flow_object.py +++ b/cybox/bindings/network_flow_object.py @@ -5155,7 +5155,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_packet_object.py b/cybox/bindings/network_packet_object.py index c4af75b0..5e9c7a5b 100644 --- a/cybox/bindings/network_packet_object.py +++ b/cybox/bindings/network_packet_object.py @@ -9008,7 +9008,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_route_entry_object.py b/cybox/bindings/network_route_entry_object.py index 2e2c5143..4f0e04fd 100644 --- a/cybox/bindings/network_route_entry_object.py +++ b/cybox/bindings/network_route_entry_object.py @@ -500,7 +500,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_route_object.py b/cybox/bindings/network_route_object.py index b34c5b34..8dd76c00 100644 --- a/cybox/bindings/network_route_object.py +++ b/cybox/bindings/network_route_object.py @@ -420,7 +420,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_socket_object.py b/cybox/bindings/network_socket_object.py index e73f6e03..4ca47890 100644 --- a/cybox/bindings/network_socket_object.py +++ b/cybox/bindings/network_socket_object.py @@ -982,7 +982,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/network_subnet_object.py b/cybox/bindings/network_subnet_object.py index 834bb2e8..3429c230 100644 --- a/cybox/bindings/network_subnet_object.py +++ b/cybox/bindings/network_subnet_object.py @@ -339,7 +339,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/pdf_file_object.py b/cybox/bindings/pdf_file_object.py index 5c307d0b..98ea572e 100644 --- a/cybox/bindings/pdf_file_object.py +++ b/cybox/bindings/pdf_file_object.py @@ -2190,7 +2190,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/pipe_object.py b/cybox/bindings/pipe_object.py index 0dd86d31..cdfd04a4 100644 --- a/cybox/bindings/pipe_object.py +++ b/cybox/bindings/pipe_object.py @@ -236,7 +236,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/port_object.py b/cybox/bindings/port_object.py index ca64eb00..2b49a30f 100644 --- a/cybox/bindings/port_object.py +++ b/cybox/bindings/port_object.py @@ -308,7 +308,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/process_object.py b/cybox/bindings/process_object.py index 71504cba..d0cb09d4 100644 --- a/cybox/bindings/process_object.py +++ b/cybox/bindings/process_object.py @@ -933,7 +933,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/product_object.py b/cybox/bindings/product_object.py index 07866d30..c907a8c2 100644 --- a/cybox/bindings/product_object.py +++ b/cybox/bindings/product_object.py @@ -276,7 +276,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/semaphore_object.py b/cybox/bindings/semaphore_object.py index 4bf99dad..63a759a4 100644 --- a/cybox/bindings/semaphore_object.py +++ b/cybox/bindings/semaphore_object.py @@ -265,7 +265,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/sms_message_object.py b/cybox/bindings/sms_message_object.py index 8ecfb7a4..3c3aa762 100644 --- a/cybox/bindings/sms_message_object.py +++ b/cybox/bindings/sms_message_object.py @@ -344,7 +344,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/socket_address_object.py b/cybox/bindings/socket_address_object.py index 3dd7365f..71834973 100644 --- a/cybox/bindings/socket_address_object.py +++ b/cybox/bindings/socket_address_object.py @@ -248,7 +248,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/system_object.py b/cybox/bindings/system_object.py index fbc68c0c..3da4b31c 100644 --- a/cybox/bindings/system_object.py +++ b/cybox/bindings/system_object.py @@ -1272,7 +1272,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_file_object.py b/cybox/bindings/unix_file_object.py index 53321c18..b0714c66 100644 --- a/cybox/bindings/unix_file_object.py +++ b/cybox/bindings/unix_file_object.py @@ -589,7 +589,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_network_route_entry_object.py b/cybox/bindings/unix_network_route_entry_object.py index 6c246a92..4270be6e 100644 --- a/cybox/bindings/unix_network_route_entry_object.py +++ b/cybox/bindings/unix_network_route_entry_object.py @@ -282,7 +282,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_pipe_object.py b/cybox/bindings/unix_pipe_object.py index 171403ff..60596616 100644 --- a/cybox/bindings/unix_pipe_object.py +++ b/cybox/bindings/unix_pipe_object.py @@ -223,7 +223,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_process_object.py b/cybox/bindings/unix_process_object.py index 17d24ebb..82ba1128 100644 --- a/cybox/bindings/unix_process_object.py +++ b/cybox/bindings/unix_process_object.py @@ -583,7 +583,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_user_account_object.py b/cybox/bindings/unix_user_account_object.py index 4aee8159..1a7678c5 100644 --- a/cybox/bindings/unix_user_account_object.py +++ b/cybox/bindings/unix_user_account_object.py @@ -403,7 +403,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/unix_volume_object.py b/cybox/bindings/unix_volume_object.py index 06e0f16d..9c81fd22 100644 --- a/cybox/bindings/unix_volume_object.py +++ b/cybox/bindings/unix_volume_object.py @@ -245,7 +245,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/uri_object.py b/cybox/bindings/uri_object.py index ed64784a..75386fd9 100644 --- a/cybox/bindings/uri_object.py +++ b/cybox/bindings/uri_object.py @@ -232,7 +232,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/url_history_object.py b/cybox/bindings/url_history_object.py index f88690cd..59dfbdf5 100644 --- a/cybox/bindings/url_history_object.py +++ b/cybox/bindings/url_history_object.py @@ -430,7 +430,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/user_account_object.py b/cybox/bindings/user_account_object.py index c20cb1bb..619b14b0 100644 --- a/cybox/bindings/user_account_object.py +++ b/cybox/bindings/user_account_object.py @@ -594,7 +594,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/user_session_object.py b/cybox/bindings/user_session_object.py index 1241287d..2be48fb2 100644 --- a/cybox/bindings/user_session_object.py +++ b/cybox/bindings/user_session_object.py @@ -280,7 +280,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/volume_object.py b/cybox/bindings/volume_object.py index 34b2babd..d6f85fbf 100644 --- a/cybox/bindings/volume_object.py +++ b/cybox/bindings/volume_object.py @@ -545,7 +545,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/whois_object.py b/cybox/bindings/whois_object.py index a05049d1..5d4040b3 100644 --- a/cybox/bindings/whois_object.py +++ b/cybox/bindings/whois_object.py @@ -1165,7 +1165,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_computer_account_object.py b/cybox/bindings/win_computer_account_object.py index 1fffa05f..ed5e522f 100644 --- a/cybox/bindings/win_computer_account_object.py +++ b/cybox/bindings/win_computer_account_object.py @@ -603,7 +603,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_critical_section_object.py b/cybox/bindings/win_critical_section_object.py index 2d93189d..cfbc6b5d 100644 --- a/cybox/bindings/win_critical_section_object.py +++ b/cybox/bindings/win_critical_section_object.py @@ -235,7 +235,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_driver_object.py b/cybox/bindings/win_driver_object.py index e63c58a1..3eb8c710 100644 --- a/cybox/bindings/win_driver_object.py +++ b/cybox/bindings/win_driver_object.py @@ -830,7 +830,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_event_log_object.py b/cybox/bindings/win_event_log_object.py index f52e3e07..a73907be 100644 --- a/cybox/bindings/win_event_log_object.py +++ b/cybox/bindings/win_event_log_object.py @@ -499,7 +499,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_event_object.py b/cybox/bindings/win_event_object.py index ed320d1d..e509b540 100644 --- a/cybox/bindings/win_event_object.py +++ b/cybox/bindings/win_event_object.py @@ -324,7 +324,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_executable_file_object.py b/cybox/bindings/win_executable_file_object.py index 3697c2ff..f52e9812 100644 --- a/cybox/bindings/win_executable_file_object.py +++ b/cybox/bindings/win_executable_file_object.py @@ -3515,7 +3515,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_file_object.py b/cybox/bindings/win_file_object.py index f2d8bf65..3ab7c28e 100644 --- a/cybox/bindings/win_file_object.py +++ b/cybox/bindings/win_file_object.py @@ -768,7 +768,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_filemapping_object.py b/cybox/bindings/win_filemapping_object.py index cbda4783..5d8ad474 100644 --- a/cybox/bindings/win_filemapping_object.py +++ b/cybox/bindings/win_filemapping_object.py @@ -452,7 +452,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_handle_object.py b/cybox/bindings/win_handle_object.py index 09c5b3b9..ed33daac 100644 --- a/cybox/bindings/win_handle_object.py +++ b/cybox/bindings/win_handle_object.py @@ -425,7 +425,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_hook_object.py b/cybox/bindings/win_hook_object.py index 96f9638b..d7f453a9 100644 --- a/cybox/bindings/win_hook_object.py +++ b/cybox/bindings/win_hook_object.py @@ -357,7 +357,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_kernel_hook_object.py b/cybox/bindings/win_kernel_hook_object.py index e38f6fc3..c2de42b4 100644 --- a/cybox/bindings/win_kernel_hook_object.py +++ b/cybox/bindings/win_kernel_hook_object.py @@ -377,7 +377,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_kernel_object.py b/cybox/bindings/win_kernel_object.py index bd0cadb6..b17e5675 100644 --- a/cybox/bindings/win_kernel_object.py +++ b/cybox/bindings/win_kernel_object.py @@ -596,7 +596,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_mailslot_object.py b/cybox/bindings/win_mailslot_object.py index 0af75a93..001be80c 100644 --- a/cybox/bindings/win_mailslot_object.py +++ b/cybox/bindings/win_mailslot_object.py @@ -274,7 +274,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_memory_page_region_object.py b/cybox/bindings/win_memory_page_region_object.py index df8bb020..6e6ada56 100644 --- a/cybox/bindings/win_memory_page_region_object.py +++ b/cybox/bindings/win_memory_page_region_object.py @@ -496,7 +496,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_mutex_object.py b/cybox/bindings/win_mutex_object.py index d5e7aed7..3b65f0b3 100644 --- a/cybox/bindings/win_mutex_object.py +++ b/cybox/bindings/win_mutex_object.py @@ -241,7 +241,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_network_route_entry_object.py b/cybox/bindings/win_network_route_entry_object.py index 0b0f8f33..97003632 100644 --- a/cybox/bindings/win_network_route_entry_object.py +++ b/cybox/bindings/win_network_route_entry_object.py @@ -398,7 +398,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_network_share_object.py b/cybox/bindings/win_network_share_object.py index feb6a72f..f481e7a7 100644 --- a/cybox/bindings/win_network_share_object.py +++ b/cybox/bindings/win_network_share_object.py @@ -465,7 +465,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_pipe_object.py b/cybox/bindings/win_pipe_object.py index 7976d350..d20475dc 100644 --- a/cybox/bindings/win_pipe_object.py +++ b/cybox/bindings/win_pipe_object.py @@ -313,7 +313,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_prefetch_object.py b/cybox/bindings/win_prefetch_object.py index 509f98dc..1fc99a76 100644 --- a/cybox/bindings/win_prefetch_object.py +++ b/cybox/bindings/win_prefetch_object.py @@ -553,7 +553,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_process_object.py b/cybox/bindings/win_process_object.py index 4368bbf3..734a7d01 100644 --- a/cybox/bindings/win_process_object.py +++ b/cybox/bindings/win_process_object.py @@ -731,7 +731,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_registry_key_object.py b/cybox/bindings/win_registry_key_object.py index 894f5792..a50a25b2 100644 --- a/cybox/bindings/win_registry_key_object.py +++ b/cybox/bindings/win_registry_key_object.py @@ -716,7 +716,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_semaphore_object.py b/cybox/bindings/win_semaphore_object.py index cc20347c..ea731f10 100644 --- a/cybox/bindings/win_semaphore_object.py +++ b/cybox/bindings/win_semaphore_object.py @@ -243,7 +243,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_service_object.py b/cybox/bindings/win_service_object.py index 6d284749..d15f689e 100644 --- a/cybox/bindings/win_service_object.py +++ b/cybox/bindings/win_service_object.py @@ -805,7 +805,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_system_object.py b/cybox/bindings/win_system_object.py index 733bacba..fb1bee61 100644 --- a/cybox/bindings/win_system_object.py +++ b/cybox/bindings/win_system_object.py @@ -550,7 +550,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_system_restore_object.py b/cybox/bindings/win_system_restore_object.py index 3a62b96f..0e5b4199 100644 --- a/cybox/bindings/win_system_restore_object.py +++ b/cybox/bindings/win_system_restore_object.py @@ -569,7 +569,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_task_object.py b/cybox/bindings/win_task_object.py index 6ef3c25a..23d245ce 100644 --- a/cybox/bindings/win_task_object.py +++ b/cybox/bindings/win_task_object.py @@ -1581,7 +1581,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_thread_object.py b/cybox/bindings/win_thread_object.py index c4c57dac..afbe4e6c 100644 --- a/cybox/bindings/win_thread_object.py +++ b/cybox/bindings/win_thread_object.py @@ -427,7 +427,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_user_account_object.py b/cybox/bindings/win_user_account_object.py index fb94609a..9fbfe30a 100644 --- a/cybox/bindings/win_user_account_object.py +++ b/cybox/bindings/win_user_account_object.py @@ -389,7 +389,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_volume_object.py b/cybox/bindings/win_volume_object.py index 909addd2..ecf8321f 100644 --- a/cybox/bindings/win_volume_object.py +++ b/cybox/bindings/win_volume_object.py @@ -474,7 +474,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/win_waitable_timer_object.py b/cybox/bindings/win_waitable_timer_object.py index ba6d44cb..68c7b2f6 100644 --- a/cybox/bindings/win_waitable_timer_object.py +++ b/cybox/bindings/win_waitable_timer_object.py @@ -335,7 +335,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/bindings/x509_certificate_object.py b/cybox/bindings/x509_certificate_object.py index 4bb75871..a5323b4e 100644 --- a/cybox/bindings/x509_certificate_object.py +++ b/cybox/bindings/x509_certificate_object.py @@ -1032,7 +1032,7 @@ def parseEtree(inFileName): return rootObj, rootElement def parseString(inString): - from six import StringIO + from mixbox.vendor.six import StringIO doc = parsexml_(StringIO(inString)) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) diff --git a/cybox/common/hashes.py b/cybox/common/hashes.py index 171b378d..2c3b4217 100644 --- a/cybox/common/hashes.py +++ b/cybox/common/hashes.py @@ -1,8 +1,8 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. -import six -from six import u +from mixbox.vendor import six +from mixbox.vendor.six import u import cybox import cybox.bindings.cybox_common as common_binding diff --git a/cybox/common/properties.py b/cybox/common/properties.py index 409ea850..893cedee 100644 --- a/cybox/common/properties.py +++ b/cybox/common/properties.py @@ -4,7 +4,7 @@ from datetime import datetime import dateutil.parser -import six +from mixbox.vendor import six import cybox from cybox.compat import long diff --git a/cybox/common/structured_text.py b/cybox/common/structured_text.py index c9642861..1f85226f 100644 --- a/cybox/common/structured_text.py +++ b/cybox/common/structured_text.py @@ -1,7 +1,7 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. -import six +from mixbox.vendor import six import cybox import cybox.bindings.cybox_common as common_binding diff --git a/cybox/compat.py b/cybox/compat.py index cfad3f45..c5b91489 100644 --- a/cybox/compat.py +++ b/cybox/compat.py @@ -7,7 +7,7 @@ Only covers things that aren't already present in `six`. """ -import six +from mixbox.vendor import six if six.PY2: long = long diff --git a/cybox/objects/address_object.py b/cybox/objects/address_object.py index 487cd44f..3d17ca3d 100644 --- a/cybox/objects/address_object.py +++ b/cybox/objects/address_object.py @@ -1,7 +1,7 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. -import six +from mixbox.vendor import six import cybox diff --git a/cybox/objects/artifact_object.py b/cybox/objects/artifact_object.py index fa70f67f..99868c3d 100644 --- a/cybox/objects/artifact_object.py +++ b/cybox/objects/artifact_object.py @@ -5,7 +5,7 @@ import bz2 import zlib -import six +from mixbox.vendor import six import cybox import cybox.bindings.artifact_object as artifact_binding diff --git a/cybox/objects/uri_object.py b/cybox/objects/uri_object.py index e95e8feb..e15eb2cf 100644 --- a/cybox/objects/uri_object.py +++ b/cybox/objects/uri_object.py @@ -1,7 +1,7 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. -import six +from mixbox.vendor import six import cybox import cybox.bindings.uri_object as uri_binding diff --git a/cybox/test/__init__.py b/cybox/test/__init__.py index 939e9280..a97f0092 100644 --- a/cybox/test/__init__.py +++ b/cybox/test/__init__.py @@ -5,7 +5,7 @@ import unittest from mixbox.binding_utils import ExternalEncoding -import six +from mixbox.vendor import six from cybox import Entity, EntityList, TypedField import cybox.bindings.cybox_core as core_binding diff --git a/cybox/test/common/extracted_features_test.py b/cybox/test/common/extracted_features_test.py index 9c60e95a..ef55cc11 100644 --- a/cybox/test/common/extracted_features_test.py +++ b/cybox/test/common/extracted_features_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.common import ExtractedFeatures from cybox.test import EntityTestCase diff --git a/cybox/test/common/extracted_string_test.py b/cybox/test/common/extracted_string_test.py index dbe8e370..b9c0e1f8 100644 --- a/cybox/test/common/extracted_string_test.py +++ b/cybox/test/common/extracted_string_test.py @@ -4,8 +4,8 @@ import binascii import unittest -import six -from six import u +from mixbox.vendor import six +from mixbox.vendor.six import u from cybox.common import ExtractedString, Hash from cybox.test import EntityTestCase diff --git a/cybox/test/common/hash_test.py b/cybox/test/common/hash_test.py index 4abf37a9..19cd704d 100644 --- a/cybox/test/common/hash_test.py +++ b/cybox/test/common/hash_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.common import Hash, HashList, HashName, HexBinary import cybox.test diff --git a/cybox/test/common/measuresource_test.py b/cybox/test/common/measuresource_test.py index f1d4584e..82bcf42c 100644 --- a/cybox/test/common/measuresource_test.py +++ b/cybox/test/common/measuresource_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.common import MeasureSource from cybox.test import EntityTestCase diff --git a/cybox/test/common/object_properties_test.py b/cybox/test/common/object_properties_test.py index 2e99633b..48589843 100644 --- a/cybox/test/common/object_properties_test.py +++ b/cybox/test/common/object_properties_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.common import ObjectProperties, Property from cybox.objects.address_object import Address diff --git a/cybox/test/common/properties_test.py b/cybox/test/common/properties_test.py index 9d626416..16651026 100644 --- a/cybox/test/common/properties_test.py +++ b/cybox/test/common/properties_test.py @@ -4,8 +4,8 @@ import datetime import unittest -import six -from six import u +from mixbox.vendor import six +from mixbox.vendor.six import u from cybox.common import (BaseProperty, DateTime, Integer, Long, NonNegativeInteger, PositiveInteger, String, UnsignedInteger, diff --git a/cybox/test/common/structured_test_text.py b/cybox/test/common/structured_test_text.py index 3b5a8025..dccb4974 100644 --- a/cybox/test/common/structured_test_text.py +++ b/cybox/test/common/structured_test_text.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.common import StructuredText import cybox.test diff --git a/cybox/test/common/tools_test.py b/cybox/test/common/tools_test.py index b3a3766c..f47136f1 100644 --- a/cybox/test/common/tools_test.py +++ b/cybox/test/common/tools_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.common import Hash, ToolInformation, ToolInformationList import cybox.test diff --git a/cybox/test/common/vocab_test.py b/cybox/test/common/vocab_test.py index 175a6968..d4b2650e 100644 --- a/cybox/test/common/vocab_test.py +++ b/cybox/test/common/vocab_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.bindings import cybox_common as common_binding from cybox.common import HashName, VocabString, vocabs diff --git a/cybox/test/core/action_test.py b/cybox/test/core/action_test.py index b133b0fb..2832fb45 100644 --- a/cybox/test/core/action_test.py +++ b/cybox/test/core/action_test.py @@ -4,7 +4,7 @@ import copy import unittest -from six import u +from mixbox.vendor.six import u from cybox.bindings.cybox_core import parseString from cybox.core import Action, ActionRelationship diff --git a/cybox/test/core/event_test.py b/cybox/test/core/event_test.py index d91a9617..1d2e59d2 100644 --- a/cybox/test/core/event_test.py +++ b/cybox/test/core/event_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.core import Event from cybox.test import EntityTestCase diff --git a/cybox/test/core/frequency_test.py b/cybox/test/core/frequency_test.py index 00b953b9..24e2d881 100644 --- a/cybox/test/core/frequency_test.py +++ b/cybox/test/core/frequency_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.core import Frequency from cybox.test import EntityTestCase diff --git a/cybox/test/core/object_test.py b/cybox/test/core/object_test.py index 637112d4..54501724 100644 --- a/cybox/test/core/object_test.py +++ b/cybox/test/core/object_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.core import Object, Observables, RelatedObject, Relationship from cybox.objects.address_object import Address diff --git a/cybox/test/core/observable_test.py b/cybox/test/core/observable_test.py index 6d716da3..98dbdd7d 100644 --- a/cybox/test/core/observable_test.py +++ b/cybox/test/core/observable_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.common import MeasureSource, ObjectProperties, String, StructuredText from cybox.core import (Event, Object, Observable, ObservableComposition, diff --git a/cybox/test/encoding_test.py b/cybox/test/encoding_test.py index 8d6ec52f..e7608d51 100644 --- a/cybox/test/encoding_test.py +++ b/cybox/test/encoding_test.py @@ -6,8 +6,8 @@ import unittest -import six -from six import u +from mixbox.vendor import six +from mixbox.vendor.six import u import cybox.bindings as bindings from cybox.common import Contributor, String, MeasureSource diff --git a/cybox/test/objects/address_test.py b/cybox/test/objects/address_test.py index 23651021..bee61bfc 100644 --- a/cybox/test/objects/address_test.py +++ b/cybox/test/objects/address_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.common import String from cybox.objects.address_object import Address, EmailAddress diff --git a/cybox/test/objects/archive_file_test.py b/cybox/test/objects/archive_file_test.py index 25fa5531..a8001a2a 100644 --- a/cybox/test/objects/archive_file_test.py +++ b/cybox/test/objects/archive_file_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.archive_file_object import ArchiveFile diff --git a/cybox/test/objects/arp_cache_test.py b/cybox/test/objects/arp_cache_test.py index 178a7dd5..bd7a739f 100644 --- a/cybox/test/objects/arp_cache_test.py +++ b/cybox/test/objects/arp_cache_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.arp_cache_object import ARPCache diff --git a/cybox/test/objects/artifact_test.py b/cybox/test/objects/artifact_test.py index 063bf673..96ff04f4 100644 --- a/cybox/test/objects/artifact_test.py +++ b/cybox/test/objects/artifact_test.py @@ -5,8 +5,8 @@ import unittest from zlib import compress -import six -from six import u +from mixbox.vendor import six +from mixbox.vendor.six import u from cybox.objects.artifact_object import (Artifact, Base64Encoding, Bz2Compression, RawArtifact, XOREncryption, ZlibCompression) diff --git a/cybox/test/objects/as_test.py b/cybox/test/objects/as_test.py index 814c3b13..a933f589 100644 --- a/cybox/test/objects/as_test.py +++ b/cybox/test/objects/as_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.as_object import AutonomousSystem from cybox.test.objects import ObjectTestCase diff --git a/cybox/test/objects/code_test.py b/cybox/test/objects/code_test.py index 56ce50f3..50247f80 100644 --- a/cybox/test/objects/code_test.py +++ b/cybox/test/objects/code_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.code_object import Code from cybox.test.objects import ObjectTestCase diff --git a/cybox/test/objects/domainname_test.py b/cybox/test/objects/domainname_test.py index a806b524..65d4b97b 100644 --- a/cybox/test/objects/domainname_test.py +++ b/cybox/test/objects/domainname_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.domain_name_object import DomainName from cybox.test.objects import ObjectTestCase diff --git a/cybox/test/objects/email_message_test.py b/cybox/test/objects/email_message_test.py index 8dbcd8eb..3db789ba 100644 --- a/cybox/test/objects/email_message_test.py +++ b/cybox/test/objects/email_message_test.py @@ -4,7 +4,7 @@ import datetime import unittest -from six import u +from mixbox.vendor.six import u from cybox.common import String, DateTime from cybox.core import Observables diff --git a/cybox/test/objects/file_test.py b/cybox/test/objects/file_test.py index 12e164d8..f5d38784 100644 --- a/cybox/test/objects/file_test.py +++ b/cybox/test/objects/file_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.file_object import File, FilePath, Packer, SymLinksList diff --git a/cybox/test/objects/http_session_test.py b/cybox/test/objects/http_session_test.py index 1dba085c..c71db668 100644 --- a/cybox/test/objects/http_session_test.py +++ b/cybox/test/objects/http_session_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.address_object import Address from cybox.objects.http_session_object import HTTPSession diff --git a/cybox/test/objects/image_file_test.py b/cybox/test/objects/image_file_test.py index dc6fae37..413b3a4b 100644 --- a/cybox/test/objects/image_file_test.py +++ b/cybox/test/objects/image_file_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.image_file_object import ImageFile diff --git a/cybox/test/objects/memory_test.py b/cybox/test/objects/memory_test.py index c4fd1e32..a8ce1235 100644 --- a/cybox/test/objects/memory_test.py +++ b/cybox/test/objects/memory_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.memory_object import Memory diff --git a/cybox/test/objects/network_connection_test.py b/cybox/test/objects/network_connection_test.py index 4866dfd0..0470aea7 100644 --- a/cybox/test/objects/network_connection_test.py +++ b/cybox/test/objects/network_connection_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.address_object import Address from cybox.objects.network_connection_object import (Layer7Connections, diff --git a/cybox/test/objects/network_packet_test.py b/cybox/test/objects/network_packet_test.py index 89530f8e..f9e5b3fb 100644 --- a/cybox/test/objects/network_packet_test.py +++ b/cybox/test/objects/network_packet_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.bindings.cybox_core import parseString from cybox.core import Observables diff --git a/cybox/test/objects/network_route_entry_test.py b/cybox/test/objects/network_route_entry_test.py index 1df79930..ae474c4d 100644 --- a/cybox/test/objects/network_route_entry_test.py +++ b/cybox/test/objects/network_route_entry_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.network_route_entry_object import NetworkRouteEntry diff --git a/cybox/test/objects/network_socket_test.py b/cybox/test/objects/network_socket_test.py index 0c92b3bf..b07749ac 100644 --- a/cybox/test/objects/network_socket_test.py +++ b/cybox/test/objects/network_socket_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.network_socket_object import NetworkSocket, SocketOptions from cybox.test import EntityTestCase diff --git a/cybox/test/objects/socket_address_test.py b/cybox/test/objects/socket_address_test.py index f03bd3fd..2d9e4de5 100644 --- a/cybox/test/objects/socket_address_test.py +++ b/cybox/test/objects/socket_address_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.address_object import Address from cybox.objects.socket_address_object import SocketAddress diff --git a/cybox/test/objects/uri_test.py b/cybox/test/objects/uri_test.py index 02efd0cd..7ff323a7 100644 --- a/cybox/test/objects/uri_test.py +++ b/cybox/test/objects/uri_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.common import AnyURI from cybox.objects.uri_object import URI diff --git a/cybox/test/objects/user_account_test.py b/cybox/test/objects/user_account_test.py index c07329dc..1f1bf954 100644 --- a/cybox/test/objects/user_account_test.py +++ b/cybox/test/objects/user_account_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.user_account_object import UserAccount from cybox.test.objects import ObjectTestCase diff --git a/cybox/test/objects/win_computer_account_test.py b/cybox/test/objects/win_computer_account_test.py index 1780f0d9..458471b1 100644 --- a/cybox/test/objects/win_computer_account_test.py +++ b/cybox/test/objects/win_computer_account_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.compat import long from cybox.objects.win_computer_account_object import WinComputerAccount diff --git a/cybox/test/objects/win_critical_section_test.py b/cybox/test/objects/win_critical_section_test.py index ac526788..1a53b448 100644 --- a/cybox/test/objects/win_critical_section_test.py +++ b/cybox/test/objects/win_critical_section_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.win_critical_section_object import WinCriticalSection from cybox.test.objects import ObjectTestCase diff --git a/cybox/test/objects/win_file_test.py b/cybox/test/objects/win_file_test.py index ae33acb1..59253b07 100644 --- a/cybox/test/objects/win_file_test.py +++ b/cybox/test/objects/win_file_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.compat import long from cybox.objects.win_file_object import WinFile, Stream diff --git a/cybox/test/objects/win_filemapping_test.py b/cybox/test/objects/win_filemapping_test.py index 635427f2..a02d088c 100644 --- a/cybox/test/objects/win_filemapping_test.py +++ b/cybox/test/objects/win_filemapping_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.compat import long from cybox.objects.win_filemapping_object import WinFilemapping diff --git a/cybox/test/objects/win_hook_test.py b/cybox/test/objects/win_hook_test.py index a98e602c..44242d82 100644 --- a/cybox/test/objects/win_hook_test.py +++ b/cybox/test/objects/win_hook_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.win_hook_object import WinHook diff --git a/cybox/test/objects/win_memory_page_region_test.py b/cybox/test/objects/win_memory_page_region_test.py index 6ab217a0..b9d2bf89 100644 --- a/cybox/test/objects/win_memory_page_region_test.py +++ b/cybox/test/objects/win_memory_page_region_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.win_memory_page_region_object import WinMemoryPageRegion diff --git a/cybox/test/objects/win_network_route_entry_test.py b/cybox/test/objects/win_network_route_entry_test.py index f2260888..9f51fe3a 100644 --- a/cybox/test/objects/win_network_route_entry_test.py +++ b/cybox/test/objects/win_network_route_entry_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.win_network_route_entry_object import WinNetworkRouteEntry diff --git a/cybox/test/objects/win_prefetch_test.py b/cybox/test/objects/win_prefetch_test.py index 3648778d..dfa2498d 100644 --- a/cybox/test/objects/win_prefetch_test.py +++ b/cybox/test/objects/win_prefetch_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.win_prefetch_object import WinPrefetch diff --git a/cybox/test/objects/win_registry_key_test.py b/cybox/test/objects/win_registry_key_test.py index dc86370f..ca9afc43 100644 --- a/cybox/test/objects/win_registry_key_test.py +++ b/cybox/test/objects/win_registry_key_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.compat import long from cybox.objects.win_registry_key_object import WinRegistryKey diff --git a/cybox/test/objects/win_semaphore_test.py b/cybox/test/objects/win_semaphore_test.py index cb57e624..ac7bc1bf 100644 --- a/cybox/test/objects/win_semaphore_test.py +++ b/cybox/test/objects/win_semaphore_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.compat import long from cybox.objects.win_semaphore_object import WinSemaphore diff --git a/cybox/test/objects/win_system_restore_test.py b/cybox/test/objects/win_system_restore_test.py index a68e15f7..496ad434 100644 --- a/cybox/test/objects/win_system_restore_test.py +++ b/cybox/test/objects/win_system_restore_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.win_system_restore_object import WinSystemRestore diff --git a/cybox/test/objects/win_task_test.py b/cybox/test/objects/win_task_test.py index 2022ca4e..dc5ea28a 100644 --- a/cybox/test/objects/win_task_test.py +++ b/cybox/test/objects/win_task_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.compat import long from cybox.objects.win_task_object import WinTask diff --git a/cybox/test/objects/win_thread_test.py b/cybox/test/objects/win_thread_test.py index e7fa4a5a..4b219312 100644 --- a/cybox/test/objects/win_thread_test.py +++ b/cybox/test/objects/win_thread_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.win_thread_object import WinThread from cybox.test.objects import ObjectTestCase diff --git a/cybox/test/objects/win_user_test.py b/cybox/test/objects/win_user_test.py index 4b6b8dd2..fa48bbef 100644 --- a/cybox/test/objects/win_user_test.py +++ b/cybox/test/objects/win_user_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.win_user_object import WinUser from cybox.test.objects import ObjectTestCase diff --git a/cybox/test/objects/win_waitable_timer_test.py b/cybox/test/objects/win_waitable_timer_test.py index 3d38ea57..37ff98a5 100644 --- a/cybox/test/objects/win_waitable_timer_test.py +++ b/cybox/test/objects/win_waitable_timer_test.py @@ -3,7 +3,7 @@ import unittest -from six import u +from mixbox.vendor.six import u from cybox.objects.win_waitable_timer_object import WinWaitableTimer diff --git a/cybox/utils/__init__.py b/cybox/utils/__init__.py index 781d9be7..59f3f171 100644 --- a/cybox/utils/__init__.py +++ b/cybox/utils/__init__.py @@ -6,7 +6,7 @@ #importlib is imported below import os -import six +from mixbox.vendor import six from .caches import * from .idgen import * diff --git a/setup.py b/setup.py index af93fe4e..441f2d02 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def get_version(): with open('README.rst') as f: readme = f.read() -install_requires = ['mixbox', 'lxml>=2.2.3', 'python-dateutil', 'six>=1.9.0'] +install_requires = ['mixbox', 'lxml>=2.2.3', 'python-dateutil'] try: import importlib except ImportError: From e2ce2d4f06e25888aa120035f1d6a52832444684 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 14 May 2015 14:35:38 -0500 Subject: [PATCH 14/17] Fix some other Python 3 compatibilty issues. A lot of new code was introduced since the first cut at Python3 compatibility. --- cybox/__init__.py | 2 +- cybox/common/vocabs.py | 4 +++- cybox/test/core/action_reference_test.py | 8 +++++--- cybox/test/core/action_test.py | 4 ++-- cybox/test/core/observable_test.py | 4 ++-- cybox/test/objects/custom_test.py | 4 +++- cybox/test/objects/whois_test.py | 24 +++++++++++++----------- cybox/test/objects/win_event_test.py | 12 +++++++----- cybox/utils/__init__.py | 4 +++- docs/examples.rst | 2 +- 10 files changed, 40 insertions(+), 28 deletions(-) diff --git a/cybox/__init__.py b/cybox/__init__.py index 18adba00..a6bd42a8 100644 --- a/cybox/__init__.py +++ b/cybox/__init__.py @@ -327,7 +327,7 @@ def _get_namespace_def(self, additional_ns_dict=None): namespaces = self._get_namespaces() if additional_ns_dict: - for ns, prefix in additional_ns_dict.iteritems(): + for ns, prefix in six.iteritems(additional_ns_dict): namespaces.update([Namespace(ns, prefix)]) # TODO: For now, always add the ID namespace. Later we can figure out diff --git a/cybox/common/vocabs.py b/cybox/common/vocabs.py index f537a0f7..0f550a60 100644 --- a/cybox/common/vocabs.py +++ b/cybox/common/vocabs.py @@ -1,6 +1,8 @@ # Copyright (c) 2015, The MITRE Corporation. All rights reserved. # See LICENSE.txt for complete terms. +from mixbox.vendor import six + import cybox import cybox.bindings.cybox_common as common_binding from cybox.common import PatternFieldGroup @@ -117,7 +119,7 @@ def lookup_class(xsi_type): if not xsi_type: return VocabString - for (k, v) in _VOCAB_MAP.iteritems(): + for (k, v) in six.iteritems(_VOCAB_MAP): # TODO: for now we ignore the prefix and just check for # a partial match if xsi_type in k: diff --git a/cybox/test/core/action_reference_test.py b/cybox/test/core/action_reference_test.py index dfc0caa3..252e9fac 100644 --- a/cybox/test/core/action_reference_test.py +++ b/cybox/test/core/action_reference_test.py @@ -3,6 +3,8 @@ import unittest +from mixbox.vendor.six import u + from cybox.core import ActionReference from cybox.test import EntityTestCase @@ -15,9 +17,9 @@ class TestActionReference(EntityTestCase, unittest.TestCase): def test_construction(self): aref = ActionReference(action_id="example:Action-1") - print aref.to_xml() - print aref.to_dict() - self.assertTrue("example:Action-1" in aref.to_xml()) + print(aref.to_xml()) + print(aref.to_dict()) + self.assertTrue(b"example:Action-1" in aref.to_xml()) self.assertTrue("example:Action-1" in aref.to_json()) diff --git a/cybox/test/core/action_test.py b/cybox/test/core/action_test.py index 2832fb45..a7661ebf 100644 --- a/cybox/test/core/action_test.py +++ b/cybox/test/core/action_test.py @@ -56,11 +56,11 @@ class TestAction(EntityTestCase, unittest.TestCase): def test_tzinfo_copy(self): action = Action() action.timestamp = "2015-03-28T16:39:28.127296+03:00" - action_xml = action.to_xml() + action_xml = action.to_xml(encoding=None) action2 = Action.from_obj(parseString(action_xml)) action2_copy = copy.deepcopy(action2) - self.assertEqual(action_xml, action2_copy.to_xml()) + self.assertEqual(action_xml, action2_copy.to_xml(encoding=None)) class TestActionRelationship(EntityTestCase, unittest.TestCase): diff --git a/cybox/test/core/observable_test.py b/cybox/test/core/observable_test.py index 98dbdd7d..7e077517 100644 --- a/cybox/test/core/observable_test.py +++ b/cybox/test/core/observable_test.py @@ -209,7 +209,7 @@ class TestObservables(EntityTestCase, unittest.TestCase): 'description': "A longer description of the observable", 'object': { 'properties': { - 'file_name': u"example.txt", + 'file_name': u("example.txt"), 'xsi:type': "FileObjectType" }, }, @@ -217,7 +217,7 @@ class TestObservables(EntityTestCase, unittest.TestCase): ], 'observable_package_source': { 'name': "The Source", - 'information_source_type': u"Logs", + 'information_source_type': u("Logs"), }, } diff --git a/cybox/test/objects/custom_test.py b/cybox/test/objects/custom_test.py index 4806d4cd..684b7fe9 100644 --- a/cybox/test/objects/custom_test.py +++ b/cybox/test/objects/custom_test.py @@ -3,6 +3,8 @@ import unittest +from mixbox.vendor.six import u + from cybox.objects.custom_object import Custom from cybox.test.objects import ObjectTestCase @@ -12,7 +14,7 @@ class TestCustom(ObjectTestCase, unittest.TestCase): klass = Custom _full_dict = { - 'custom_name': u"SuperCustomizedObjectName", + 'custom_name': u("SuperCustomizedObjectName"), 'description': "Some description of the custom object", 'custom_properties': [ {'name': "Property #1", 'description': "A First Property", 'value': "12345"}, diff --git a/cybox/test/objects/whois_test.py b/cybox/test/objects/whois_test.py index b2defca3..3e78d01e 100644 --- a/cybox/test/objects/whois_test.py +++ b/cybox/test/objects/whois_test.py @@ -4,6 +4,8 @@ import unittest import uuid +from mixbox.vendor.six import u + from cybox.bindings.cybox_common import StringObjectPropertyType from cybox.bindings.whois_object import (WhoisContactType, WhoisRegistrantInfoType) @@ -88,17 +90,17 @@ class TestContact(EntityTestCase, unittest.TestCase): _full_dict = { 'contact_type': "ADMIN", - 'contact_id': u"abc123", - 'name': u"John Smith", + 'contact_id': u("abc123"), + 'name': u("John Smith"), 'email_address': { - 'address_value': u"john@smith.com", + 'address_value': u("john@smith.com"), 'category': Address.CAT_EMAIL, 'xsi:type': "AddressObjectType", }, - 'phone_number': u"(800) 555-1212", - 'fax_number': u"(800) 555-1200", - 'address': u"123 Main St.\nAnytown, CA 01234", - 'organization': u"XYZ Hosting", + 'phone_number': u("(800) 555-1212"), + 'fax_number': u("(800) 555-1200"), + 'address': u("123 Main St.\nAnytown, CA 01234"), + 'organization': u("XYZ Hosting"), } def test_parse_email_address(self): @@ -130,16 +132,16 @@ def test_issue_227_binding_init(self): contact_obj = WhoisContactType( contact_type="ADMIN", Contact_ID=StringObjectPropertyType(valueOf_="abc123"), - Fax_Number=StringObjectPropertyType(valueOf_=u"(800) 555-1200"), - Organization=StringObjectPropertyType(valueOf_=u"XYZ Hosting"), + Fax_Number=StringObjectPropertyType(valueOf_=u("(800) 555-1200")), + Organization=StringObjectPropertyType(valueOf_=u("XYZ Hosting")), ) contact = WhoisContact.from_obj(contact_obj) reg_obj = WhoisRegistrantInfoType( contact_type="ADMIN", Contact_ID=StringObjectPropertyType(valueOf_="abc123"), - Fax_Number=StringObjectPropertyType(valueOf_=u"(800) 555-1200"), - Organization=StringObjectPropertyType(valueOf_=u"XYZ Hosting"), + Fax_Number=StringObjectPropertyType(valueOf_=u("(800) 555-1200")), + Organization=StringObjectPropertyType(valueOf_=u("XYZ Hosting")), ) registrant = WhoisRegistrant.from_obj(reg_obj) diff --git a/cybox/test/objects/win_event_test.py b/cybox/test/objects/win_event_test.py index c7008904..974a83f5 100644 --- a/cybox/test/objects/win_event_test.py +++ b/cybox/test/objects/win_event_test.py @@ -3,6 +3,8 @@ import unittest +from mixbox.vendor.six import u + from cybox.objects.win_event_object import WinEvent from cybox.test.objects import ObjectTestCase @@ -12,13 +14,13 @@ class TestWinThread(ObjectTestCase, unittest.TestCase): klass = WinEvent _full_dict = { - 'name': u"Object Open", + 'name': u("Object Open"), 'handle': { - 'name': u"Event Handle", - 'type': u"Event", + 'name': u("Event Handle"), + 'type': u("Event"), 'xsi:type': "WindowsHandleObjectType", }, - 'type': u"Success", + 'type': u("Success"), 'xsi:type': "WindowsEventObjectType", } @@ -33,7 +35,7 @@ def test_object_construction(self): d = event.to_dict() # Should not raise. self.assertEqual("Success", d['type']) o = event.to_xml() # Should not raise. - self.assertTrue("Success" in o) + self.assertTrue(b"Success" in o) if __name__ == "__main__": diff --git a/cybox/utils/__init__.py b/cybox/utils/__init__.py index 59f3f171..b12be319 100644 --- a/cybox/utils/__init__.py +++ b/cybox/utils/__init__.py @@ -78,7 +78,9 @@ def is_sequence(item): ``tuple``). String types will return ``False``. """ - return hasattr(item, "__iter__") + # NOTE: On Python 3, strings have the __iter__ defined, so a simple hasattr + # check is insufficient. + return hasattr(item, "__iter__") and not isinstance(item, six.string_types) def _import_all(): diff --git a/docs/examples.rst b/docs/examples.rst index 60734d90..617fe0b4 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -545,7 +545,7 @@ the fields used in the Custom object. p1.value = "SuP3rS3cr3T!" c.custom_properties.append(p1) - print c.to_xml(include_namespaces=False) + print(c.to_xml(include_namespaces=False, encoding=None)) .. testoutput:: From 9210af1adf9abb7187548f45fa004c3d6e7826d3 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 14 May 2015 15:03:32 -0500 Subject: [PATCH 15/17] Use mixbox on RHEL Tox tests. --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 18c0ddd2..07f5b62b 100644 --- a/tox.ini +++ b/tox.ini @@ -14,13 +14,12 @@ commands = nosetests cybox deps = -rrequirements.txt -#NOTE: RHEL 6 bundles six==1.7.3, but we need 1.9.0 [testenv:rhel6] basepython=python2.6 commands = nosetests cybox deps = lxml==2.2.3 + mixbox python-dateutil==1.4.1 - six>=1.9.0 nose From 8327de6e1f60b32050910abcba88d24e6bd87e5f Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 28 May 2015 08:33:46 -0500 Subject: [PATCH 16/17] Undo capitalization change of Email_Message. Partially revert ce549b8de55a098cc0b3eadaf3db73248c710c0a --- cybox/bindings/email_message_object.py | 8 ++++---- cybox/bindings/win_task_object.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cybox/bindings/email_message_object.py b/cybox/bindings/email_message_object.py index 69eaf219..80eaf1b1 100644 --- a/cybox/bindings/email_message_object.py +++ b/cybox/bindings/email_message_object.py @@ -1064,7 +1064,7 @@ def parse(inFileName): rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) if rootClass is None: - rootTag = 'email_message' + rootTag = 'Email_Message' rootClass = EmailMessageObjectType rootObj = rootClass.factory() rootObj.build(rootNode) @@ -1081,7 +1081,7 @@ def parseEtree(inFileName): rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) if rootClass is None: - rootTag = 'email_message' + rootTag = 'Email_Message' rootClass = EmailMessageObjectType rootObj = rootClass.factory() rootObj.build(rootNode) @@ -1100,14 +1100,14 @@ def parseString(inString): rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) if rootClass is None: - rootTag = 'email_message' + rootTag = 'Email_Message' rootClass = EmailMessageObjectType rootObj = rootClass.factory() rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None # sys.stdout.write('\n') -# rootObj.export(sys.stdout.write, 0, name_="email_message", +# rootObj.export(sys.stdout.write, 0, name_="Email_Message", # namespacedef_='') return rootObj diff --git a/cybox/bindings/win_task_object.py b/cybox/bindings/win_task_object.py index 23d245ce..a5c9f52a 100644 --- a/cybox/bindings/win_task_object.py +++ b/cybox/bindings/win_task_object.py @@ -1522,7 +1522,7 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 'Fuzzy_Hash_Value': cybox_common.FuzzyHashValueType, 'Show_Message_Title': cybox_common.StringObjectPropertyType, 'Data_Size': cybox_common.DataSizeType, - 'email_message': email_message_object.EmailMessageObjectType, + 'Email_Message': email_message_object.EmailMessageObjectType, 'Dependency_Description': cybox_common.StructuredTextType, 'File': email_message_object.AttachmentReferenceType, 'Contributor': cybox_common.ContributorType, From 603f7a937fd8c626394106009bf3673d2cb9f10d Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 28 May 2015 08:43:35 -0500 Subject: [PATCH 17/17] Minor fixups --- cybox/common/structured_text.py | 2 +- cybox/objects/artifact_object.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cybox/common/structured_text.py b/cybox/common/structured_text.py index 1f85226f..d9b1a611 100644 --- a/cybox/common/structured_text.py +++ b/cybox/common/structured_text.py @@ -79,4 +79,4 @@ def from_dict(cls, text_dict, text=None): return text def __str__(self): - return self.value + return six.text_type(self.value) diff --git a/cybox/objects/artifact_object.py b/cybox/objects/artifact_object.py index 99868c3d..dc563a8b 100644 --- a/cybox/objects/artifact_object.py +++ b/cybox/objects/artifact_object.py @@ -83,7 +83,7 @@ def data(self, value): @property def packed_data(self): - "Should return a Unicode string" + """Should return a Unicode string""" if self._packed_data: return self._packed_data elif self._data: