Exemplo n.º 1
0
    def from_obj(cls, obj, return_obj=None):
        from stix.common import StructuredTextList, InformationSource
        from stix.data_marking import Marking

        if not return_obj:
            raise ValueError("Must provide a return_obj argument")

        if not obj:
            raise ValueError("Must provide an obj argument")

        return_obj.id_ = obj.id
        return_obj.idref = obj.idref
        return_obj.timestamp = obj.timestamp

        # These may not be found on the input obj if it isn't a full
        # type definition (e.g., used as a reference)
        return_obj.version = getattr(obj, 'version', None)
        return_obj.title = getattr(obj, 'Title', None)
        return_obj.descriptions = \
            StructuredTextList.from_obj(getattr(obj, 'Description', None))
        return_obj.short_descriptions = \
            StructuredTextList.from_obj(getattr(obj, 'Short_Description', None))
        return_obj.information_source = \
            InformationSource.from_obj(getattr(obj, 'Information_Source', None))
        return_obj.handling = \
            Marking.from_obj(getattr(obj, 'Handling', None))

        return return_obj
Exemplo n.º 2
0
    def from_obj(cls, obj, return_obj=None):
        if not obj:
            return None
        if not return_obj:
            return_obj = cls()

        return_obj.descriptions = StructuredTextList.from_obj(obj.Description)
        return_obj.short_descriptions = StructuredTextList.from_obj(obj.Short_Description)
        return_obj.applicability_confidence = Confidence.from_obj(obj.Applicability_Confidence)
        return return_obj
Exemplo n.º 3
0
    def from_dict(cls, dict_repr, return_obj=None):
        if not dict_repr:
            return None
        if not return_obj:
            return_obj = cls()

        get = dict_repr.get
        return_obj.description = StructuredTextList.from_dict(get('description'))
        return_obj.short_description = StructuredTextList.from_dict(get('short_description'))
        return_obj.applicability_confidence = Confidence.from_dict(get('applicability_confidence'))
        
        return return_obj
Exemplo n.º 4
0
    def from_obj(cls, obj, return_obj=None):
        if not obj:
            return None
        if not return_obj:
            return_obj = cls()

        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 return_obj
Exemplo n.º 5
0
    def from_dict(cls, dict_repr, return_obj=None):
        if not dict_repr:
            return None
        if not return_obj:
            return_obj = cls()

        return_obj.id_ = dict_repr.get('id')
        return_obj.title = dict_repr.get('title')
        return_obj.descriptions = StructuredTextList.from_dict(dict_repr.get('description'))
        return_obj.short_descriptions = StructuredTextList.from_dict(dict_repr.get('short_description'))

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

        if not return_obj:
            return_obj = cls()

        return_obj.descriptions = StructuredTextList.from_obj(obj.Description)
        return_obj.short_description = StructuredTextList.from_obj(obj.Short_Description)
        return_obj.cce_id = obj.CCE_ID

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

        if not return_obj:
            return_obj = cls()

        get = dict_repr.get
        return_obj.descriptions = StructuredTextList.from_dict(get('description'))
        return_obj.short_descriptions = StructuredTextList.from_dict(get('short_description'))
        return_obj.cce_id = get('cce_id')

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

        return_obj.id_ = dict_repr.get('id')
        return_obj.title = dict_repr.get('title')
        return_obj.descriptions = StructuredTextList.from_dict(dict_repr.get('description'))
        return_obj.short_descriptions = StructuredTextList.from_dict(dict_repr.get('short_description'))
        return_obj.types = [VocabString.from_dict(x) for x in dict_repr.get('types', [])]
        return_obj.observable_characterization = Observables.from_dict(dict_repr.get('observable_characterization'))

        return return_obj
Exemplo n.º 9
0
class Sighting(stix.Entity):
    _namespace = "http://stix.mitre.org/Indicator-2"
    _binding = indicator_binding
    _binding_class = _binding.SightingType
    
    timestamp = fields.DateTimeField("timestamp")
    timestamp_precision = fields.TypedField("timestamp_precision", preset_hook=validate_precision)
    descriptions = fields.TypedField("Description", StructuredTextList)
    source = fields.TypedField("Source", InformationSource)
    reference = fields.TypedField("Reference")
    confidence = fields.TypedField("Confidence", Confidence)
    related_observables = fields.TypedField("Related_Observables", type_="stix.indicator.sightings.RelatedObservables")
    
    def __init__(self, timestamp=None, timestamp_precision=None, description=None):
        super(Sighting, self).__init__()

        self.timestamp = timestamp or utils.dates.now()
        self.timestamp_precision = timestamp_precision
        self.descriptions = description
        self.source = None
        self.reference = None
        self.confidence = None

    @property
    def description(self):
        """A single description about the contents or purpose of this object.

        Default Value: ``None``

        Note:
            If this object has more than one description set, this will return
            the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`

        """
        return next(iter(self.descriptions or []), None)

    @description.setter
    def description(self, value):
        self.descriptions = StructuredTextList(value)

    def add_description(self, description):
        """Adds a description to the ``descriptions`` collection.

        This is the same as calling "foo.descriptions.add(bar)".

        """
        self.descriptions.add(description)
Exemplo n.º 10
0
    def from_obj(cls, obj, return_obj=None):
        if not obj:
            return None

        if not return_obj:
            return_obj = cls()

        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.handling = Marking.from_obj(obj.Handling)
        return_obj.information_source = InformationSource.from_obj(obj.Information_Source)
        return_obj.intents = _ReportIntents.from_obj(obj.Intent)

        return return_obj
Exemplo n.º 11
0
    def from_obj(cls, obj, return_obj=None):
        if not obj:
            return None

        if not return_obj:
            return_obj = cls()

        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.handling = Marking.from_obj(obj.Handling)
        return_obj.information_source = InformationSource.from_obj(obj.Information_Source)
        return_obj.package_intents = _PackageIntents.from_obj(obj.Package_Intent)
        return_obj.profiles = obj.Profiles.Profile if obj.Profiles else []

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

        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.observable_characterization = Observables.from_obj(obj.Observable_Characterization)

        if obj.Type:
            return_obj.types = [VocabString.from_obj(x) for x in obj.Type]

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

        get = d.get
        return_obj.type_ = AssetType.from_dict(get('type'))
        return_obj.descriptions = StructuredTextList.from_dict(get('description'))
        return_obj.business_functions_or_roles = StructuredTextList.from_dict(get('business_function_or_role'))
        return_obj.ownership_class = VocabString.from_dict(get('ownership_class'))
        return_obj.management_class = VocabString.from_dict(get('management_class'))
        return_obj.location_class = VocabString.from_dict(get('location_class'))
        # return_obj.location = Location.from_dict(get('location'))
        return_obj.nature_of_security_effect = NatureOfSecurityEffect.from_dict(get('nature_of_security_effect'))
        return_obj.structured_description = Observables.from_dict(get('structured_description'))
        return return_obj
Exemplo n.º 14
0
    def add_description(self, description):
        """Adds a description to the ``descriptions`` collection.

        This is the same as calling "foo.descriptions.add(bar)".
        """
        if self.descriptions is None:
            self.descriptions = StructuredTextList()
        self.descriptions.add(description)
Exemplo n.º 15
0
    def from_dict(cls, dict_repr, return_obj=None):
        if not dict_repr:
            return None

        if not return_obj:
            return_obj = cls()

        get = dict_repr.get

        return_obj.title = get('title')
        return_obj.intents = _ReportIntents.from_list(get('intents'))
        return_obj.descriptions = StructuredTextList.from_dict(get('description'))
        return_obj.short_descriptions = StructuredTextList.from_dict(get('short_description'))
        return_obj.handling = Marking.from_dict(get('handling'))
        return_obj.information_source = InformationSource.from_dict(get('information_source'))

        return return_obj
class GenericTestMechanism(_BaseTestMechanism):
    _namespace = "http://stix.mitre.org/extensions/TestMechanism#Generic-1"
    _binding = generic_tm_binding
    _binding_class = _binding.GenericTestMechanismType
    _XSI_TYPE = "genericTM:GenericTestMechanismType"
    
    reference_location = fields.TypedField("reference_location")
    descriptions = fields.TypedField("Description", StructuredTextList)
    specification = fields.TypedField("Specification", EncodedCDATA)
    type_ = VocabField("Type")
    
    def __init__(self, id_=None, idref=None):
        super(GenericTestMechanism, self).__init__(id_=id_, idref=idref)
        self.descriptions = StructuredTextList()

    @property
    def description(self):
        """A single description about the contents or purpose of this object.

        Default Value: ``None``

        Note:
            If this object has more than one description set, this will return
            the description with the lowest ordinality value.

        Returns:
            An instance of
            :class:`.StructuredText`

        """
        return next(iter(self.descriptions), None)

    @description.setter
    def description(self, value):
        self.descriptions = StructuredTextList(value)

    def add_description(self, description):
        """Adds a description to the ``descriptions`` collection.

        This is the same as calling "foo.descriptions.add(bar)".

        """
        if self.descriptions is None:
            self.descriptions = StructuredTextList()
        self.descriptions.add(description)
    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_obj(cls, obj, return_obj=None):
        if not obj:
            return None
        if not return_obj:
            return_obj = cls()

        return_obj.type_ = AssetType.from_obj(obj.Type)
        return_obj.descriptions = StructuredTextList.from_obj(obj.Description)
        return_obj.business_functions_or_roles = StructuredTextList.from_obj(obj.Business_Function_Or_Role)
        return_obj.ownership_class = VocabString.from_obj(obj.Ownership_Class)
        return_obj.management_class = VocabString.from_obj(obj.Management_Class)
        return_obj.location_class = VocabString.from_obj(obj.Location_Class)
        # return_obj.location = None
        
        if obj.Nature_Of_Security_Effect:
            n = obj.Nature_Of_Security_Effect
            return_obj.nature_of_security_effect = [PropertyAffected.from_obj(x) for x in n.Property_Affected]

        return return_obj
Exemplo n.º 19
0
    def from_dict(cls, dict_repr, return_obj=None):
        if not dict_repr:
            return None
        if not return_obj:
            return_obj = cls()

        return_obj.descriptions = StructuredTextList.from_dict(dict_repr.get('description'))
        return_obj.cwe_id = dict_repr.get('cwe_id')

        return return_obj
Exemplo n.º 20
0
    def from_dict(cls, d, return_obj=None):
        from stix.common import StructuredTextList, InformationSource
        from stix.data_marking import Marking

        if not return_obj:
            raise ValueError("Must provide a return_obj argument")

        get = d.get
        return_obj.id_ = get("id")
        return_obj.idref = get("idref")
        return_obj.timestamp = get("timestamp")
        return_obj.version = get("version")
        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.information_source = InformationSource.from_dict(get("information_source"))
        return_obj.handling = Marking.from_dict(get("handling"))

        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
 def from_obj(cls, obj, return_obj=None):
     if not obj:
         return None
     if not return_obj:
         return_obj = cls()
         
     return_obj.property_ = VocabString.from_obj(obj.Property)
     return_obj.descriptions_of_effect = StructuredTextList.from_obj(obj.Description_Of_Effect)
     return_obj.type_of_availability_loss = VocabString.from_obj(obj.Type_Of_Availability_Loss)
     return_obj.duration_of_availability_loss = VocabString.from_obj(obj.Duration_Of_Availability_Loss)
     return_obj.non_public_data_compromised = NonPublicDataCompromised.from_obj(obj.Non_Public_Data_Compromised)
     return return_obj
 def from_dict(cls, d, return_obj=None):
     if not d:
         return None
     if not return_obj:
         return_obj = cls()
         
     super(GenericTestMechanism, cls).from_dict(d, return_obj)
     return_obj.reference_location = d.get('reference_location')
     return_obj.descriptions = StructuredTextList.from_dict(d.get('description'))
     return_obj.type_ = VocabString.from_dict(d.get('type'))
     return_obj.specification = EncodedCDATA.from_dict(d.get('specification'))
     
     return return_obj
 def from_dict(cls, d, return_obj=None):
     if not d:
         return None
     if not return_obj:
         return_obj = cls()
         
     return_obj.property_ = VocabString.from_dict(d.get('property'))
     return_obj.descriptions_of_effect = StructuredTextList.from_dict(d.get('description_of_effect'))
     return_obj.type_of_availability_loss = VocabString.from_dict(d.get('type_of_availability_loss'))
     return_obj.duration_of_availability_loss = VocabString.from_dict(d.get('duration_of_availability_loss'))
     return_obj.non_public_data_compromised = NonPublicDataCompromised.from_dict(d.get('non_public_data_compromised'))
     
     return return_obj
 def from_obj(cls, obj, return_obj=None):
     if not obj:
         return None
     if not return_obj:
         return_obj = cls()
     
     super(GenericTestMechanism, cls).from_obj(obj, return_obj)
     return_obj.reference_location = obj.reference_location
     return_obj.descriptions = StructuredTextList.from_obj(obj.Description)
     return_obj.type_ = VocabString.from_obj(obj.Type)
     return_obj.specification = EncodedCDATA.from_obj(obj.Specification)
     
     return return_obj
Exemplo n.º 26
0
    def from_dict(cls, dict_repr, return_obj=None):
        if not dict_repr:
            return None
        if not return_obj:
            return_obj = cls()

        get = dict_repr.get
        return_obj.is_known = utils.xml_bool(get('is_known'))
        return_obj.is_publicly_acknowledged = utils.xml_bool(get('is_publicly_acknowledged'))
        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.cve_id = get('cve_id')
        return_obj.osvdb_id = get('osvdb_id')
        return_obj.source = get('source')
        return_obj.cvss_score = CVSSVector.from_dict(get('cvss_score'))
        return_obj.discovered_datetime = DateTimeWithPrecision.from_dict(get('discovered_datetime'))
        return_obj.published_datetime = DateTimeWithPrecision.from_dict(get('published_datetime'))
        return_obj.affected_software = AffectedSoftware.from_dict(get('affected_software'))
        return_obj.references = get('references')

        return return_obj
Exemplo n.º 27
0
    def from_dict(cls, d, return_obj=None):
        from stix.common import StructuredTextList, InformationSource
        from stix.data_marking import Marking

        if not return_obj:
            raise ValueError("Must provide a return_obj argument")

        get = d.get
        return_obj.id_ = get('id')
        return_obj.idref = get('idref')
        return_obj.timestamp = get('timestamp')
        return_obj.version = get('version')
        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.information_source = \
            InformationSource.from_dict(get('information_source'))
        return_obj.handling = \
            Marking.from_dict(get('handling'))

        return return_obj
Exemplo n.º 28
0
    def from_obj(cls, obj, return_obj=None):
        if not obj:
            return None
        if not return_obj:
            return_obj = cls()

        return_obj.is_known = utils.xml_bool(obj.is_known)
        return_obj.is_publicly_acknowledged = utils.xml_bool(obj.is_publicly_acknowledged)
        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.cve_id = obj.CVE_ID
        return_obj.osvdb_id = obj.OSVDB_ID
        return_obj.source = obj.Source
        return_obj.cvss_score = CVSSVector.from_obj(obj.CVSS_Score)
        return_obj.discovered_datetime = DateTimeWithPrecision.from_obj(obj.Discovered_DateTime)
        return_obj.published_datetime = DateTimeWithPrecision.from_obj(obj.Published_DateTime)
        return_obj.affected_software = AffectedSoftware.from_obj(obj.Affected_Software)

        if obj.References:
            return_obj.references = obj.References.Reference

        return return_obj
Exemplo n.º 29
0
    def from_dict(cls, d, return_obj=None):
        if not d:
            return None
        if return_obj is None:
            return_obj = cls()

        return_obj.timestamp = d.get('timestamp')
        return_obj.timestamp_precision = d.get('timestamp_precision')
        return_obj.source = InformationSource.from_dict(d.get('source'))
        return_obj.reference = d.get('reference')
        return_obj.confidence = Confidence.from_dict(d.get('confidence'))
        return_obj.descriptions = StructuredTextList.from_dict(d.get('description'))
        return_obj.related_observables = RelatedObservables.from_dict(d.get('related_observables'))
        return return_obj
Exemplo n.º 30
0
    def description(self):
        """A single description about the contents or purpose of this object.

        Default Value: ``None``

        Note:
            If this object has more than one description set, this will return
            the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        if self.descriptions is None:
            self.descriptions = StructuredTextList()
        return next(iter(self.descriptions), None)
Exemplo n.º 31
0
class MalwareInstance(stix.Entity):
    _binding = ttp_binding
    _binding_class = _binding.MalwareInstanceType
    _namespace = "http://stix.mitre.org/TTP-1"
    _XSI_TYPE = None  # defined by subclasses

    id_ = fields.IdField("id")
    idref = fields.IdrefField("idref")
    title = fields.TypedField("Title")
    descriptions = fields.TypedField("Description",
                                     type_="stix.common.StructuredTextList")
    short_descriptions = fields.TypedField(
        "Short_Description", type_="stix.common.StructuredTextList")
    names = vocabs.VocabField("Name",
                              type_=VocabString,
                              multiple=True,
                              key_name="names")
    types = vocabs.VocabField("Type",
                              type_=vocabs.MalwareType,
                              multiple=True,
                              key_name="types")

    def __init__(self,
                 id_=None,
                 idref=None,
                 title=None,
                 description=None,
                 short_description=None):
        super(MalwareInstance, self).__init__()
        self.id_ = id_
        self.idref = idref
        self.title = title
        self.description = StructuredTextList(description)
        self.short_description = StructuredTextList(short_description)

    @property
    def description(self):
        """A single description about the contents or purpose of this object.

        Default Value: ``None``

        Note:
            If this object has more than one description set, this will return
            the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        if self.descriptions is None:
            self.descriptions = StructuredTextList()
        return next(iter(self.descriptions), None)

    @description.setter
    def description(self, value):
        self.descriptions = value

    def add_description(self, description):
        """Adds a description to the ``descriptions`` collection.

        This is the same as calling "foo.descriptions.add(bar)".
        """
        self.descriptions.add(description)

    @property
    def short_description(self):
        """A single short description about the contents or purpose of this
        object.

        Default Value: ``None``

        Note:
            If this object has more than one short description set, this will
            return the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        if self.short_descriptions is None:
            self.short_descriptions = []
        return next(iter(self.short_descriptions), None)

    @short_description.setter
    def short_description(self, value):
        self.short_descriptions = value

    def add_short_description(self, description):
        """Adds a description to the ``short_descriptions`` collection.

        This is the same as calling "foo.short_descriptions.add(bar)".
        """
        self.short_descriptions.add(description)

    def add_name(self, name):
        self.names.append(name)

    def add_type(self, type_):
        self.types.append(type_)

    @staticmethod
    def lookup_class(xsi_type):
        if not xsi_type:
            raise ValueError("xsi:type is required")

        return stix.lookup_extension(xsi_type)
Exemplo n.º 32
0
 def __init__(self, description=None, short_description=None, cce_id=None):
     super(Configuration, self).__init__()
     self.description = StructuredTextList(description)
     self.short_description = StructuredTextList(short_description)
     self.cce_id = cce_id
Exemplo n.º 33
0
    def __init__(self, description=None, short_description=None):
        super(Objective, self).__init__()

        self.description = StructuredTextList(description)
        self.short_description = StructuredTextList(short_description)
Exemplo n.º 34
0
 def __init__(self, description=None, cwe_id=None):
     super(Weakness, self).__init__()
     self.description = StructuredTextList(description)
     self.cwe_id = cwe_id
Exemplo n.º 35
0
class BaseCoreComponent(Entity):
    _ALL_VERSIONS = ()
    _ID_PREFIX = None

    title = fields.TypedField("Title")
    id_ = fields.IdField("id")
    idref = fields.IdrefField("idref")
    descriptions = fields.TypedField(
        "Description",
        type_="stix.common.StructuredTextList",
    )
    short_descriptions = fields.TypedField(
        "Short_Description", type_="stix.common.StructuredTextList")
    version = fields.TypedField("version", preset_hook=_validate_version)
    timestamp = fields.DateTimeField("timestamp")
    handling = fields.TypedField("Handling", type_="stix.data_marking.Marking")

    def __init__(self,
                 id_=None,
                 idref=None,
                 timestamp=None,
                 title=None,
                 description=None,
                 short_description=None):
        from stix.common import StructuredTextList

        super(BaseCoreComponent, self).__init__()

        self.id_ = id_ or idgen.create_id(self._ID_PREFIX)
        self.idref = idref
        self.title = title
        self.descriptions = StructuredTextList(description)
        self.short_descriptions = StructuredTextList(short_description)

        if timestamp:
            self.timestamp = timestamp
        else:
            self.timestamp = utils.dates.now() if not idref else None

    @property
    def description(self):
        """A single description about the contents or purpose of this object.

        Default Value: ``None``

        Note:
            If this object has more than one description set, this will return
            the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        return next(iter(self.descriptions), None)

    @description.setter
    def description(self, value):
        self.descriptions = value

    def add_description(self, description):
        """Adds a description to the ``descriptions`` collection.

        This is the same as calling "foo.descriptions.add(bar)".
        """
        self.descriptions.add(description)

    @property
    def short_description(self):
        """A single short description about the contents or purpose of this
        object.

        Default Value: ``None``

        Note:
            If this object has more than one short description set, this will
            return the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        return next(iter(self.short_descriptions), None)

    @short_description.setter
    def short_description(self, value):
        self.short_descriptions = value

    def add_short_description(self, description):
        """Adds a description to the ``short_descriptions`` collection.

        This is the same as calling "foo.short_descriptions.add(bar)".
        """
        self.short_descriptions.add(description)
 def __init__(self, id_=None, idref=None):
     super(GenericStructuredCOA, self).__init__(id_=id_, idref=idref)
     self.descriptions = StructuredTextList()
Exemplo n.º 37
0
 def business_functions_or_roles(self, value):
     self._business_function_or_role = StructuredTextList(value)
Exemplo n.º 38
0
class STIXHeader(stix.Entity):
    """The STIX Package Header.

    Args:
        handling: The data marking section of the Header.
        information_source: The :class:`.InformationSource` section of the
            Header.
        package_intents: **DEPRECATED**. A collection of :class:`.VocabString`
            defining the intent of the parent :class:`.STIXPackage`.
        description: **DEPRECATED**. A description of the intent or purpose
            of the parent :class:`.STIXPackage`.
        short_description: **DEPRECATED**. A short description of the intent
            or purpose of the parent :class:`.STIXPackage`.
        title: **DEPRECATED**. The title of the :class:`.STIXPackage`.

    Attributes:
        profiles: A collection of STIX Profiles the parent
            :class:`.STIXPackage` conforms to.
        title: **DEPRECATED**. The title of the parent :class:`.STIXPackage`.

    """
    _binding = stix_core_binding
    _binding_class = _binding.STIXHeaderType
    _namespace = 'http://stix.mitre.org/stix-1'

    title = fields.TypedField("Title", preset_hook=deprecated.field)
    package_intents = VocabField("Package_Intent", PackageIntent, multiple=True, preset_hook=deprecated.field)
    descriptions = fields.TypedField("Description", type_=StructuredTextList, preset_hook=deprecated.field)
    short_descriptions = fields.TypedField("Short_Description", type_=StructuredTextList, preset_hook=deprecated.field)
    handling = fields.TypedField("Handling", Marking)
    information_source = fields.TypedField("Information_Source", InformationSource)
    profiles = fields.TypedField("Profiles", Profiles)

    def __init__(self, package_intents=None, description=None, handling=None,
                 information_source=None, title=None, short_description=None):

        super(STIXHeader, self).__init__()

        self.package_intents = package_intents
        self.title = title
        self.description = StructuredTextList(description)
        self.short_description = StructuredTextList(short_description)
        self.handling = handling
        self.information_source = information_source
        self.profiles = None

    @property
    def description(self):
        """**DEPRECATED**. A single description about the contents or
        purpose of this object.

        Default Value: ``None``

        Note:
            If this object has more than one description set, this will return
            the description with the lowest ordinality value.

        Returns:
            An instance of
            :class:`.StructuredText`

        """
        return next(iter(self.descriptions), None)

    @description.setter
    def description(self, value):
        self.descriptions = StructuredTextList(value)

    def add_description(self, description):
        """**DEPRECATED**. Adds a description to the ``descriptions``
        collection.

        This is the same as calling "foo.descriptions.add(bar)".

        """
        deprecated.warn(description)
        self.descriptions.add(description)

    @property
    def short_description(self):
        """**DEPRECATED**. A single short description about the contents or
        purpose of this object.

        Default Value: ``None``

        Note:
            If this object has more than one short description set, this will
            return the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`

        """
        return next(iter(self.short_descriptions), None)

    @short_description.setter
    def short_description(self, value):
        self.short_descriptions = StructuredTextList(value)

    def add_short_description(self, description):
        """**DEPRECATED**. Adds a description to the ``short_descriptions``
        collection.

        This is the same as calling "foo.short_descriptions.add(bar)".

        """
        deprecated.warn(description)
        self.short_descriptions.add(description)


    def add_package_intent(self, package_intent):
        """**DEPRECATED**. Adds :class:`.VocabString` object to the
        :attr:`package_intents` collection.

        If the input is not an instance of :class:`.VocabString`, an effort
        will be made to convert it into an instance of :class:`.PackageIntent`.

        """
        deprecated.warn(package_intent)
        self.package_intents.append(package_intent)

    def add_profile(self, profile):
        """Adds a profile to the STIX Header. A Profile is represented by a
        string URI.

        """
        self.profiles.append(profile)
Exemplo n.º 39
0
 def short_descriptions(self, value):
     deprecated(value)
     self._short_description = StructuredTextList(value)
Exemplo n.º 40
0
class Vulnerability(stix.Entity):
    """Implementation of STIX ``Vulnerability``.

    Args:
        title (optional): A string title.
        description (optional): A string description.
        short_description (optional): A string short description.

    """
    _binding = exploit_target_binding
    _binding_class = _binding.VulnerabilityType
    _namespace = "http://stix.mitre.org/ExploitTarget-1"

    is_known = fields.BooleanField("is_known")
    is_publicly_acknowledged = fields.BooleanField("is_publicly_acknowledged")
    title = fields.TypedField("Title")
    descriptions = fields.TypedField("Description", type_="stix.common.StructuredTextList")
    short_descriptions = fields.TypedField("Short_Description", type_="stix.common.StructuredTextList")
    cve_id = fields.TypedField("CVE_ID")
    osvdb_id = fields.TypedField("OSVDB_ID")
    source = fields.TypedField("Source")
    cvss_score = fields.TypedField("CVSS_Score", "stix.exploit_target.vulnerability.CVSSVector")
    discovered_datetime = fields.TypedField("Discovered_DateTime", DateTimeWithPrecision)
    published_datetime = fields.TypedField("Published_DateTime", DateTimeWithPrecision)
    affected_software = fields.TypedField("Affected_Software", "stix.exploit_target.vulnerability.AffectedSoftware")
    references = fields.TypedField("References", References)

    def __init__(self, title=None, description=None, short_description=None):
        super(Vulnerability, self).__init__()
        self.title = title
        self.descriptions = StructuredTextList(description)
        self.short_descriptions = StructuredTextList(short_description)
        self.references = []

    @property
    def description(self):
        """A single description about the contents or purpose of this object.

        Default Value: ``None``

        Note:
            If this object has more than one description set, this will return
            the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        return next(iter(self.descriptions or []), None)

    @description.setter
    def description(self, value):
        self.descriptions = value

    def add_description(self, description):
        """Adds a description to the ``descriptions`` collection.

        This is the same as calling "foo.descriptions.add(bar)".
        """
        self.descriptions.add(description)

    @property
    def short_description(self):
        """A single short description about the contents or purpose of this
        object.

        Default Value: ``None``

        Note:
            If this object has more than one short description set, this will
            return the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        return next(iter(self.short_descriptions or []), None)

    @short_description.setter
    def short_description(self, value):
        self.short_descriptions = value

    def add_short_description(self, description):
        """Adds a description to the ``short_descriptions`` collection.

        This is the same as calling "foo.short_descriptions.add(bar)".
        """
        self.short_descriptions.add(description)

    def add_reference(self, reference):
        if not reference:
            return

        self.references.append(reference)
Exemplo n.º 41
0
 def short_descriptions(self, value):
     from stix.common import StructuredTextList
     self._short_description = StructuredTextList(value)
Exemplo n.º 42
0
 def descriptions_of_effect(self, value):
     self._description_of_effect = StructuredTextList(value)
Exemplo n.º 43
0
class Exploit(stix.Entity):
    _binding = ttp_binding
    _binding_class = _binding.ExploitType
    _namespace = "http://stix.mitre.org/TTP-1"

    id_ = fields.IdField("id")
    idref = fields.IdrefField("idref")
    title = fields.TypedField("Title")
    descriptions = fields.TypedField("Description",
                                     type_="stix.common.StructuredTextList")
    short_descriptions = fields.TypedField(
        "Short_Description", type_="stix.common.StructuredTextList")

    def __init__(self,
                 id_=None,
                 idref=None,
                 title=None,
                 description=None,
                 short_description=None):
        super(Exploit, self).__init__()
        self.id_ = id_
        self.idref = idref
        self.title = title
        self.description = StructuredTextList(description)
        self.short_description = StructuredTextList(short_description)

    @property
    def description(self):
        """A single description about the contents or purpose of this object.

        Default Value: ``None``

        Note:
            If this object has more than one description set, this will return
            the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        if self.descriptions is None:
            self.descriptions = StructuredTextList()
        return next(iter(self.descriptions), None)

    @description.setter
    def description(self, value):
        self.descriptions = value

    def add_description(self, description):
        """Adds a description to the ``descriptions`` collection.

        This is the same as calling "foo.descriptions.add(bar)".
        """
        self.descriptions.add(description)

    @property
    def short_description(self):
        """A single short description about the contents or purpose of this
        object.

        Default Value: ``None``

        Note:
            If this object has more than one short description set, this will
            return the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        if self.short_descriptions is None:
            self.short_descriptions = StructuredTextList()
        return next(iter(self.short_descriptions), None)

    @short_description.setter
    def short_description(self, value):
        self.short_descriptions = value

    def add_short_description(self, description):
        """Adds a description to the ``short_descriptions`` collection.

        This is the same as calling "foo.short_descriptions.add(bar)".
        """
        self.short_descriptions.add(description)
Exemplo n.º 44
0
 def __init__(self):
     super(PropertyAffected, self).__init__()
     self.descriptions_of_effect = StructuredTextList()
Exemplo n.º 45
0
 def short_descriptions(self, value):
     self._short_description = StructuredTextList(value)
Exemplo n.º 46
0
 def __init__(self, title=None, description=None, short_description=None):
     super(Vulnerability, self).__init__()
     self.title = title
     self.descriptions = StructuredTextList(description)
     self.short_descriptions = StructuredTextList(short_description)
     self.references = []
Exemplo n.º 47
0
class Infrastructure(stix.Entity):
    _binding = ttp_binding
    _binding_class = _binding.InfrastructureType
    _namespace = "http://stix.mitre.org/TTP-1"
    
    
    id_ = fields.IdField("id")
    idref = fields.IdrefField("idref")
    title = fields.TypedField("Title")
    descriptions = fields.TypedField("Description", StructuredTextList)
    short_descriptions = fields.TypedField("Short_Description", StructuredTextList)
    types = fields.TypedField("Type", VocabString, multiple=True, key_name="types")
    observable_characterization = fields.TypedField("Observable_Characterization", Observables)
    
    
    def __init__(self, id_=None, idref=None, title=None, description=None, short_description=None):
        super(Infrastructure, self).__init__()
        self.id_ = id_
        self.idref = idref
        self.title = title
        self.description = StructuredTextList(description)
        self.short_description = StructuredTextList(short_description)


    @property
    def description(self):
        """A single description about the contents or purpose of this object.

        Default Value: ``None``

        Note:
            If this object has more than one description set, this will return
            the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        if self.descriptions is None:
            self.descriptions = StructuredTextList()
        return next(iter(self.descriptions), None)

    @description.setter
    def description(self, value):
        self.descriptions = StructuredTextList(value)

    def add_description(self, description):
        """Adds a description to the ``descriptions`` collection.

        This is the same as calling "foo.descriptions.add(bar)".
        """
        self.descriptions.add(description)

    @property
    def short_description(self):
        """A single short description about the contents or purpose of this
        object.

        Default Value: ``None``

        Note:
            If this object has more than one short description set, this will
            return the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        if self.short_descriptions is None:
            self.short_descriptions = StructuredTextList()
        return next(iter(self.short_descriptions), None)

    @short_description.setter
    def short_description(self, value):
        self.short_descriptions = value

    def add_short_description(self, description):
        """Adds a description to the ``short_descriptions`` collection.

        This is the same as calling "foo.short_descriptions.add(bar)".
        """
        self.short_descriptions.add(description)

    def add_type(self, type_):
        self.types.append(type_)
Exemplo n.º 48
0
 def description(self, value):
     self.descriptions = StructuredTextList(value)
Exemplo n.º 49
0
 def __init__(self):
     super(AffectedAsset, self).__init__()
     self.description = StructuredTextList()
     self.business_function_or_role = StructuredTextList()
Exemplo n.º 50
0
class Configuration(stix.Entity):
    """Implementation of STIX ``Configuration``.

    Args:
        cce_id(optional): Common Configuration Enumeration value as a string
        description (optional): A string description.
        short_description (optional): A string short description.

    """
    _binding = exploit_target_binding
    _binding_class = _binding.ConfigurationType
    _namespace = "http://stix.mitre.org/ExploitTarget-1"

    descriptions = fields.TypedField("Description",
                                     type_="stix.common.StructuredTextList")
    short_descriptions = fields.TypedField(
        "Short_Description", type_="stix.common.StructuredTextList")
    cce_id = fields.TypedField("CCE_ID")

    def __init__(self, description=None, short_description=None, cce_id=None):
        super(Configuration, self).__init__()
        self.description = StructuredTextList(description)
        self.short_description = StructuredTextList(short_description)
        self.cce_id = cce_id

    @property
    def description(self):
        """A single description about the contents or purpose of this object.

        Default Value: ``None``

        Note:
            If this object has more than one description set, this will return
            the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        if self.descriptions is None:
            return None
        return next(iter(self.descriptions), None)

    @description.setter
    def description(self, value):
        self.descriptions = value

    def add_description(self, description):
        """Adds a description to the ``descriptions`` collection.

        This is the same as calling "foo.descriptions.add(bar)".
        """
        if self.descriptions is None:
            self.descriptions = StructuredTextList()
        self.descriptions.add(description)

    @property
    def short_description(self):
        """A single short description about the contents or purpose of this
        object.

        Default Value: ``None``

        Note:
            If this object has more than one short description set, this will
            return the description with the lowest ordinality value.

        Returns:
            An instance of :class:`.StructuredText`
        """
        if self.short_descriptions is None:
            self.short_descriptions = StructuredTextList()
        return next(iter(self.short_descriptions), None)

    @short_description.setter
    def short_description(self, value):
        self.short_descriptions = value

    def add_short_description(self, description):
        """Adds a description to the ``short_descriptions`` collection.

        This is the same as calling "foo.short_descriptions.add(bar)".
        """
        self.short_descriptions.add(description)