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())
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
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())
#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())