Skip to content

Commit

Permalink
Add Raw_Artifact_Reference to Artifact. closes #301
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanvg committed Nov 21, 2017
1 parent 8df8468 commit 5d5e3ee
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 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 All @@ -23,6 +23,16 @@ def validate_artifact_type(instance, value):
raise ValueError(err)


def validate_byte_order_endianness(instance, value):
if value is None:
return
elif value in RawArtifact.ENDIANNESS:
return
else:
err = "Type must be one of %s. Received '%s'." % (RawArtifact.ENDIANNESS, value)
raise ValueError(err)


class RawArtifact(String):
_binding_class = artifact_binding.RawArtifactType
_namespace = 'http://cybox.mitre.org/objects#ArtifactObject-2'
Expand Down Expand Up @@ -67,6 +77,9 @@ class Artifact(ObjectProperties):
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 +165,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

0 comments on commit 5d5e3ee

Please sign in to comment.