当前位置: 首页>>代码示例>>Python>>正文


Python RelatedPackageRefs.append方法代码示例

本文整理汇总了Python中stix.common.related.RelatedPackageRefs.append方法的典型用法代码示例。如果您正苦于以下问题:Python RelatedPackageRefs.append方法的具体用法?Python RelatedPackageRefs.append怎么用?Python RelatedPackageRefs.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stix.common.related.RelatedPackageRefs的用法示例。


在下文中一共展示了RelatedPackageRefs.append方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_add_stix_package

# 需要导入模块: from stix.common.related import RelatedPackageRefs [as 别名]
# 或者: from stix.common.related.RelatedPackageRefs import append [as 别名]
    def test_add_stix_package(self):
        from stix.core import STIXPackage

        l = RelatedPackageRefs()
        l.append(STIXPackage())

        self.assertEqual(1, len(l))
开发者ID:ExodusIntelligence,项目名称:python-stix,代码行数:9,代码来源:related_test.py

示例2: Incident

# 需要导入模块: from stix.common.related import RelatedPackageRefs [as 别名]
# 或者: from stix.common.related.RelatedPackageRefs import append [as 别名]
class Incident(stix.BaseCoreComponent):
    """Implementation of the STIX Incident.

    Args:
        id_ (optional): An identifier. If ``None``, a value will be generated
            via ``mixbox.idgen.create_id()``. If set, this will unset the
            ``idref`` property.
        idref (optional): An identifier reference. If set this will unset the
            ``id_`` property.
        timestamp (optional): A timestamp value. Can be an instance of
            ``datetime.datetime`` or ``str``.
        description: A description of the purpose or intent of this object.
        short_description: A short description of the intent
            or purpose of this object.
        title: The title of this object.

    """
    _binding = incident_binding
    _binding_class = _binding.IncidentType
    _namespace = "http://stix.mitre.org/Incident-1"
    _version = "1.2"
    _ALL_VERSIONS = ("1.0", "1.0.1", "1.1", "1.1.1", "1.2")
    _ID_PREFIX = 'incident'

    status = vocabs.VocabField("Status", vocabs.IncidentStatus)
    time = fields.TypedField("Time", Time)
    victims = fields.TypedField("Victim", Identity, factory=IdentityFactory, multiple=True, key_name="victims")
    attributed_threat_actors = fields.TypedField("Attributed_Threat_Actors", type_="stix.incident.AttributedThreatActors")
    related_indicators = fields.TypedField("Related_Indicators", type_="stix.incident.RelatedIndicators")
    related_observables = fields.TypedField("Related_Observables", type_="stix.incident.RelatedObservables")
    related_incidents = fields.TypedField("Related_Incidents", type_="stix.incident.RelatedIncidents")
    related_packages = fields.TypedField("Related_Packages", RelatedPackageRefs)
    affected_assets = fields.TypedField("Affected_Assets", type_="stix.incident.AffectedAssets")
    categories = fields.TypedField("Categories", type_="stix.incident.IncidentCategories")
    intended_effects = StatementField("Intended_Effect", Statement, vocab_type=vocabs.IntendedEffect, multiple=True, key_name="intended_effects")
    leveraged_ttps = fields.TypedField("Leveraged_TTPs", type_="stix.incident.LeveragedTTPs")
    discovery_methods = vocabs.VocabField("Discovery_Method", vocabs.DiscoveryMethod, multiple=True, key_name="discovery_methods")
    reporter = fields.TypedField("Reporter", InformationSource)
    responders = fields.TypedField("Responder", InformationSource, multiple=True, key_name="responders")
    coordinators = fields.TypedField("Coordinator", InformationSource, multiple=True, key_name="coordinators")
    external_ids = fields.TypedField("External_ID", ExternalID, multiple=True, key_name="external_ids")
    impact_assessment = fields.TypedField("Impact_Assessment", ImpactAssessment)
    security_compromise = vocabs.VocabField("Security_Compromise", vocabs.SecurityCompromise)
    confidence = fields.TypedField("Confidence", Confidence)
    coa_taken = fields.TypedField("COA_Taken", COATaken, multiple=True)
    coa_requested = fields.TypedField("COA_Requested", COARequested, multiple=True)
    history = fields.TypedField("History", History)
    information_source = fields.TypedField("Information_Source", InformationSource)
    url = fields.TypedField("URL")
    contacts = fields.TypedField("Contact", InformationSource, multiple=True, key_name="contacts")

    def __init__(self, id_=None, idref=None, timestamp=None, title=None, description=None, short_description=None):
        super(Incident, self).__init__(
            id_=id_,
            idref=idref,
            timestamp=timestamp,
            title=title,
            description=description,
            short_description=short_description
        )
        self.related_indicators = RelatedIndicators()
        self.related_observables = RelatedObservables()
        self.related_incidents = RelatedIncidents()
        self.related_packages = RelatedPackageRefs()
        self.categories = IncidentCategories()
        self.affected_assets = AffectedAssets()
        self.leveraged_ttps = LeveragedTTPs()
        
    def add_intended_effect(self, value):
        """Adds a :class:`.Statement` object to the :attr:`intended_effects`
        collection.

        If `value` is a string, an attempt will be made to convert it into an
        instance of :class:`.Statement`.

        """
        self.intended_effects.append(value)

    def add_leveraged_ttps(self, ttp):
        """Adds a :class:`.RelatedTTP` value to the :attr:`leveraged_ttps`
        collection.

        """
        self.leveraged_ttps.append(ttp)

    def add_victim(self, victim):
        """Adds a :class:`.IdentityType` value to the :attr:`victims`
        collection.

        """
        self.victims.append(victim)

    def add_category(self, category):
        """Adds a :class:`.VocabString` object to the :attr:`categories`
        collection.

        If `category` is a string, an attempt will be made to convert it into
        an instance of :class:`.IncidentCategory`.

        """
#.........这里部分代码省略.........
开发者ID:STIXProject,项目名称:python-stix,代码行数:103,代码来源:__init__.py

示例3: Indicator

# 需要导入模块: from stix.common.related import RelatedPackageRefs [as 别名]
# 或者: from stix.common.related.RelatedPackageRefs import append [as 别名]

#.........这里部分代码省略.........
    def observables(self):
        """A list of ``cybox.core.Observable`` instances. This can be set to
        a single object instance or a list of objects.

        Note:
            If only one Observable is set, this property will return a list
            with the ``observable`` property.

            If multiple ``cybox.core.Observable`` this property will return
            Observables under the ``cybox.core.ObservableComposition``.

            Access to the top level ``cybox.core.Observable`` is made via
            ``observable`` property.

        Default Value:
            Empty ``list``.

        Returns:
            A ``list`` of ``cybox.core.Observable`` instances.

        """
        if not self.observable:
            return []
        elif self.observable.observable_composition:
            return self.observable.observable_composition.observables

        # self.observable is defined and not a composition.
        return [self.observable]

    @observables.setter
    def observables(self, value):
        """
        The method will automatically create a top ``cybox.core.Observable`` and
        append all ``cybox.core.Observable`` using ``observable_composition``
        property when a ``list`` is given with length greater than 1.

        Note:
            The top level ``cybox.core.Observable`` will set the ``operator``
            property for the ``cybox.core.ObservableComposition`` via the
            ``observable_composition_operator`` property. The value of
            ``operator`` can be changed via ``observable_composition_operator``
            property. By default, the composition layer will be set to ``"OR"``.

        Args:
            value: A ``list`` of ``cybox.core.Observable`` instances or a single
                ``cybox.core.Observable`` instance.

        Raises:
            ValueError: If set to a value that cannot be converted to an
                instance of ``cybox.core.Observable``.
        """
        if not value:
            return

        if isinstance(value, Observable):
            self.observable = value

        elif utils.is_sequence(value):
            if len(value) == 1:
                self.add_observable(value[0])
                return

            observable_comp = ObservableComposition()
            observable_comp.operator = self.observable_composition_operator

            for element in value:
开发者ID:STIXProject,项目名称:python-stix,代码行数:70,代码来源:indicator.py

示例4: test_deprecated_warning

# 需要导入模块: from stix.common.related import RelatedPackageRefs [as 别名]
# 或者: from stix.common.related.RelatedPackageRefs import append [as 别名]
    def test_deprecated_warning(self):
        from stix.core import STIXPackage

        l = RelatedPackageRefs()
        l.append(STIXPackage())
开发者ID:ExodusIntelligence,项目名称:python-stix,代码行数:7,代码来源:related_test.py

示例5: Incident

# 需要导入模块: from stix.common.related import RelatedPackageRefs [as 别名]
# 或者: from stix.common.related.RelatedPackageRefs import append [as 别名]

#.........这里部分代码省略.........

        """
        return self._time

    @time.setter
    def time(self, value):
        self._set_var(Time, try_cast=False, time=value)

    @property
    def intended_effects(self):
        """The impact of this intended effects of this Incident. This is a
        collection of :class:`.Statement` objects and behaves like a
        ``MutableSequence`` type.

        If set to a string, an attempt will be made to convert it into a
        :class:`.Statement` object with its value set to an instance of
        :class:`.IntendedEffect`.

        """
        return self._intended_effects

    @intended_effects.setter
    def intended_effects(self, value):
        self._intended_effects = _IntendedEffects(value)

    def add_intended_effect(self, value):
        """Adds a :class:`.Statement` object to the :attr:`intended_effects`
        collection.

        If `value` is a string, an attempt will be made to convert it into an
        instance of :class:`.Statement`.

        """
        self.intended_effects.append(value)

    @property
    def victims(self):
        """A collection of victim :class:`.Identity` objects. This behaves like
        a ``MutableSequence`` type.

        """
        return self._victims

    @victims.setter
    def victims(self, value):
        self._victims = _Victims(value)

    def add_victim(self, victim):
        """Adds a :class:`.IdentityType` value to the :attr:`victims`
        collection.

        """
        self._victims.append(victim)

    @property
    def categories(self):
        """A collection of :class:`.VocabString` objects. This behaves
        like a ``MutableSequence`` type.

        """
        return self._categories

    @categories.setter
    def categories(self, value):
        self._categories = IncidentCategories(value)
开发者ID:nnh100,项目名称:python-stix,代码行数:69,代码来源:__init__.py

示例6: Indicator

# 需要导入模块: from stix.common.related import RelatedPackageRefs [as 别名]
# 或者: from stix.common.related.RelatedPackageRefs import append [as 别名]
class Indicator(stix.BaseCoreComponent):
    """Implementation of the STIX Indicator.

    Args:
        id_ (optional): An identifier. If ``None``, a value will be generated
            via ``mixbox.idgen.create_id()``. If set, this will unset the
            ``idref`` property.
        idref (optional): An identifier reference. If set this will unset the
            ``id_`` property.
        title (optional): A string title.
        timestamp (optional): A timestamp value. Can be an instance of
            ``datetime.datetime`` or ``str``.
        description (optional): A string description.
        short_description (optional): A string short description.

    """
    _binding = indicator_binding
    _binding_class = indicator_binding.IndicatorType
    _namespace = 'http://stix.mitre.org/Indicator-2'
    _version = "2.2"
    _ALL_VERSIONS = ("2.0", "2.0.1", "2.1", "2.1.1", "2.2")
    _ALLOWED_COMPOSITION_OPERATORS = ('AND', 'OR')
    _ID_PREFIX = "indicator"

    def __init__(self, id_=None, idref=None, timestamp=None, title=None,
                 description=None, short_description=None):

        super(Indicator, self).__init__(
            id_=id_,
            idref=idref,
            timestamp=timestamp,
            title=title,
            description=description,
            short_description=short_description
        )

        self.producer = None
        self.observables = None
        self.indicator_types = IndicatorTypes()
        self.confidence = None
        self.indicated_ttps = _IndicatedTTPs()
        self.test_mechanisms = TestMechanisms()
        self.alternative_id = None
        self.suggested_coas = SuggestedCOAs()
        self.sightings = Sightings()
        self.composite_indicator_expression = None
        self.kill_chain_phases = KillChainPhasesReference()
        self.valid_time_positions = _ValidTimePositions()
        self.related_indicators = None
        self.related_campaigns = RelatedCampaignRefs()
        self.observable_composition_operator = "OR"
        self.likely_impact = None
        self.negate = None
        self.related_packages = RelatedPackageRefs()

    @property
    def producer(self):
        """Contains information about the source of the :class:`Indicator`.

        Default Value: ``None``

        Returns:
            An instance of
            :class:`stix.common.information_source.InformationSource`

        Raises:
            ValueError: If set to a value that is not ``None`` and not an
                instance of
                :class:`stix.common.information_source.InformationSource`

        """
        return self._producer

    @producer.setter
    def producer(self, value):
        self._set_var(InformationSource, try_cast=False, producer=value)

    @property
    def observable(self):
        """A convenience property for accessing or setting the only
        ``cybox.core.Observable`` instance held by this Indicator.

        Default Value: Empty ``list``.

        Setting this property results in the ``observables`` property being
        reinitialized to an empty ``list`` and appending the input value,
        resulting in a ``list`` containing one value.

        Note:
            If the ``observables`` list contains more than one item, this
            property will only return the first item in the list.

        Returns:
            An instance of ``cybox.core.Observable``.

        Raises:
            ValueError: If set to a value that cannot be converted to an
                instance of ``cybox.core.Observable``.


#.........这里部分代码省略.........
开发者ID:shinsec,项目名称:python-stix,代码行数:103,代码来源:indicator.py


注:本文中的stix.common.related.RelatedPackageRefs.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。