Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cybox/bindings/pdf_file_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,10 @@ def build(self, node):
def buildAttributes(self, node, attrs, already_processed):
value = find_attr_value_('type', node)
if value is not None:

self.type_ = value
def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
if nodeName_ == 'ID':
obj_ = PDFFileIDType.factory()
obj_ = PDFIndirectObjectIDType.factory()
obj_.build(child_)
self.set_ID(obj_)
elif nodeName_ == 'Contents':
Expand Down
1 change: 1 addition & 0 deletions cybox/common/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class HashList(entities.EntityList):
_binding = common_binding
_binding_class = common_binding.HashListType
_namespace = 'http://cybox.mitre.org/common-2'

hashes = fields.TypedField("Hash", Hash, multiple=True)

@property
Expand Down
1 change: 1 addition & 0 deletions cybox/common/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def from_dict(cls, cls_dict):

return attr


class String(BaseProperty):
_binding_class = common_binding.StringObjectPropertyType
default_datatype = "string"
Expand Down
2 changes: 1 addition & 1 deletion cybox/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .frequency import Frequency

from .object import (DomainSpecificObjectProperties, Object, RelatedObject,
Relationship)
Relationship)

from .action_reference import ActionReference
from .associated_object import AssociatedObject, AssociationType
Expand Down
13 changes: 10 additions & 3 deletions cybox/core/object.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015, The MITRE Corporation. All rights reserved.
# Copyright (c) 2017, The MITRE Corporation. All rights reserved.
# See LICENSE.txt for complete terms.
from mixbox import entities
from mixbox import fields
Expand All @@ -7,6 +7,7 @@
import cybox
import cybox.utils
import cybox.bindings.cybox_core as core_binding
from cybox.common import StructuredText
from cybox.common.object_properties import ObjectPropertiesFactory, ObjectProperties
from cybox.common.vocabs import VocabField
from cybox.common.vocabs import ObjectRelationship as Relationship
Expand Down Expand Up @@ -51,6 +52,8 @@ class Object(entities.Entity):
Currently only supports the following data members:
- id\_
- idref
- has_changed
- description
- properties
- related_objects
- domain specific object properties
Expand All @@ -61,11 +64,13 @@ class Object(entities.Entity):

id_ = fields.IdField("id", postset_hook=_cache_object)
idref = fields.IdrefField("idref")
has_changed = fields.TypedField("has_changed")
description = fields.TypedField("Description", StructuredText)
properties = fields.TypedField("Properties", ObjectProperties, factory=ObjectPropertiesFactory, postset_hook=_modify_properties_parent)
related_objects = fields.TypedField("Related_Objects", "cybox.core.object.RelatedObjects")
domain_specific_object_properties = fields.TypedField("Domain_Specific_Object_Properties", "cybox.core.DomainSpecificObjectProperties", factory=ExternalTypeFactory)
related_objects = fields.TypedField("Related_Objects", "cybox.core.object.RelatedObjects")

def __init__(self, properties=None, type_=None, id_=None, idref=None):
def __init__(self, properties=None, id_=None, idref=None):
super(Object, self).__init__()

if properties:
Expand Down Expand Up @@ -173,8 +178,10 @@ class RelatedObjects(entities.EntityList):
_namespace = "http://cybox.mitre.org/cybox-2"
_binding = core_binding
_binding_class = _binding.RelatedObjectsType

related_object = fields.TypedField("Related_Object", RelatedObject, multiple=True)


class DomainSpecificObjectProperties(entities.Entity):
"""The Cybox DomainSpecificObjectProperties base class."""
_binding = core_binding
Expand Down
1 change: 0 additions & 1 deletion cybox/objects/account_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ class Account(ObjectProperties):
creation_date = fields.TypedField("Creation_Date", DateTime)
modified_date = fields.TypedField("Modified_Date", DateTime)
last_accessed_time = fields.TypedField("Last_Accessed_Time", DateTime)

10 changes: 6 additions & 4 deletions cybox/objects/artifact_object.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015, The MITRE Corporation. All rights reserved.
# Copyright (c) 2017, The MITRE Corporation. All rights reserved.
# See LICENSE.txt for complete terms.
import base64
import bz2
Expand Down Expand Up @@ -63,10 +63,13 @@ class Artifact(ObjectProperties):

hashes = fields.TypedField("Hashes", HashList)
# packaging = fields.TypedField("Packaging", Packaging, multiple=True) # TODO: Support this as a TypedField
type_ = fields.TypedField("type_", key_name="type", preset_hook=validate_artifact_type)
type_ = fields.TypedField("type_", key_name="type", preset_hook=validate_artifact_type)
content_type = fields.TypedField("content_type")
content_type_version = fields.TypedField("content_type_version")
suspected_malicious = fields.TypedField("suspected_malicious")
# TODO: xs:choice
raw_artifact = fields.TypedField("Raw_Artifact", RawArtifact)
raw_artifact_reference = fields.TypedField("Raw_Artifact_Reference")

def __init__(self, data=None, type_=None):
super(Artifact, self).__init__()
Expand Down Expand Up @@ -152,8 +155,7 @@ def to_obj(self, ns_info=None):
elif isinstance(p, Encoding):
packaging.add_Encoding(p_obj)
else:
raise ValueError("Unsupported Packaging Type: %s" %
type(p))
raise ValueError("Unsupported Packaging Type: %s" % type(p))
artifact_obj.Packaging = packaging

if self.packed_data:
Expand Down
1 change: 1 addition & 0 deletions cybox/objects/as_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ class AutonomousSystem(ObjectProperties):
handle = fields.TypedField("Handle", String)
regional_internet_registry = fields.TypedField("Regional_Internet_Registry", String)


# Add alias for the "proper", but completely unhelpful name, "AS"
AS = AutonomousSystem
1 change: 1 addition & 0 deletions cybox/objects/code_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class TargetedPlatforms(entities.EntityList):
_binding = code_binding
_binding_class = code_binding.TargetedPlatformsType
_namespace = "http://cybox.mitre.org/objects#CodeObject-2"

targeted_platform = fields.TypedField("Targeted_Platform", PlatformSpecification, multiple=True)


Expand Down
1 change: 1 addition & 0 deletions cybox/objects/disk_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class PartitionList(entities.EntityList):
_binding = disk_binding
_binding_class = disk_binding.PartitionListType
_namespace = "http://cybox.mitre.org/objects#DiskObject-2"

partition = fields.TypedField("Partition", DiskPartition, multiple=True)


Expand Down
3 changes: 1 addition & 2 deletions cybox/objects/dns_cache_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ class DNSCache(ObjectProperties):
_XSI_NS = "DNSCacheObj"
_XSI_TYPE = "DNSCacheObjectType"

dns_cache_entry = fields.TypedField("DNS_Cache_Entry", DNSCacheEntry,
multiple=True)
dns_cache_entry = fields.TypedField("DNS_Cache_Entry", DNSCacheEntry, multiple=True)
9 changes: 3 additions & 6 deletions cybox/objects/dns_query_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ class DNSQuery(ObjectProperties):
successful = fields.TypedField("successful")
transaction_id = fields.TypedField("Transaction_ID", HexBinary)
question = fields.TypedField("Question", DNSQuestion)
answer_resource_records = fields.TypedField("Answer_Resource_Records",
DNSResourceRecords)
authority_resource_records = fields.TypedField("Authority_Resource_Records",
DNSResourceRecords)
additional_records = fields.TypedField("Additional_Records",
DNSResourceRecords)
answer_resource_records = fields.TypedField("Answer_Resource_Records", DNSResourceRecords)
authority_resource_records = fields.TypedField("Authority_Resource_Records", DNSResourceRecords)
additional_records = fields.TypedField("Additional_Records", DNSResourceRecords)
date_ran = fields.TypedField("Date_Ran", DateTime)
service_used = fields.TypedField("Service_Used", String)
14 changes: 7 additions & 7 deletions cybox/objects/file_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class EntryPointSignatureList(entities.EntityList):
_binding = file_binding
_binding_class = file_binding.EntryPointSignatureListType
_namespace = 'http://cybox.mitre.org/objects#FileObject-2'

entry_point_signature = fields.TypedField("Entry_Point_Signature", EntryPointSignature, multiple=True)


Expand All @@ -64,13 +65,15 @@ class PackerList(entities.EntityList):
_binding = file_binding
_binding_class = file_binding.PackerListType
_namespace = 'http://cybox.mitre.org/objects#FileObject-2'

packer = fields.TypedField("Packer", Packer, multiple=True)


class SymLinksList(entities.EntityList):
_binding = file_binding
_binding_class = file_binding.SymLinksListType
_namespace = 'http://cybox.mitre.org/objects#FileObject-2'

sym_link = fields.TypedField("Sym_Link", String, multiple=True)


Expand Down Expand Up @@ -106,23 +109,20 @@ class File(ObjectProperties):
magic_number = fields.TypedField("Magic_Number", HexBinary)
file_format = fields.TypedField("File_Format", String)
hashes = fields.TypedField("Hashes", HashList)
digital_signatures = fields.TypedField("Digital_Signatures",
DigitalSignatureList)
digital_signatures = fields.TypedField("Digital_Signatures", DigitalSignatureList)
modified_time = fields.TypedField("Modified_Time", DateTime)
accessed_time = fields.TypedField("Accessed_Time", DateTime)
created_time = fields.TypedField("Created_Time", DateTime)
# Subclasses must redefine these, since the abstract types
# cannot be instantiated.
file_attributes_list = fields.TypedField("File_Attributes_List",
FileAttribute) # abstract
permissions = fields.TypedField("Permissions", FilePermissions) # abstract
file_attributes_list = fields.TypedField("File_Attributes_List", FileAttribute) # abstract
permissions = fields.TypedField("Permissions", FilePermissions) # abstract
user_owner = fields.TypedField("User_Owner", String)
packer_list = fields.TypedField("Packer_List", PackerList)
peak_entropy = fields.TypedField("Peak_Entropy", Double)
sym_links = fields.TypedField("Sym_Links", SymLinksList)
byte_runs = fields.TypedField("Byte_Runs", ByteRuns)
extracted_features = fields.TypedField("Extracted_Features",
ExtractedFeatures)
extracted_features = fields.TypedField("Extracted_Features", ExtractedFeatures)
encryption_algorithm = fields.TypedField("Encryption_Algorithm", String)
decryption_key = fields.TypedField("Decryption_Key", String)
compression_method = fields.TypedField("Compression_Method", String)
Expand Down
16 changes: 5 additions & 11 deletions cybox/objects/http_session_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ class HTTPClientRequest(entities.Entity):
_namespace = "http://cybox.mitre.org/objects#HTTPSessionObject-2"

http_request_line = fields.TypedField("HTTP_Request_Line", HTTPRequestLine)
http_request_header = fields.TypedField("HTTP_Request_Header",
HTTPRequestHeader)
http_request_header = fields.TypedField("HTTP_Request_Header", HTTPRequestHeader)
http_message_body = fields.TypedField("HTTP_Message_Body", HTTPMessage)


Expand All @@ -117,8 +116,7 @@ class HTTPResponseHeaderFields(entities.Entity):
_binding_class = http_session_binding.HTTPResponseHeaderFieldsType
_namespace = "http://cybox.mitre.org/objects#HTTPSessionObject-2"

access_control_allow_origin = \
fields.TypedField("Access_Control_Allow_Origin", String)
access_control_allow_origin = fields.TypedField("Access_Control_Allow_Origin", String)
accept_ranges = fields.TypedField("Accept_Ranges", String)
age = fields.TypedField("Age", Integer)
cache_control = fields.TypedField("Cache_Control", String)
Expand All @@ -144,8 +142,7 @@ class HTTPResponseHeaderFields(entities.Entity):
retry_after = fields.TypedField("Retry_After", Integer)
server = fields.TypedField("Server", String)
set_cookie = fields.TypedField("Set_Cookie", String)
strict_transport_security = fields.TypedField("Strict_Transport_Security",
String)
strict_transport_security = fields.TypedField("Strict_Transport_Security", String)
trailer = fields.TypedField("Trailer", String)
transfer_encoding = fields.TypedField("Transfer_Encoding", String)
vary = fields.TypedField("Vary", String)
Expand Down Expand Up @@ -174,8 +171,7 @@ class HTTPServerResponse(entities.Entity):
_namespace = "http://cybox.mitre.org/objects#HTTPSessionObject-2"

http_status_line = fields.TypedField("HTTP_Status_Line", HTTPStatusLine)
http_response_header = fields.TypedField("HTTP_Response_Header",
HTTPResponseHeader)
http_response_header = fields.TypedField("HTTP_Response_Header", HTTPResponseHeader)
http_message_body = fields.TypedField("HTTP_Message_Body", HTTPMessage)


Expand All @@ -197,6 +193,4 @@ class HTTPSession(ObjectProperties):
_XSI_NS = "HTTPSessionObj"
_XSI_TYPE = "HTTPSessionObjectType"

http_request_response = fields.TypedField("HTTP_Request_Response",
HTTPRequestResponse,
multiple=True)
http_request_response = fields.TypedField("HTTP_Request_Response", HTTPRequestResponse, multiple=True)
3 changes: 1 addition & 2 deletions cybox/objects/memory_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ class Memory(ObjectProperties):
block_type = fields.TypedField("Block_Type", String)
region_start_address = fields.TypedField("Region_Start_Address", HexBinary)
region_end_address = fields.TypedField("Region_End_Address", HexBinary)
extracted_features = fields.TypedField("Extracted_Features",
ExtractedFeatures)
extracted_features = fields.TypedField("Extracted_Features", ExtractedFeatures)
9 changes: 3 additions & 6 deletions cybox/objects/network_connection_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ class NetworkConnection(ObjectProperties):
layer3_protocol = fields.TypedField('Layer3_Protocol', String)
layer4_protocol = fields.TypedField('Layer4_Protocol', String)
layer7_protocol = fields.TypedField('Layer7_Protocol', String)
source_socket_address = fields.TypedField('Source_Socket_Address',
SocketAddress)
source_socket_address = fields.TypedField('Source_Socket_Address', SocketAddress)
source_tcp_state = fields.TypedField('Source_TCP_State')
destination_socket_address = fields.TypedField('Destination_Socket_Address',
SocketAddress)
destination_socket_address = fields.TypedField('Destination_Socket_Address', SocketAddress)
destination_tcp_state = fields.TypedField('Destination_TCP_State')
layer7_connections = fields.TypedField('Layer7_Connections',
Layer7Connections)
layer7_connections = fields.TypedField('Layer7_Connections', Layer7Connections)
Loading