def from_dict(cls, d, return_obj=None):
        if not d:
            return None

        import stix.extensions.structured_coa.generic_structured_coa  # noqa

        if not return_obj:
            klass = stix.lookup_extension(d.get('xsi:type'))
            return_obj = klass.from_dict(d)
        else:
            return_obj.id_ = d.get('id')
            return_obj.idref = d.get('idref')

        return return_obj
예제 #2
0
    def from_dict(cls, d, return_obj=None):
        if not d:
            return None

        import stix.extensions.structured_coa.generic_structured_coa  # noqa

        if not return_obj:
            klass = stix.lookup_extension(d.get('xsi:type'))
            return_obj = klass.from_dict(d)
        else:
            return_obj.id_ = d.get('id')
            return_obj.idref = d.get('idref')

        return return_obj
    def from_obj(cls, obj, return_obj=None):
        if not obj:
            return None

        # Registers the class extension
        import stix.extensions.structured_coa.generic_structured_coa  # noqa

        if not return_obj:
            klass = stix.lookup_extension(obj)
            return_obj = klass.from_obj(obj)
        else:
            return_obj.id_ = obj.id
            return_obj.idref = obj.idref

        return return_obj
예제 #4
0
    def from_obj(cls, obj, return_obj=None):
        if not obj:
            return None

        # Registers the class extension
        import stix.extensions.structured_coa.generic_structured_coa  # noqa

        if not return_obj:
            klass = stix.lookup_extension(obj)
            return_obj = klass.from_obj(obj)
        else:
            return_obj.id_ = obj.id
            return_obj.idref = obj.idref

        return return_obj
예제 #5
0
    def from_obj(cls, obj, return_obj=None):
        import stix.extensions.identity.ciq_identity_3_0  # noqa
        
        if not obj:
            return None

        if not return_obj:
            klass = stix.lookup_extension(obj, default=cls)
            return_obj = klass.from_obj(obj, return_obj=klass())
        else:
            return_obj.id_ = obj.id
            return_obj.idref = obj.idref
            return_obj.name = obj.Name
            return_obj.related_identities = \
                RelatedIdentities.from_obj(obj.Related_Identities)

        return return_obj
예제 #6
0
    def from_obj(cls, obj, return_obj=None):
        import stix.extensions.identity.ciq_identity_3_0  # noqa

        if not obj:
            return None

        if not return_obj:
            klass = stix.lookup_extension(obj, default=cls)
            return_obj = klass.from_obj(obj, return_obj=klass())
        else:
            return_obj.id_ = obj.id
            return_obj.idref = obj.idref
            return_obj.name = obj.Name
            return_obj.related_identities = \
                RelatedIdentities.from_obj(obj.Related_Identities)

        return return_obj
    def from_obj(cls, obj, return_obj=None):
        import stix.extensions.malware.maec_4_1_malware  # noqa
        
        if not obj:
            return None
        
        if not return_obj:
            klass = stix.lookup_extension(obj, default=cls)
            return_obj = klass.from_obj(obj, klass())
        else:
            return_obj.id_ = obj.id
            return_obj.title = obj.Title
            return_obj.descriptions = StructuredTextList.from_obj(obj.Description)
            return_obj.short_descriptions = StructuredTextList.from_obj(obj.Short_Description)
            return_obj.names = MalwareNames.from_obj(obj.Name)
            return_obj.types = MalwareTypes.from_obj(obj.Type)

        return return_obj
예제 #8
0
    def from_dict(cls, dict_repr, return_obj=None):
        import stix.extensions.identity.ciq_identity_3_0  # noqa

        if not dict_repr:
            return None

        get = dict_repr.get

        if not return_obj:
            klass = stix.lookup_extension(get('xsi:type'), default=cls)
            return_obj = klass.from_dict(dict_repr, klass())
        else:
            return_obj.name = get('name')
            return_obj.id_ = get('id')
            return_obj.idref = get('idref')
            return_obj.related_identities = \
                RelatedIdentities.from_dict(get('related_identities'))

        return return_obj
예제 #9
0
    def from_dict(cls, dict_repr, return_obj=None):
        import stix.extensions.identity.ciq_identity_3_0  # noqa
        
        if not dict_repr:
            return None

        get = dict_repr.get

        if not return_obj:
            klass = stix.lookup_extension(get('xsi:type'), default=cls)
            return_obj = klass.from_dict(dict_repr, klass())
        else:
            return_obj.name = get('name')
            return_obj.id_ = get('id')
            return_obj.idref = get('idref')
            return_obj.related_identities = \
                RelatedIdentities.from_dict(get('related_identities'))

        return return_obj
 def from_dict(cls, d, return_obj=None):
     if not d:
         return None
     
     import stix.extensions.test_mechanism.snort_test_mechanism  # noqa
     import stix.extensions.test_mechanism.open_ioc_2010_test_mechanism  # noqa
     import stix.extensions.test_mechanism.yara_test_mechanism  # noqa
     import stix.extensions.test_mechanism.generic_test_mechanism  # noqa
     
     if not return_obj:
         klass = stix.lookup_extension(d.get('xsi:type'))
         return_obj = klass.from_dict(d)
     else:
         return_obj.id_ = d.get('id')
         return_obj.idref = d.get('idref')
         return_obj.efficacy = Statement.from_dict(d.get('efficacy'))
         return_obj.producer = InformationSource.from_dict(d.get('producer'))
         
     return return_obj
 def from_obj(cls, obj, return_obj=None):
     if not obj:
         return None
     
     import stix.extensions.test_mechanism.snort_test_mechanism  # noqa
     import stix.extensions.test_mechanism.open_ioc_2010_test_mechanism  # noqa
     import stix.extensions.test_mechanism.yara_test_mechanism  # noqa
     import stix.extensions.test_mechanism.generic_test_mechanism  # noqa
     
     if not return_obj:
         klass = stix.lookup_extension(obj)
         return_obj = klass.from_obj(obj)
     else:
         return_obj.id_ = obj.id
         return_obj.idref = obj.idref
         return_obj.efficacy = Statement.from_obj(obj.Efficacy)
         return_obj.producer = InformationSource.from_obj(obj.Producer)
     
     return return_obj
예제 #12
0
    def from_obj(cls, obj, return_obj=None):
        if not obj:
            return None

        import stix.extensions.test_mechanism.snort_test_mechanism  # noqa
        import stix.extensions.test_mechanism.open_ioc_2010_test_mechanism  # noqa
        import stix.extensions.test_mechanism.yara_test_mechanism  # noqa
        import stix.extensions.test_mechanism.generic_test_mechanism  # noqa

        if not return_obj:
            klass = stix.lookup_extension(obj)
            return_obj = klass.from_obj(obj)
        else:
            return_obj.id_ = obj.id
            return_obj.idref = obj.idref
            return_obj.efficacy = Statement.from_obj(obj.Efficacy)
            return_obj.producer = InformationSource.from_obj(obj.Producer)

        return return_obj
예제 #13
0
    def from_obj(cls, obj, return_obj=None):
        import stix.extensions.marking.tlp  # noqa
        import stix.extensions.marking.simple_marking  # noqa
        import stix.extensions.marking.terms_of_use_marking  # noqa

        if not obj:
            return None

        if return_obj:
            m = return_obj
            m.id_ = obj.id
            m.idref = obj.idref
            m.marking_model_name = obj.marking_model_name
            m.marking_model_ref = obj.marking_model_ref

        else:
            klass = stix.lookup_extension(obj, default=cls)
            m = klass.from_obj(obj, return_obj=klass())

        return m
예제 #14
0
    def from_obj(cls, obj, return_obj=None):
        import stix.extensions.malware.maec_4_1_malware  # noqa

        if not obj:
            return None

        if not return_obj:
            klass = stix.lookup_extension(obj, default=cls)
            return_obj = klass.from_obj(obj, klass())
        else:
            return_obj.id_ = obj.id
            return_obj.title = obj.Title
            return_obj.descriptions = StructuredTextList.from_obj(
                obj.Description)
            return_obj.short_descriptions = StructuredTextList.from_obj(
                obj.Short_Description)
            return_obj.names = MalwareNames.from_obj(obj.Name)
            return_obj.types = MalwareTypes.from_obj(obj.Type)

        return return_obj
    def from_dict(cls, dict_repr, return_obj=None):
        from stix.extensions.malware import maec_4_1_malware  # noqa

        if not dict_repr:
            return None

        get = dict_repr.get
    
        if not return_obj:
            klass = stix.lookup_extension(get('xsi:type'), cls)
            return_obj = klass.from_dict(dict_repr, klass())
        else:
            return_obj.id_ = get('id')
            return_obj.title = get('title')
            return_obj.descriptions = StructuredTextList.from_dict(get('description'))
            return_obj.short_descriptions = StructuredTextList.from_dict(get('short_description'))
            return_obj.names = MalwareNames.from_dict(get('names'))
            return_obj.types = MalwareTypes.from_dict(get('types'))

        return return_obj
예제 #16
0
    def from_dict(cls, d, return_obj=None):
        if not d:
            return None

        import stix.extensions.test_mechanism.snort_test_mechanism  # noqa
        import stix.extensions.test_mechanism.open_ioc_2010_test_mechanism  # noqa
        import stix.extensions.test_mechanism.yara_test_mechanism  # noqa
        import stix.extensions.test_mechanism.generic_test_mechanism  # noqa

        if not return_obj:
            klass = stix.lookup_extension(d.get('xsi:type'))
            return_obj = klass.from_dict(d)
        else:
            return_obj.id_ = d.get('id')
            return_obj.idref = d.get('idref')
            return_obj.efficacy = Statement.from_dict(d.get('efficacy'))
            return_obj.producer = InformationSource.from_dict(
                d.get('producer'))

        return return_obj
예제 #17
0
    def from_dict(cls, d, return_obj=None):
        import stix.extensions.marking.tlp  # noqa
        import stix.extensions.marking.simple_marking  # noqa
        import stix.extensions.marking.terms_of_use_marking  # noqa
        
        if not d:
            return None

        get = d.get
        
        if return_obj is not None:
            m = return_obj
            m.id_ = get('id')
            m.idref = get('idref')
            m.marking_model_name = get('marking_model_name')
            m.marking_model_ref = get('marking_model_ref')
        else:
            klass = stix.lookup_extension(get('xsi:type'), default=cls)
            m = klass.from_dict(d, return_obj=klass())

        return m
예제 #18
0
    def from_dict(cls, dict_repr, return_obj=None):
        from stix.extensions.malware import maec_4_1_malware  # noqa

        if not dict_repr:
            return None

        get = dict_repr.get

        if not return_obj:
            klass = stix.lookup_extension(get('xsi:type'), cls)
            return_obj = klass.from_dict(dict_repr, klass())
        else:
            return_obj.id_ = get('id')
            return_obj.title = get('title')
            return_obj.descriptions = StructuredTextList.from_dict(
                get('description'))
            return_obj.short_descriptions = StructuredTextList.from_dict(
                get('short_description'))
            return_obj.names = MalwareNames.from_dict(get('names'))
            return_obj.types = MalwareTypes.from_dict(get('types'))

        return return_obj
예제 #19
0
    def lookup_class(xsi_type):
        if not xsi_type:
            raise ValueError("xsi:type is required")

        return stix.lookup_extension(xsi_type)
예제 #20
0
 def lookup_class(xsi_type):
     return stix.lookup_extension(xsi_type, default=MarkingStructure)
예제 #21
0
 def entity_class(cls, key):
     import stix.extensions.marking.tlp  # noqa
     import stix.extensions.marking.simple_marking  # noqa
     import stix.extensions.marking.terms_of_use_marking  # noqa
     return stix.lookup_extension(key, default=MarkingStructure)
예제 #22
0
 def lookup_class(xsi_type):
     return stix.lookup_extension(xsi_type, default=MarkingStructure)
예제 #23
0
 def entity_class(cls, key):
     import stix.extensions.structured_coa.generic_structured_coa  # noqa
     return stix.lookup_extension(key)
예제 #24
0
 def entity_class(cls, key):
     import stix.extensions.structured_coa.generic_structured_coa  # noqa
     return stix.lookup_extension(key)
예제 #25
0
 def lookup_class(xsi_type):
     return stix.lookup_extension(xsi_type, default=Identity)
예제 #26
0
    def lookup_class(xsi_type):
        if not xsi_type:
            raise ValueError("xsi:type is required")

        return stix.lookup_extension(xsi_type)
예제 #27
0
 def entity_class(cls, key):
     from stix.extensions.malware.maec_4_1_malware import MAECInstance  # noqa
     return stix.lookup_extension(key, default=MalwareInstance)
예제 #28
0
 def entity_class(cls, key):
     return stix.lookup_extension(key, default=MalwareInstance)
예제 #29
0
    def lookup_class(xsi_type):
        if not xsi_type:
            return MarkingStructure

        return stix.lookup_extension(xsi_type)
예제 #30
0
 def lookup_class(xsi_type):
     try:
         return stix.lookup_extension(xsi_type, default=VocabString)
     except ValueError:
         return VocabString
예제 #31
0
 def entity_class(cls, key):
     from stix.extensions.malware.maec_4_1_malware import MAECInstance  # noqa
     return stix.lookup_extension(key, default=MalwareInstance)
예제 #32
0
 def entity_class(cls, key):
     import stix.extensions.identity.ciq_identity_3_0  # noqa
     return stix.lookup_extension(key, default=Identity)
예제 #33
0
 def entity_class(self, key):
     import stix.extensions.test_mechanism.snort_test_mechanism  # noqa
     import stix.extensions.test_mechanism.open_ioc_2010_test_mechanism  # noqa
     import stix.extensions.test_mechanism.yara_test_mechanism  # noqa
     import stix.extensions.test_mechanism.generic_test_mechanism  # noqa
     return stix.lookup_extension(key)
예제 #34
0
파일: vocabs.py 프로젝트: sgml/python-stix
 def entity_class(cls, key):
     try:
         return stix.lookup_extension(key, default=VocabString)
     except ValueError:
         return VocabString
예제 #35
0
 def entity_class(cls, key):
     import stix.extensions.marking.tlp  # noqa
     import stix.extensions.marking.simple_marking  # noqa
     import stix.extensions.marking.terms_of_use_marking  # noqa
     return stix.lookup_extension(key, default=MarkingStructure)
예제 #36
0
 def lookup_class(xsi_type):
     try:
         return stix.lookup_extension(xsi_type, default=VocabString)
     except ValueError:
         return VocabString
예제 #37
0
 def entity_class(self, key):
     import stix.extensions.test_mechanism.snort_test_mechanism  # noqa
     import stix.extensions.test_mechanism.open_ioc_2010_test_mechanism  # noqa
     import stix.extensions.test_mechanism.yara_test_mechanism  # noqa
     import stix.extensions.test_mechanism.generic_test_mechanism  # noqa
     return stix.lookup_extension(key)