Version: 1.2.0.11
stix.indicator.indicator Module¶
Overview¶
The stix.indicator.indicator module implements IndicatorType STIX
Language construct. The IndicatorType characterizes a cyber threat indicator
made up of a pattern identifying certain observable conditions as well as
contextual information about the patterns meaning, how and when it should be
acted on, etc.
Documentation Resources¶
Classes¶
-
class
stix.indicator.indicator.Indicator(id_=None, idref=None, timestamp=None, title=None, description=None, short_description=None)¶ Bases:
stix.base.BaseCoreComponentImplementation of the STIX Indicator.
Parameters: - id (optional) – An identifier. If
None, a value will be generated viamixbox.idgen.create_id(). If set, this will unset theidrefproperty. - 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.datetimeorstr. - description (optional) – A string description.
- short_description (optional) – A string short description.
-
add_alternative_id(value)¶ Adds an alternative id to the
alternative_idlist property.Note
If
Noneis passed in no value is added to thealternative_idlist property.Parameters: value – An identifier value.
-
add_description(description)¶ Adds a description to the
descriptionscollection.This is the same as calling “foo.descriptions.add(bar)”.
-
add_indicated_ttp(v)¶ Adds an Indicated TTP to the
indicated_ttpslist property of thisIndicator.The v parameter must be an instance of
stix.common.related.RelatedTTPorstix.ttp.TTP.If the v parameter is
None, no item wil be added to theindicated_ttpslist property.Note
If the v parameter is not an instance of
stix.common.related.RelatedTTPan attempt will be made to convert it to one.Parameters: v – An instance of stix.common.related.RelatedTTPorstix.ttp.TTP.Raises: ValueError– If the v parameter cannot be converted into an instance ofstix.common.related.RelatedTTP
-
add_indicator_type(value)¶ Adds a value to the
indicator_typeslist property.The value parameter can be a
stror an instance ofstix.common.vocabs.VocabString.Note
If the value parameter is a
strinstance, an attempt will be made to convert it into an instance ofstix.common.vocabs.IndicatorTypeParameters: value – An instance of stix.common.vocabs.VocabStringorstr.Raises: ValueError– If the value param is astrinstance that cannot be converted into an instance ofstix.common.vocabs.IndicatorType.
-
add_kill_chain_phase(value)¶ Add a new Kill Chain Phase reference to this Indicator.
Parameters: value – a stix.common.kill_chains.KillChainPhaseor a str representing the phase_id of. Note that you if you are defining a custom Kill Chain, you need to add it to the STIX package separately.
-
add_object(object_)¶ Adds a python-cybox Object instance to the
observableslist property.This is the same as calling
indicator.add_observable(object_).Note
If the object param is not an instance of
cybox.core.Objectan attempt will be made to to convert it into one before wrapping it in ancybox.core.Observablelayer.Parameters: object – An instance of cybox.core.Objector an object that can be converted into an instance ofcybox.core.ObservableRaises: ValueError– if the object_ param cannot be converted to an instance ofcybox.core.Observable.
-
add_observable(observable)¶ Adds an observable to the
observableproperty of theIndicator.If the observable parameter is
None, no item will be added to theobservableproperty.Note
The STIX Language dictates that an
Indicatorcan have only oneObservableunder it. Because of this, when a user adds anotherObservablea new, emptyObservablewill be crated and append the existing and newobservableusing theObservableCompositionproperty. To access the top levelObservablecan be achieved by theobservableproperty .By default, theoperatorof the composition layer will be set to"OR". Theoperatorvalue can be changed via theobservable_composition_operatorproperty.Setting
observableorobservableswith re-initialize the property and lose allObservablein the composition layer.Parameters: observable – An instance of cybox.core.Observableor an object type that can be converted into one.Raises: ValueError– If the observable param cannot be converted into an instance ofcybox.core.Observable.
Adds a Related Campaign to this Indicator.
The value parameter must be an instance of
RelatedCampaignReforCampaignRef.If the value parameter is
None, no item wil be added to therelated_campaignscollection.Calling this method is the same as calling
append()on therelated_campaignsproperty.See also
The
RelatedCampaignRefdocumentation.Note
If the value parameter is not an instance of
RelatedCampaignRefan attempt will be made to convert it to one.Parameters: value – An instance of RelatedCampaignReforCampaign.Raises: ValueError– If the value parameter cannot be converted into an instance ofRelatedCampaignRef
Adds an Related Indicator to the
related_indicatorslist property of thisIndicator.The indicator parameter must be an instance of
stix.common.related.RelatedIndicatororIndicator.If the indicator parameter is
None, no item wil be added to therelated_indicatorslist property.Calling this method is the same as calling
append()on therelated_indicatorsproeprty.See also
The
RelatedIndicatorsdocumentation.Note
If the tm parameter is not an instance of
stix.common.related.RelatedIndicatoran attempt will be made to convert it to one.Parameters: indicator – An instance of Indicatororstix.common.related.RelatedIndicator.Raises: ValueError– If the indicator parameter cannot be converted into an instance ofstix.common.related.RelatedIndicator
-
add_short_description(description)¶ Adds a description to the
short_descriptionscollection.This is the same as calling “foo.short_descriptions.add(bar)”.
-
add_test_mechanism(tm)¶ Adds an Test Mechanism to the
test_mechanismslist property of thisIndicator.The tm parameter must be an instance of a
stix.indicator.test_mechanism._BaseTestMechanismimplementation.If the tm parameter is
None, no item will be added to thetest_mechanismslist property.See also
Test Mechanism implementations are found under the
stix.extensions.test_mechanismpackage.Parameters: tm – An instance of a stix.indicator.test_mechanism._BaseTestMechanismimplementation.Raises: ValueError– If the tm parameter is not an instance ofstix.indicator.test_mechanism._BaseTestMechanism
-
add_valid_time_position(value)¶ Adds an valid time position to the
valid_time_positionsproperty list.If value is
None, no item is added to thevalue_time_positionslist.Parameters: value – An instance of stix.indicator.valid_time.ValidTime.Raises: ValueError– If the value argument is not an instance ofstix.indicator.valid_time.ValidTime.
-
description¶ A single description about the contents or purpose of this object.
Default Value:
NoneNote
If this object has more than one description set, this will return the description with the lowest ordinality value.
Returns: An instance of StructuredText
-
find(id_)¶ Searches the children of a
Entityimplementation for an object with anid_property that matches id_.
-
get_produced_time()¶ Gets the produced time for this
Indicator.This is the same as calling
produced_time = indicator.producer.time.produced_time.Returns: Noneor an instance ofcybox.common.DateTimeWithPrecision.
-
get_received_time()¶ Gets the received time for this
Indicator.This is the same as calling
received_time = indicator.producer.time.received_time.Returns: Noneor an instance ofcybox.common.DateTimeWithPrecision.
-
observables¶ A list of
cybox.core.Observableinstances. 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
observableproperty.If multiple
cybox.core.Observablethis property will return Observables under thecybox.core.ObservableComposition.Access to the top level
cybox.core.Observableis made viaobservableproperty.- Default Value:
- Empty
list.
Returns: A listofcybox.core.Observableinstances.
-
set_produced_time(produced_time)¶ Sets the
produced_timeproperty of theproducerproperty instance fo produced_time.This is the same as calling
indicator.producer.time.produced_time = produced_time.The produced_time parameter must be an instance of
str,datetime.datetime, orcybox.common.DateTimeWithPrecision.Note
If produced_time is a
strordatetime.datetimeinstance an attempt will be made to convert it into an instance ofcybox.common.DateTimeWithPrecision.Parameters: produced_time – An instance of str,datetime.datetime, orcybox.common.DateTimeWithPrecision.
-
set_producer_identity(identity)¶ Sets the name of the producer of this indicator.
This is the same as calling
indicator.producer.identity.name = identity.If the
producerproperty isNone, it will be initialized to an instance ofstix.common.information_source.InformationSource.If the
identityproperty of theproducerinstance isNone, it will be initialized to an instance ofstix.common.identity.Identity.Note
if the identity parameter is not an instance
stix.common.identity.Identityan attempt will be made to convert it to one.Parameters: identity – An instance of strorstix.common.identity.Identity.
-
set_received_time(received_time)¶ Sets the received time for this
Indicator.This is the same as calling
indicator.producer.time.produced_time = produced_time.The received_time parameter must be an instance of
str,datetime.datetime, orcybox.common.DateTimeWithPrecision.Parameters: received_time – An instance of str,datetime.datetime, orcybox.common.DateTimeWithPrecision.Note
If received_time is a
strordatetime.datetimeinstance an attempt will be made to convert it into an instance ofcybox.common.DateTimeWithPrecision.
-
short_description¶ A single short description about the contents or purpose of this object.
Default Value:
NoneNote
If this object has more than one short description set, this will return the description with the lowest ordinality value.
Returns: An instance of StructuredText
-
to_dict()¶ Convert to a
dictSubclasses can override this function.
Returns: Python dict with keys set from this Entity.
-
to_json()¶ Export an object as a JSON String.
-
to_obj(ns_info=None)¶ Convert to a GenerateDS binding object.
Subclasses can override this function.
Returns: An instance of this Entity’s _binding_classwith properties set from this Entity.
- id (optional) – An identifier. If
-
class
stix.indicator.indicator.CompositeIndicatorExpression(operator='OR', *args)¶ Bases:
mixbox.entities.EntityListImplementation of the STIX
CompositeIndicatorExpressionType.The
CompositeIndicatorExpressionclass implements methods found oncollections.MutableSequenceand as such can be interacted with as alist(e.g.,append()).Note
The
append()method can only accept instances ofIndicator.Examples
Add a
Indicatorinstance to an instance ofCompositeIndicatorExpression:>>> i = Indicator() >>> comp = CompositeIndicatorExpression() >>> comp.append(i)
Create a
CompositeIndicatorExpressionfrom a list ofIndicatorinstances using*argsargument list:>>> list_indicators = [Indicator() for i in xrange(10)] >>> comp = CompositeIndicatorExpression(CompositeIndicatorExpression.OP_OR, *list_indicators) >>> len(comp) 10
Parameters: - operator (str, optional) – The logical composition operator. Must be
"AND"or"OR". - *args – Variable length argument list of
Indicatorinstances.
-
OP_AND¶ str
String
"AND"
-
OP_OR¶ str
String
"OR"
-
OPERATORS¶ tuple
Tuple of allowed
operatorvalues.
-
operator¶ str
The logical composition operator. Must be
"AND"or"OR".
-
to_obj(ns_info=None)¶ Convert to a GenerateDS binding object.
Subclasses can override this function.
Returns: An instance of this Entity’s _binding_classwith properties set from this Entity.
- operator (str, optional) – The logical composition operator. Must be
-
class
stix.indicator.indicator.RelatedIndicators(related_indicators=None, scope=None)¶ Bases:
stix.common.related.GenericRelationshipListThe
RelatedIndicatorsclass provides functionality for addingstix.common.related.RelatedIndicatorinstances to anIndicatorinstance.The
RelatedIndicatorsclass implements methods found oncollections.MutableSequenceand as such can be interacted with as alist(e.g.,append()).The
append()method can accept instances ofstix.common.related.RelatedIndicatororIndicatoras an argument.Note
Calling
append()with an instance ofstix.coa.CourseOfActionwill wrap that instance in astix.common.related.RelatedIndicatorlayer, withitemset to theIndicatorinstance.Examples
Append an instance of
Indicatorto theIndicator.related_indicatorsproperty. The instance ofIndicatorwill be wrapped in an instance ofstix.common.related.RelatedIndicator:>>> related = Indicator() >>> parent_indicator = Indicator() >>> parent_indicator.related_indicators.append(related) >>> print(type(indicator.related_indicators[0])) <class 'stix.common.related.RelatedIndicator'>
Iterate over the
related_indicatorsproperty of anIndicatorinstance and print the ids of each underlyingIndicator`instance:>>> for related in indicator.related_indicators: >>> print(related.item.id_)
Parameters: - related_indicators (list, optional) – A list of
Indicatororstix.common.related.RelatedIndicatorinstances. - scope (str, optional) – The scope of the items. Can be set to
"inclusive"or"exclusive". Seestix.common.related.GenericRelationshipListdocumentation for more information.
-
scope¶ str
The scope of the items. Can be set to
"inclusive"or"exclusive". Seestix.common.related.GenericRelationshipListdocumentation for more information.
-
to_obj(ns_info=None)¶ Convert to a GenerateDS binding object.
Subclasses can override this function.
Returns: An instance of this Entity’s _binding_classwith properties set from this Entity.
- related_indicators (list, optional) – A list of
-
class
stix.indicator.indicator.RelatedCampaignRefs(related_campaign_refs=None, scope=None)¶ Bases:
stix.common.related.GenericRelationshipList-
to_obj(ns_info=None)¶ Convert to a GenerateDS binding object.
Subclasses can override this function.
Returns: An instance of this Entity’s _binding_classwith properties set from this Entity.
-
-
class
stix.indicator.indicator.SuggestedCOAs(suggested_coas=None, scope=None)¶ Bases:
stix.common.related.GenericRelationshipListThe
SuggestedCOAsclass provides functionality for addingstix.common.related.RelatedCOAinstances to anIndicatorinstance.The
SuggestedCOAsclass implements methods found oncollections.MutableSequenceand as such can be interacted with as alist(e.g.,append()).The
append()method can accept instances ofstix.common.related.RelatedCOAorstix.coa.CourseOfActionas an argument.Note
Calling
append()with an instance ofstix.coa.CourseOfActionwill wrap that instance in astix.common.related.RelatedCOAlayer, with theitemset to thestix.coa.CourseOfActioninstance.Examples
Append an instance of
stix.coa.CourseOfActionto theIndicator.suggested_coasproperty. The instance ofstix.coa.CourseOfActionwill be wrapped in an instance ofstix.common.related.RelatedCOA.>>> coa = CourseOfAction() >>> indicator = Indicator() >>> indicator.suggested_coas.append(coa) >>> print(type(indicator.suggested_coas[0])) <class 'stix.common.related.RelatedCOA'>
Iterate over the
suggested_coasproperty of anIndicatorinstance and print the ids of each underlyingstix.coa.CourseOfActioninstance.>>> for related_coa in indicator.suggested_coas: >>> print(related_coa.item.id_)
Parameters: - suggested_coas (list) – A list of
stix.coa.CourseOfActionorstix.common.related.RelatedCOAinstances. - scope (str) – The scope of the items. Can be set to
"inclusive"or"exclusive". Seestix.common.related.GenericRelationshipListdocumentation for more information.
-
scope¶ str
The scope of the items. Can be set to
"inclusive"or"exclusive". Seestix.common.related.GenericRelationshipListdocumentation for more information.
-
to_obj(ns_info=None)¶ Convert to a GenerateDS binding object.
Subclasses can override this function.
Returns: An instance of this Entity’s _binding_classwith properties set from this Entity.
- suggested_coas (list) – A list of
-
class
stix.indicator.indicator.IndicatorTypes(*args)¶ Bases:
stix.base.TypedListA
stix.common.vocabs.VocabStringcollection which defaults tostix.common.vocabs.IndicatorType. This class implements methods found oncollections.MutableSequenceand as such can be interacted with like alist.Note
The
append()method can acceptstrorstix.common.vocabs.VocabStringinstances. If astrinstance is passed in, an attempt will be made to convert it to an instance ofstix.common.vocabs.IndicatorType.Examples
Add an instance of
stix.common.vocabs.IndicatorType:>>> from stix.common.vocabs import IndicatorType >>> itypes = IndicatorTypes() >>> type_ = IndicatorType(IndicatorType.TERM_IP_WATCHLIST) >>> itypes.append(type_) >>> print(len(itypes)) 1
Add a string value:
>>> from stix.common.vocabs import IndicatorType >>> itypes = IndicatorTypes() >>> type(IndicatorType.TERM_IP_WATCHLIST) <type 'str'> >>> itypes.append(IndicatorType.TERM_IP_WATCHLIST) >>> print(len(itypes)) 1
Parameters: *args – Variable length argument list of strings or stix.common.vocabs.VocabStringinstances.