Ejemplo n.º 1
0
 def test_nonstandard_type_vocab(self):
     ar = ActionRelationship()
     ar.type = VocabString(u"AddedMultipleTimes")
     ar.type.vocab_reference = "http://example.com/action-types/"
     ar.type.xsi_type = None
     ar2 = round_trip(ar)
     self.assertEqual(ar.to_dict(), ar2.to_dict())
Ejemplo n.º 2
0
 def create_action_relationship(self,type=None,action_references=None):
     actionrelationship = ActionRelationship()
     actionrelationship.type =type
     if action_references is not None:
         for actionref in action_references:
             actionrelationship.action_references.append(actionref)
     return  actionrelationship
Ejemplo n.º 3
0
 def test_nonstandard_type_vocab(self):
     ar = ActionRelationship()
     ar.type = ActionType("AddedMultipleTimes")
     ar.type.vocab_reference = "http://example.com/action-types/"
     ar.type.xsi_type = None
     ar2 = round_trip(ar)
     self.assertEqual(ar.to_dict(), ar2.to_dict())
Ejemplo n.º 4
0
    #Add timestamp
    import datetime
    ex.add_timestamp(timestamp=datetime.datetime.now())
    ###################################################################################################################
    #Add Ordinal Position
    ex.add_ordinal_position(15)
    ###################################################################################################################
    #Add Associated objects
    from cybox.objects.product_object import Product
    from cybox.common.vocabs import ActionObjectAssociationType
    at = ActionObjectAssociationType()
    at.value = ActionObjectAssociationType.TERM_AFFECTED
    dobj = Product()
    dobj.product='TestProduct'
    ob1 = ex.create_associated_object(defined_object=dobj,association_type=at)
    ex.add_associated_objects(associated_object=ob1)
    ###################################################################################################################
    # Add Frequency
    ex.add_frequnecy(rate=15,scale=18,trend=7,units=19)
    ###################################################################################################################
    # Add Relationships
    from cybox.common.vocabs import ActionRelationshipType
    ar= ActionRelationship()
    ar.value = ActionRelationshipType.TERM_INITIATED
    rf1 = ex.create_action_reference(action_id='test1d:1234')
    rel1 = ex.create_action_relationship(action_references=[rf1],type=ar)
    ex.add_relationships(action_relationship=rel1)
    ###################################################################################################################
    #Printing results
    print(ex.to_xml())