本文整理汇总了Python中stix.common.StructuredTextList.add方法的典型用法代码示例。如果您正苦于以下问题:Python StructuredTextList.add方法的具体用法?Python StructuredTextList.add怎么用?Python StructuredTextList.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stix.common.StructuredTextList
的用法示例。
在下文中一共展示了StructuredTextList.add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Sighting
# 需要导入模块: from stix.common import StructuredTextList [as 别名]
# 或者: from stix.common.StructuredTextList import add [as 别名]
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)
示例2: GenericTestMechanism
# 需要导入模块: from stix.common import StructuredTextList [as 别名]
# 或者: from stix.common.StructuredTextList import add [as 别名]
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)
示例3: MalwareInstance
# 需要导入模块: from stix.common import StructuredTextList [as 别名]
# 或者: from stix.common.StructuredTextList import add [as 别名]
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)
def to_dict(self):
d = super(MalwareInstance, self).to_dict()
if self._XSI_TYPE:
d["xsi:type"] = self._XSI_TYPE
return d
示例4: Exploit
# 需要导入模块: from stix.common import StructuredTextList [as 别名]
# 或者: from stix.common.StructuredTextList import add [as 别名]
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)
示例5: STIXHeader
# 需要导入模块: from stix.common import StructuredTextList [as 别名]
# 或者: from stix.common.StructuredTextList import add [as 别名]
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):
#.........这里部分代码省略.........
示例6: Configuration
# 需要导入模块: from stix.common import StructuredTextList [as 别名]
# 或者: from stix.common.StructuredTextList import add [as 别名]
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)
示例7: Infrastructure
# 需要导入模块: from stix.common import StructuredTextList [as 别名]
# 或者: from stix.common.StructuredTextList import add [as 别名]
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_)