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


Python RelatedPackageRefs.to_obj方法代码示例

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


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

示例1: ExploitTarget

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

#.........这里部分代码省略.........
        
        return self._configuration
    
    @configuration.setter
    def configuration(self, value):
        self._configuration = []
        if not value:
            return
        elif isinstance(value, list):
            for v in value:
                self.add_configuration(v)
        else:
            self.add_configuration(value)
            
    def add_configuration(self, v):
        """Adds a configuration to the ``configurations`` list property.

        Note:
            If ``None`` is passed in no value is added 

        Args:
            v: A configuration value.
            
        Raises: ValueError if the ``v`` param is of type :class:`stix.exploit_target.configuration`

        """
        if not v:
            return
        elif isinstance(v, Configuration):
            self.configuration.append(v)
        else:
            raise ValueError('Cannot add type %s to configuration list' % type(v))
 
    def to_obj(self, return_obj=None, ns_info=None):
        super(ExploitTarget, self).to_obj(return_obj=return_obj, ns_info=ns_info)

        if not return_obj:
            return_obj = self._binding_class()

        return_obj.id = self.id_
        return_obj.idref = self.idref
        return_obj.timestamp = dates.serialize_value(self.timestamp)
        return_obj.version = self.version
        return_obj.Title = self.title

        if self.description:
            return_obj.Description = self.description.to_obj(ns_info=ns_info)
        if self.short_description:
            return_obj.Short_Description = self.short_description.to_obj(ns_info=ns_info)
        if self.information_source:
            return_obj.Information_Source = self.information_source.to_obj(ns_info=ns_info)
        if self.handling:
            return_obj.Handling = self.handling.to_obj(ns_info=ns_info)
        if self.potential_coas:
            return_obj.Potential_COAs = self.potential_coas.to_obj(ns_info=ns_info)
        if self.related_exploit_targets:
            return_obj.Related_Exploit_Targets = self.related_exploit_targets.to_obj(ns_info=ns_info)
        if self.vulnerabilities:
            return_obj.Vulnerability = [x.to_obj(ns_info=ns_info) for x in self.vulnerabilities]
        if self.weaknesses:
            return_obj.Weakness = [x.to_obj(ns_info=ns_info) for x in self.weaknesses]
        if self.configuration:
            return_obj.Configuration = [x.to_obj(ns_info=ns_info) for x in self.configuration]
        if self.related_packages:
            return_obj.Related_Packages = self.related_packages.to_obj(ns_info=ns_info)
            
开发者ID:DavidWatersHub,项目名称:python-stix,代码行数:69,代码来源:__init__.py

示例2: ThreatActor

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

#.........这里部分代码省略.........
    def add_intended_effect(self, value):
        if not value:
            return
        elif isinstance(value, Statement):
            self.intended_effects.append(value)
        else:
            intended_effect = IntendedEffect(value)
            self.intended_effects.append(Statement(value=intended_effect))

    @property
    def planning_and_operational_supports(self):
        return self._planning_and_operational_supports
    
    @planning_and_operational_supports.setter
    def planning_and_operational_supports(self, value):
        self._planning_and_operational_supports = []
        if not value:
            return
        elif isinstance(value, list):
            for v in value:
                self.add_planning_and_operational_support(v)
        else:
            self.add_planning_and_operational_support(value)
            
    def add_planning_and_operational_support(self, value):
        if not value:
            return
        elif isinstance(value, Statement):
            self.planning_and_operational_supports.append(value)
        else:
            pos = PlanningAndOperationalSupport(value)
            self.planning_and_operational_supports.append(Statement(value=pos))

    def to_obj(self, return_obj=None, ns_info=None):
        super(ThreatActor, self).to_obj(return_obj=return_obj, ns_info=ns_info)

        if not return_obj:
            return_obj = self._binding_class()

        return_obj.id = self.id_
        return_obj.idref = self.idref
        if self.timestamp:
            return_obj.timestamp = dates.serialize_value(self.timestamp)
        return_obj.version = self.version
        return_obj.Title = self.title
        if self.description:
            return_obj.Description = self.description.to_obj(ns_info=ns_info)
        if self.short_description:
            return_obj.Short_Description = self.short_description.to_obj(ns_info=ns_info)
        if self.identity:
            return_obj.Identity = self.identity.to_obj(ns_info=ns_info)
        if self.types:
            return_obj.Type = [x.to_obj(ns_info=ns_info) for x in self.types]
        if self.motivations:
            return_obj.Motivation = [x.to_obj(ns_info=ns_info) for x in self.motivations]
        if self.sophistications:
            return_obj.Sophistication = [x.to_obj(ns_info=ns_info) for x in self.sophistications]
        if self.intended_effects:
            return_obj.Intended_Effect = [x.to_obj(ns_info=ns_info) for x in self.intended_effects]
        if self.planning_and_operational_supports:
            return_obj.Planning_And_Operational_Support = [x.to_obj(ns_info=ns_info) for x in self.planning_and_operational_supports]
        if self.observed_ttps:
            return_obj.Observed_TTPs = self.observed_ttps.to_obj(ns_info=ns_info)
        if self.associated_campaigns:
            return_obj.Associated_Campaigns = self.associated_campaigns.to_obj(ns_info=ns_info)
        if self.associated_actors:
开发者ID:DavidWatersHub,项目名称:python-stix,代码行数:70,代码来源:__init__.py

示例3: ThreatActor

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

#.........这里部分代码省略.........
        """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 planning_and_operational_supports(self):
        """A collection of :class:`.VocabString` objects. Default is
        :class:`.PlanningAndOperationalSupport`.

        This behaves like a ``MutableSequence`` type.

        """
        return self._planning_and_operational_supports
    
    @planning_and_operational_supports.setter
    def planning_and_operational_supports(self, value):
        self._planning_and_operational_supports = _PlanningAndOperationalSupports(value)
            
    def add_planning_and_operational_support(self, value):
        """Adds a :class:`.VocabString` object to the
        :attr:`planning_and_operational_supports` collection.

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

        """
        self.planning_and_operational_supports.append(value)

    def to_obj(self, return_obj=None, ns_info=None):
        if not return_obj:
            return_obj = self._binding_class()

        super(ThreatActor, self).to_obj(return_obj=return_obj, ns_info=ns_info)

        if self.identity:
            return_obj.Identity = self.identity.to_obj(ns_info=ns_info)
        if self.types:
            return_obj.Type = self.types.to_obj(ns_info=ns_info)
        if self.motivations:
            return_obj.Motivation = self.motivations.to_obj(ns_info=ns_info)
        if self.sophistications:
            return_obj.Sophistication = self.sophistications.to_obj(ns_info=ns_info)
        if self.intended_effects:
            return_obj.Intended_Effect = self.intended_effects.to_obj(ns_info=ns_info)
        if self.planning_and_operational_supports:
            return_obj.Planning_And_Operational_Support = \
                self.planning_and_operational_supports.to_obj(ns_info=ns_info)
        if self.observed_ttps:
            return_obj.Observed_TTPs = self.observed_ttps.to_obj(ns_info=ns_info)
        if self.associated_campaigns:
            return_obj.Associated_Campaigns = self.associated_campaigns.to_obj(ns_info=ns_info)
        if self.associated_actors:
            return_obj.Associated_Actors = self.associated_actors.to_obj(ns_info=ns_info)
        if self.confidence:
            return_obj.Confidence = self.confidence.to_obj(ns_info=ns_info)
        if self.related_packages:
            return_obj.Related_Packages = self.related_packages.to_obj(ns_info=ns_info)

        return return_obj

    @classmethod
开发者ID:thurday,项目名称:python-stix,代码行数:70,代码来源:__init__.py

示例4: Campaign

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

#.........这里部分代码省略.........
    def add_activity(self, value):
        """Adds an :class:`.Activity` object to the :attr:`activity`
        collection.

        """
        self.activity.append(value)

    @property
    def status(self):
        """The status of the Campaign. This is a :class:`VocabString` field.

        If set to a string, an attempt will be made to convert it to a
        :class:`.CampaignStatus` object.

        """
        return self._status

    @status.setter
    def status(self, value):
        self._set_vocab(vocabs.CampaignStatus, status=value)

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

        """
        return self._attribution

    @attribution.setter
    def attribution(self, value):
        self._attribution = _AttributionList(value)

    def to_obj(self, return_obj=None, ns_info=None):
        if not return_obj:
            return_obj = self._binding_class()

        super(Campaign, self).to_obj(return_obj=return_obj, ns_info=ns_info)

        if self.names:
            return_obj.Names = self.names.to_obj(ns_info=ns_info)
        if self.intended_effects:
            return_obj.Intended_Effect = self.intended_effects.to_obj(ns_info=ns_info)
        if self.status:
            return_obj.Status = self.status.to_obj(ns_info=ns_info)
        if self.related_ttps:
            return_obj.Related_TTPs = self.related_ttps.to_obj(ns_info=ns_info)
        if self.related_incidents:
            return_obj.Related_Incidents = self.related_incidents.to_obj(ns_info=ns_info)
        if self.related_indicators:
            return_obj.Related_Indicators = self.related_indicators.to_obj(ns_info=ns_info)
        if self.attribution:
            return_obj.Attribution = self.attribution.to_obj(ns_info=ns_info)
        if self.associated_campaigns:
            return_obj.Associated_Campaigns = self.associated_campaigns.to_obj(ns_info=ns_info)
        if self.confidence:
            return_obj.Confidence = self.confidence.to_obj(ns_info=ns_info)
        if self.activity:
            return_obj.Activity = self.activity.to_obj(ns_info=ns_info)
        if self.related_packages:
            return_obj.Related_Packages = self.related_packages.to_obj(ns_info=ns_info)

        return return_obj

    @classmethod
    def from_obj(cls, obj, return_obj=None):
开发者ID:ExodusIntelligence,项目名称:python-stix,代码行数:70,代码来源:__init__.py

示例5: CourseOfAction

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

#.........这里部分代码省略.........
    @efficacy.setter
    def efficacy(self, efficacy):
        if not efficacy:
            self._efficacy = None
        elif isinstance(efficacy, Statement):
            self._efficacy = efficacy
        else:
            self._efficacy = Statement(value=efficacy)

    @property
    def information_source(self):
        return self._information_source

    @information_source.setter
    def information_source(self, value):
        if not value:
            self._information_source = None
        elif isinstance(value, InformationSource):
            self._information_source = value
        else:
            raise ValueError('value must be instance of InformationSource')

    @property
    def handling(self):
        return self._handling

    @handling.setter
    def handling(self, value):
        if value and not isinstance(value, Marking):
            raise ValueError('value must be instance of Marking')

        self._handling = value

    def to_obj(self, return_obj=None, ns_info=None):
        super(CourseOfAction, self).to_obj(return_obj=return_obj, ns_info=ns_info)

        if not return_obj:
            return_obj = self._binding_class()

        return_obj.id = self.id_
        return_obj.idref = self.idref
        if self.timestamp:
            return_obj.timestamp = self.timestamp.isoformat()
        return_obj.version = self.version
        return_obj.Title = self.title
        if self.stage:
            return_obj.Stage = self.stage.to_obj(ns_info=ns_info)
        if self.type_:
            return_obj.Type = self.type_.to_obj(ns_info=ns_info)
        if self.description:
            return_obj.Description = self.description.to_obj(ns_info=ns_info)
        if self.short_description:
            return_obj.Short_Description = self.short_description.to_obj(ns_info=ns_info)
        if self.objective:
            return_obj.Objective = self.objective.to_obj(ns_info=ns_info)
        if self.parameter_observables:
            return_obj.Parameter_Observables = self.parameter_observables.to_obj(ns_info=ns_info)
        if self.impact:
            return_obj.Impact = self.impact.to_obj(ns_info=ns_info)
        if self.cost:
            return_obj.Cost = self.cost.to_obj(ns_info=ns_info)
        if self.efficacy:
            return_obj.Efficacy = self.efficacy.to_obj(ns_info=ns_info)
        if self.information_source:
            return_obj.Information_Source = self.information_source.to_obj(ns_info=ns_info)
        if self.handling:
开发者ID:Seevil,项目名称:python-stix,代码行数:70,代码来源:__init__.py

示例6: Campaign

# 需要导入模块: from stix.common.related import RelatedPackageRefs [as 别名]
# 或者: from stix.common.related.RelatedPackageRefs import to_obj [as 别名]
class Campaign(stix.Entity):
    _binding = campaign_binding
    _binding_class = _binding.CampaignType
    _namespace = "http://stix.mitre.org/Campaign-1"
    _version = "1.1"

    def __init__(self, id_=None, idref=None, timestamp=None, title=None, description=None, short_description=None):
        self.id_ = id_ or stix.utils.create_id("Campaign")
        self.idref = idref
        self.timestamp = timestamp or datetime.now()
        self.version = self._version
        self.title = title
        self.description = description
        self.short_description = short_description
        self.names = None
        self.intended_effect = []
        self.status = None
        self.related_ttps = RelatedTTPs()
        self.related_incidents = RelatedIncidents()
        self.related_indicators = RelatedIndicators()
        self.attribution = []
        self.associated_campaigns = AssociatedCampaigns()
        self.confidence = None
        self.activity = []
        self.information_source = None
        self.handling = None
        self.related_packages = RelatedPackageRefs()

    @property
    def id_(self):
        return self._id
    
    @id_.setter
    def id_(self, value):
        if not value:
            self._id = None
        else:
            self._id = value
            self.idref = None
    
    @property
    def idref(self):
        return self._idref
    
    @idref.setter
    def idref(self, value):
        if not value:
            self._idref = None
        else:
            self._idref = value
            self.id_ = None # unset id_ if idref is present
    
    @property
    def timestamp(self):
        return self._timestamp

    @timestamp.setter
    def timestamp(self, value):
        self._timestamp = dates.parse_value(value)

    @property
    def title(self):
        return self._title

    @title.setter
    def title(self, value):
        self._title = value

    @property
    def description(self):
        return self._description

    @description.setter
    def description(self, value):
        if value:
            if isinstance(value, StructuredText):
                self._description = value
            else:
                self._description = StructuredText(value=value)
        else:
            self._description = None

    @property
    def short_description(self):
        return self._short_description

    @short_description.setter
    def short_description(self, value):
        if value:
            if isinstance(value, StructuredText):
                self._short_description = value
            else:
                self._short_description = StructuredText(value=value)
        else:
            self._short_description = None


    def to_obj(self, return_obj=None):
        if not return_obj:
            return_obj = self._binding_class()
#.........这里部分代码省略.........
开发者ID:mgoldsborough,项目名称:python-stix,代码行数:103,代码来源:__init__.py

示例7: ExploitTarget

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

#.........这里部分代码省略.........
    @property
    def configuration(self):
        """A list of :class:`.Configuration` objects. This behaves like
        a ``MutableSequence`` type.
        
        Default Value: ``None``

        Returns:
            A list of :class:`.Configuration` objects.

        Raises:
            ValueError: If set to a value that is not ``None`` and not an
                instance of :class:`.Configuration`.

        """
        
        return self._configuration
    
    @configuration.setter
    def configuration(self, value):
        self._configuration = _Configurations(value)

    def add_configuration(self, value):
        """Adds a configuration to the :attr:`configurations` list property.

        Note:
            If ``None`` is passed in no value is added 

        Args:
            value: A configuration value.
            
        Raises:
            ValueError: If the `value` param is of type :class:`.Configuration`

        """
        self.configuration.append(value)
 
    def to_obj(self, return_obj=None, ns_info=None):
        if not return_obj:
            return_obj = self._binding_class()

        super(ExploitTarget, self).to_obj(return_obj=return_obj, ns_info=ns_info)

        if self.potential_coas:
            return_obj.Potential_COAs = self.potential_coas.to_obj(ns_info=ns_info)
        if self.related_exploit_targets:
            return_obj.Related_Exploit_Targets = self.related_exploit_targets.to_obj(ns_info=ns_info)
        if self.vulnerabilities:
            return_obj.Vulnerability = self.vulnerabilities.to_obj(ns_info=ns_info)
        if self.weaknesses:
            return_obj.Weakness = self.weaknesses.to_obj(ns_info=ns_info)
        if self.configuration:
            return_obj.Configuration = self.configuration.to_obj(ns_info=ns_info)
        if self.related_packages:
            return_obj.Related_Packages = self.related_packages.to_obj(ns_info=ns_info)
            
        return return_obj

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

        if not return_obj:
            return_obj = cls()

        super(ExploitTarget, cls).from_obj(obj, return_obj=return_obj)

        if isinstance(obj, cls._binding_class):
            return_obj.potential_coas = PotentialCOAs.from_obj(obj.Potential_COAs)
            return_obj.related_exploit_targets = RelatedExploitTargets.from_obj(obj.Related_Exploit_Targets)
            return_obj.vulnerabilities = _Vulnerabilities.from_obj(obj.Vulnerability)
            return_obj.weaknesses = _Weaknesses.from_obj(obj.Weakness)
            return_obj.configuration = _Configurations.from_obj(obj.Configuration)
            return_obj.related_packages = RelatedPackageRefs.from_obj(obj.Related_Packages)

        return return_obj

    def to_dict(self):
        return super(ExploitTarget, self).to_dict()

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

        if not return_obj:
            return_obj = cls()

        super(ExploitTarget, cls).from_dict(dict_repr, return_obj=return_obj)

        get = dict_repr.get
        return_obj.potential_coas = PotentialCOAs.from_dict(get('potential_coas'))
        return_obj.related_exploit_targets = RelatedExploitTargets.from_dict(get('related_exploit_targets'))
        return_obj.vulnerabilities = _Vulnerabilities.from_dict(get('vulnerabilities'))
        return_obj.weaknesses = _Weaknesses.from_dict(get('weaknesses'))
        return_obj.configuration = _Configurations.from_dict(get('configuration'))
        return_obj.related_packages = RelatedPackageRefs.from_dict(get('related_packages'))
        
        return return_obj
开发者ID:thurday,项目名称:python-stix,代码行数:104,代码来源:__init__.py

示例8: Incident

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

#.........这里部分代码省略.........
        Calling this method is the same as calling ``append()`` on the
        ``related_observables`` property.

        See Also:
            The :class:`RelatedObservables` documentation.

        Note:
            If the `observable` parameter is not an instance of
            :class:`.RelatedObservable` an attempt will be
            made to convert it to one.

        Args:
            observable: An instance of :class:`Observable` or
                :class:`.RelatedObservable`.

        Raises:
            ValueError: If the `value` parameter cannot be converted into
                an instance of :class:`.RelatedObservable`

        """
        self.related_observables.append(value)

    @property
    def related_packages(self):
        return self._related_packages

    @related_packages.setter
    def related_packages(self, value):
        self._related_packages = RelatedPackageRefs(value)

    def add_related_package(self, value):
        self.related_packages.append(value)

    def to_obj(self, return_obj=None, ns_info=None):
        if not return_obj:
            return_obj = self._binding_class()

        super(Incident, self).to_obj(return_obj=return_obj, ns_info=ns_info)

        if self.time:
            return_obj.Time = self.time.to_obj(ns_info=ns_info)
        if self.victims:
            return_obj.Victim = self.victims.to_obj(ns_info=ns_info)
        if self.attributed_threat_actors:
            return_obj.Attributed_Threat_Actors = self.attributed_threat_actors.to_obj(ns_info=ns_info)
        if self.related_indicators:
            return_obj.Related_Indicators = self.related_indicators.to_obj(ns_info=ns_info)
        if self.related_observables:
            return_obj.Related_Observables = self.related_observables.to_obj(ns_info=ns_info)
        if self.related_incidents:
            return_obj.Related_Incidents = self.related_incidents.to_obj(ns_info=ns_info)
        if self.categories:
            return_obj.Categories = self.categories.to_obj(ns_info=ns_info)
        if self.intended_effects:
            return_obj.Intended_Effect = self.intended_effects.to_obj(ns_info=ns_info)
        if self.leveraged_ttps:
            return_obj.Leveraged_TTPs = self.leveraged_ttps.to_obj(ns_info=ns_info)
        if self.affected_assets:
            return_obj.Affected_Assets = self.affected_assets.to_obj(ns_info=ns_info)
        if self.discovery_methods:
            return_obj.Discovery_Method = self.discovery_methods.to_obj(ns_info=ns_info)
        if self.reporter:
            return_obj.Reporter = self.reporter.to_obj(ns_info=ns_info)
        if self.responders:
            return_obj.Responder = self.responders.to_obj(ns_info=ns_info)
        if self.coordinators:
开发者ID:nnh100,项目名称:python-stix,代码行数:70,代码来源:__init__.py

示例9: ExploitTarget

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

#.........这里部分代码省略.........
            self.add_weakness(value)
            
    def add_weakness(self, v):
        if not v:
            return
        elif isinstance(v, Weakness):
            self.weaknesses.append(v)
        else:
            raise ValueError('Cannot add type %s to weakness list' % type(v))
 
    @property
    def configuration(self):
        return self._configuration
    
    @configuration.setter
    def configuration(self, value):
        self._configuration = []
        if not value:
            return
        elif isinstance(value, list):
            for v in value:
                self.add_configuration(v)
        else:
            self.add_configuration(value)
            
    def add_configuration(self, v):
        if not v:
            return
        elif isinstance(v, Configuration):
            self.configuration.append(v)
        else:
            raise ValueError('Cannot add type %s to configuration list' % type(v))
 
    def to_obj(self, return_obj=None):
        if not return_obj:
            return_obj = self._binding_class()

        return_obj.set_id(self.id_)
        return_obj.set_idref(self.idref)
        return_obj.set_timestamp(dates.serialize_value(self.timestamp))
        return_obj.set_version(self.version)
        return_obj.set_Title(self.title)

        if self.description:
            return_obj.set_Description(self.description.to_obj())
        if self.short_description:
            return_obj.set_Short_Description(self.short_description.to_obj())
        if self.information_source:
            return_obj.set_Information_Source(self.information_source.to_obj())
        if self.handling:
            return_obj.set_Handling(self.handling.to_obj())
        if self.potential_coas:
            return_obj.set_Potential_COAs(self.potential_coas.to_obj())
        if self.related_exploit_targets:
            return_obj.set_Related_Exploit_Targets(self.related_exploit_targets.to_obj())
        if self.vulnerabilities:
            return_obj.set_Vulnerability([x.to_obj() for x in self.vulnerabilities])
        if self.weaknesses:
            return_obj.set_Weakness([x.to_obj() for x in self.weaknesses])
        if self.configuration:
            return_obj.set_Configuration([x.to_obj() for x in self.configuration])
        if self.related_packages:
            return_obj.set_Related_Packages(self.related_packages.to_obj())
            
        return return_obj
开发者ID:SYNchroACK,项目名称:crits_dependencies,代码行数:69,代码来源:__init__.py

示例10: Campaign

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

#.........这里部分代码省略.........
            intended_effect = IntendedEffect(value)
            self.intended_effects.append(Statement(value=intended_effect))

    @property
    def status(self):
        return self._status
    
    @status.setter
    def status(self, value):
        if not value:
            self._status = None
        elif isinstance(value, VocabString):
            self._status = value
        else:
            self._status = CampaignStatus(value)

    @property
    def attribution(self):
        return self._attribution

    @attribution.setter
    def attribution(self, value):
        self._attribution = AttributionList()
        if not value:
            return
        elif isinstance(value, AttributionList):
            self._attribution = value
        elif hasattr(value, '__getitem__'):
            self._attribution = AttributionList(*value)
        else:
            self._attribution.append(value) # may raise a ValueError


    def to_obj(self, return_obj=None, ns_info=None):
        super(Campaign, self).to_obj(return_obj=return_obj, ns_info=ns_info)

        if not return_obj:
            return_obj = self._binding_class()

        return_obj.id = self.id_
        return_obj.idref = self.idref
        if self.timestamp:
            return_obj.timestamp = self.timestamp.isoformat()
        return_obj.version = self.version
        return_obj.Title = self.title
        if self.description:
            return_obj.Description = self.description.to_obj(ns_info=ns_info)
        if self.short_description:
            return_obj.Short_Description = self.short_description.to_obj(ns_info=ns_info)
        if self.names:
            return_obj.Names = self.names.to_obj(ns_info=ns_info)
        if self.intended_effects:
            return_obj.Intended_Effect = [x.to_obj(ns_info=ns_info) for x in self.intended_effects]
        if self.status:
            return_obj.Status = self.status.to_obj(ns_info=ns_info)
        if self.related_ttps:
            return_obj.Related_TTPs = self.related_ttps.to_obj(ns_info=ns_info)
        if self.related_incidents:
            return_obj.Related_Incidents = self.related_incidents.to_obj(ns_info=ns_info)
        if self.related_indicators:
            return_obj.Related_Indicators = self.related_indicators.to_obj(ns_info=ns_info)
        if self.attribution:
            return_obj.Attribution = [x.to_obj(ns_info=ns_info) for x in self.attribution]
        if self.associated_campaigns:
            return_obj.Associated_Campaigns = self.associated_campaigns.to_obj(ns_info=ns_info)
        if self.confidence:
开发者ID:VerSprite,项目名称:python-stix,代码行数:70,代码来源:__init__.py

示例11: Indicator

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

#.........这里部分代码省略.........
            observable_composition.add(observable)

        root_observable = Observable()
        root_observable.observable_composition = observable_composition

        return root_observable

    def add_object(self, object_):
        """Adds a python-cybox Object instance to the ``observables`` list
        property.

        This is the same as calling ``indicator.add_observable(object_)``.

        Note:
            If the `object` param is not an instance of ``cybox.core.Object``
            an attempt will be made to to convert it into one before wrapping
            it in an ``cybox.core.Observable`` layer.

        Args:
            object_: An instance of ``cybox.core.Object`` or an object
                that can be converted into an instance of
                ``cybox.core.Observable``

        Raises:
            ValueError: if the `object_` param cannot be converted to an
                instance of ``cybox.core.Observable``.
        """
        if not object_:
            return

        observable = Observable(object_)
        self.add_observable(observable)

    def to_obj(self, return_obj=None, ns_info=None):
        if not return_obj:
            return_obj = self._binding_class()

        super(Indicator, self).to_obj(return_obj=return_obj, ns_info=ns_info)

        return_obj.negate = True if self.negate else None

        if self.confidence:
            return_obj.Confidence = self.confidence.to_obj(ns_info=ns_info)
        if self.indicator_types:
            return_obj.Type = self.indicator_types.to_obj(ns_info=ns_info)
        if self.indicated_ttps:
            return_obj.Indicated_TTP = self.indicated_ttps.to_obj(ns_info=ns_info)
        if self.producer:
            return_obj.Producer = self.producer.to_obj(ns_info=ns_info)
        if self.test_mechanisms:
            return_obj.Test_Mechanisms = self.test_mechanisms.to_obj(ns_info=ns_info)
        if self.likely_impact:
            return_obj.Likely_Impact = self.likely_impact.to_obj(ns_info=ns_info)
        if self.alternative_id:
            return_obj.Alternative_ID = self.alternative_id
        if self.valid_time_positions:
            return_obj.Valid_Time_Position = self.valid_time_positions.to_obj(ns_info=ns_info)
        if self.suggested_coas:
            return_obj.Suggested_COAs = self.suggested_coas.to_obj(ns_info=ns_info)
        if self.sightings:
            return_obj.Sightings = self.sightings.to_obj(ns_info=ns_info)
        if self.composite_indicator_expression:
            return_obj.Composite_Indicator_Expression = self.composite_indicator_expression.to_obj(ns_info=ns_info)
        if self.kill_chain_phases:
            return_obj.Kill_Chain_Phases = self.kill_chain_phases.to_obj(ns_info=ns_info)
        if self.related_indicators:
开发者ID:shinsec,项目名称:python-stix,代码行数:70,代码来源:indicator.py

示例12: ThreatActor

# 需要导入模块: from stix.common.related import RelatedPackageRefs [as 别名]
# 或者: from stix.common.related.RelatedPackageRefs import to_obj [as 别名]
class ThreatActor(stix.Entity):
    _binding = threat_actor_binding
    _binding_class = threat_actor_binding.ThreatActorType
    _namespace = 'http://stix.mitre.org/ThreatActor-1'
    _version = "1.1"

    def __init__(self, id_=None, idref=None, timestamp=None, title=None, description=None, short_description=None):
        self.id_ = id_ or stix.utils.create_id("threatactor")
        self.idref = idref
        self.timestamp = timestamp or datetime.now()
        self.version = self._version
        self.title = title
        self.description = description
        self.short_description = short_description
        self.identity = None
        self.type_ = []
        self.motivation = []
        self.sophistication = []
        self.intended_effect = []
        self.planning_and_operational_support = []
        self.handling = None
        self.confidence = None
        self.information_source = None
        self.observed_ttps = ObservedTTPs()
        self.associated_campaigns = AssociatedCampaigns()
        self.associated_actors = AssociatedActors()
        self.related_packages = RelatedPackageRefs()

    @property
    def id_(self):
        return self._id
    
    @id_.setter
    def id_(self, value):
        if not value:
            self._id = None
        else:
            self._id = value
            self.idref = None
    
    @property
    def idref(self):
        return self._idref
    
    @idref.setter
    def idref(self, value):
        if not value:
            self._idref = None
        else:
            self._idref = value
            self.id_ = None # unset id_ if idref is present
    
    @property
    def timestamp(self):
        return self._timestamp

    @timestamp.setter
    def timestamp(self, value):
        self._timestamp = dates.parse_value(value)

    @property
    def title(self):
        return self._title

    @title.setter
    def title(self, value):
        self._title = value

    @property
    def description(self):
        return self._description

    @description.setter
    def description(self, value):
        if value:
            if isinstance(value, StructuredText):
                self._description = value
            else:
                self._description = StructuredText(value=value)
        else:
            self._description = None

    @property
    def short_description(self):
        return self._short_description

    @short_description.setter
    def short_description(self, value):
        if value:
            if isinstance(value, StructuredText):
                self._short_description = value
            else:
                self._short_description = StructuredText(value=value)
        else:
            self._short_description = None


    def to_obj(self, return_obj=None):
        if not return_obj:
            return_obj = self._binding_class()
#.........这里部分代码省略.........
开发者ID:mgoldsborough,项目名称:python-stix,代码行数:103,代码来源:__init__.py

示例13: ThreatActor

# 需要导入模块: from stix.common.related import RelatedPackageRefs [as 别名]
# 或者: from stix.common.related.RelatedPackageRefs import to_obj [as 别名]
class ThreatActor(stix.BaseCoreComponent):
    _binding = threat_actor_binding
    _binding_class = threat_actor_binding.ThreatActorType
    _namespace = 'http://stix.mitre.org/ThreatActor-1'
    _version = "1.1.1"
    _ALL_VERSIONS = ("1.0", "1.0.1", "1.1", "1.1.1")
    _ID_PREFIX = 'threatactor'

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

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

        self.identity = None
        self.types = None
        self.motivations = None
        self.sophistications = None
        self.intended_effects = None
        self.planning_and_operational_supports = None
        self.handling = None
        self.confidence = None
        self.observed_ttps = ObservedTTPs()
        self.associated_campaigns = AssociatedCampaigns()
        self.associated_actors = AssociatedActors()
        self.related_packages = RelatedPackageRefs()

    @property
    def identity(self):
        return self._identity
    
    @identity.setter
    def identity(self, value):
        self._set_var(Identity, try_cast=False, identity=value)

    @property
    def types(self):
        return self._types
    
    @types.setter
    def types(self, value):
        self._types = _Types(value)
            
    def add_type(self, value):
        self.types.append(value)

    @property
    def motivations(self):
        return self._motivations
    
    @motivations.setter
    def motivations(self, value):
        self._motivations = _Motivations(value)
            
    def add_motivation(self, value):
        self.motivations.append(value)

    @property
    def sophistications(self):
        return self._sophistications
    
    @sophistications.setter
    def sophistications(self, value):
        self._sophistications = _Sophistications(value)
            
    def add_sophistication(self, value):
        self._sophistications.append(value)

    @property
    def intended_effects(self):
        return self._intended_effects
    
    @intended_effects.setter
    def intended_effects(self, value):
        self._intended_effects = _IntendedEffects(value)
            
    def add_intended_effect(self, value):
        self.intended_effects.append(value)

    @property
    def planning_and_operational_supports(self):
        return self._planning_and_operational_supports
    
    @planning_and_operational_supports.setter
    def planning_and_operational_supports(self, value):
        self._planning_and_operational_supports = _PlanningAndOperationalSupports(value)
            
    def add_planning_and_operational_support(self, value):
        self.planning_and_operational_supports.append(value)

    def to_obj(self, return_obj=None, ns_info=None):
        if not return_obj:
            return_obj = self._binding_class()

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

示例14: Campaign

# 需要导入模块: from stix.common.related import RelatedPackageRefs [as 别名]
# 或者: from stix.common.related.RelatedPackageRefs import to_obj [as 别名]
class Campaign(stix.BaseCoreComponent):
    _binding = campaign_binding
    _binding_class = _binding.CampaignType
    _namespace = "http://stix.mitre.org/Campaign-1"
    _version = "1.1.1"
    _ALL_VERSIONS = ("1.0", "1.0.1", "1.1", "1.1.1")
    _ID_PREFIX = 'campaign'

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

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

        self.names = None
        self.intended_effects = _IntendedEffects()
        self.status = None
        self.related_ttps = RelatedTTPs()
        self.related_incidents = RelatedIncidents()
        self.related_indicators = RelatedIndicators()
        self.attribution = _AttributionList()
        self.associated_campaigns = AssociatedCampaigns()
        self.confidence = None
        self.activity = _Activities()
        self.handling = None
        self.related_packages = RelatedPackageRefs()

    @property
    def intended_effects(self):
        return self._intended_effects

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

    def add_intended_effect(self, value):
        self.intended_effects.append(value)

    @property
    def activity(self):
        return self._activity

    @activity.setter
    def activity(self, value):
        self._activity = _Activities(value)

    def add_activity(self, value):
        self.activity.append(value)

    @property
    def status(self):
        return self._status

    @status.setter
    def status(self, value):
        self._set_vocab(vocabs.CampaignStatus, status=value)

    @property
    def attribution(self):
        return self._attribution

    @attribution.setter
    def attribution(self, value):
        self._attribution = _AttributionList(value)

    def to_obj(self, return_obj=None, ns_info=None):
        if not return_obj:
            return_obj = self._binding_class()

        super(Campaign, self).to_obj(return_obj=return_obj, ns_info=ns_info)

        if self.names:
            return_obj.Names = self.names.to_obj(ns_info=ns_info)
        if self.intended_effects:
            return_obj.Intended_Effect = self.intended_effects.to_obj(ns_info=ns_info)
        if self.status:
            return_obj.Status = self.status.to_obj(ns_info=ns_info)
        if self.related_ttps:
            return_obj.Related_TTPs = self.related_ttps.to_obj(ns_info=ns_info)
        if self.related_incidents:
            return_obj.Related_Incidents = self.related_incidents.to_obj(ns_info=ns_info)
        if self.related_indicators:
            return_obj.Related_Indicators = self.related_indicators.to_obj(ns_info=ns_info)
        if self.attribution:
            return_obj.Attribution = self.attribution.to_obj(ns_info=ns_info)
        if self.associated_campaigns:
            return_obj.Associated_Campaigns = self.associated_campaigns.to_obj(ns_info=ns_info)
        if self.confidence:
            return_obj.Confidence = self.confidence.to_obj(ns_info=ns_info)
        if self.activity:
            return_obj.Activity = self.activity.to_obj(ns_info=ns_info)
        if self.handling:
            return_obj.Handling = self.handling.to_obj(ns_info=ns_info)
        if self.related_packages:
#.........这里部分代码省略.........
开发者ID:andybarilla,项目名称:python-stix,代码行数:103,代码来源:__init__.py


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