class Confidence(stix.Entity): _namespace = 'http://stix.mitre.org/common-1' _binding = common_binding _binding_class = common_binding.ConfidenceType value = VocabField("Value") descriptions = fields.TypedField("Description", StructuredTextList) timestamp = fields.DateTimeField("timestamp") timestamp_precision = fields.TypedField("timestamp_precision", preset_hook=validate_precision) source = fields.TypedField("Source", type_="stix.common.InformationSource") def __init__(self, value=None, timestamp=None, description=None, source=None): super(Confidence, self).__init__() self.timestamp = timestamp or utils.dates.now() self.timestamp_precision = "second" self.value = value self.description = StructuredTextList(description) self.source = source # TODO: support confidence_assertion_chain # self.confidence_assertion_chain = 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): from stix.common.structured_text import StructuredTextList if value is None: self.descriptions = StructuredTextList() else: 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)
def __init__(self, description=None, identity=None, time=None, tools=None, contributing_sources=None, references=None): super(InformationSource, self).__init__() self.identity = identity self.descriptions = StructuredTextList(description) self.contributing_sources = contributing_sources self.time = time self.tools = tools self.references = references
def __init__(self, value=None, timestamp=None, description=None, source=None): super(Confidence, self).__init__() self.timestamp = timestamp or utils.dates.now() self.timestamp_precision = "second" self.value = value self.description = StructuredTextList(description) self.source = source
def description(self, value): from stix.common.structured_text import StructuredTextList if value is None: self.descriptions = StructuredTextList() else: self.descriptions = StructuredTextList(value)
class InformationSource(stix.Entity): _binding = stix_common_binding _binding_class = stix_common_binding.InformationSourceType _namespace = 'http://stix.mitre.org/common-1' identity = fields.TypedField("Identity", type_=Identity, factory=IdentityFactory) descriptions = fields.TypedField("Description", StructuredTextList) contributing_sources = fields.TypedField( "Contributing_Sources", type_="stix.common.information_source.ContributingSources") time = fields.TypedField("Time", cybox.common.Time) roles = VocabField("Role", multiple=True, key_name="roles") tools = fields.TypedField("Tools", ToolInformationList) references = fields.TypedField("References", References) def __init__(self, description=None, identity=None, time=None, tools=None, contributing_sources=None, references=None): super(InformationSource, self).__init__() self.identity = identity self.descriptions = StructuredTextList(description) self.contributing_sources = contributing_sources self.time = time self.tools = tools self.references = references #self.roles = None def add_contributing_source(self, value): self.contributing_sources.append(value) def add_reference(self, value): if not value: return # TODO: Check if it's a valid URI? self.references.append(value) @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): from stix.common.structured_text import StructuredTextList 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) def add_role(self, value): self.roles.append(value)
class Campaign(stix.BaseCoreComponent): """Implementation of the STIX Campaign. 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 = campaign_binding _binding_class = _binding.CampaignType _namespace = "http://stix.mitre.org/Campaign-1" _version = "1.2" _ALL_VERSIONS = ("1.0", "1.0.1", "1.1", "1.1.1", "1.2") _ID_PREFIX = 'campaign' descriptions = fields.TypedField("Description", StructuredTextList) activity = fields.TypedField("Activity", Activity, multiple=True) associated_campaigns = fields.TypedField("Associated_Campaigns", AssociatedCampaigns) attribution = fields.TypedField("Attribution", Attribution, multiple=True) confidence = fields.TypedField("Confidence", Confidence) # references = fields.TypedField("Reference", multiple=True) status = VocabField("Status", CampaignStatus) intended_effects = StatementField("Intended_Effect", Statement, vocab_type=vocabs.IntendedEffect, multiple=True, key_name="intended_effects") names = fields.TypedField("Names", Names) related_incidents = fields.TypedField("Related_Incidents", RelatedIncidents) related_indicators = fields.TypedField("Related_Indicators", RelatedIndicators) related_packages = fields.TypedField("Related_Packages", RelatedPackageRefs) related_ttps = fields.TypedField("Related_TTPs", RelatedTTPs) information_source = fields.TypedField("Information_Source", InformationSource) 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.related_ttps = RelatedTTPs() self.related_incidents = RelatedIncidents() self.related_indicators = RelatedIndicators() self.related_packages = RelatedPackageRefs() def add_intended_effect(self, value): self.intended_effects.append(value) def add_activity(self, value): """Adds an :class:`.Activity` object to the :attr:`activity` collection. """ self.activity.append(value) @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)". """ self.descriptions.add(description)
def description(self, value): self.descriptions = StructuredTextList(value)
def description(self, value): from stix.common.structured_text import StructuredTextList self.descriptions = StructuredTextList(value)
class InformationSource(stix.Entity): _binding = stix_common_binding _binding_class = stix_common_binding.InformationSourceType _namespace = 'http://stix.mitre.org/common-1' identity = fields.TypedField("Identity", type_=Identity, factory=IdentityFactory) descriptions = fields.TypedField("Description", StructuredTextList) contributing_sources = fields.TypedField("Contributing_Sources", type_="stix.common.information_source.ContributingSources") time = fields.TypedField("Time", cybox.common.Time) roles = VocabField("Role", multiple=True, key_name="roles") tools = fields.TypedField("Tools", ToolInformationList) references = fields.TypedField("References", References) def __init__(self, description=None, identity=None, time=None, tools=None, contributing_sources=None, references=None): super(InformationSource, self).__init__() self.identity = identity self.descriptions = StructuredTextList(description) self.contributing_sources = contributing_sources self.time = time self.tools = tools self.references = references #self.roles = None def add_contributing_source(self, value): self.contributing_sources.append(value) def add_reference(self, value): if not value: return # TODO: Check if it's a valid URI? self.references.append(value) @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): from stix.common.structured_text import StructuredTextList 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) def add_role(self, value): self.roles.append(value)