object_markings

Functions for working with STIX 2.0 object markings.

add_markings(obj, marking)

Append an object level marking to the object_marking_refs collection.

Parameters:
  • obj – A SDO or SRO object.
  • marking – identifier or list of identifiers to apply SDO or SRO object.
Returns:

A new version of the given SDO or SRO with specified markings added.

clear_markings(obj)

Remove all object level markings from the object_marking_refs collection.

Parameters:obj – A SDO or SRO object.
Returns:A new version of the given SDO or SRO with object_marking_refs cleared.
get_markings(obj)

Get all object level markings from the given SDO or SRO object.

Parameters:obj – A SDO or SRO object.
Returns:list
Marking identifiers contained in the SDO or SRO. Empty list if no
markings are present in object_marking_refs.
is_marked(obj, marking=None)

Check if SDO or SRO is marked by any marking or by specific marking(s).

Parameters:
  • obj – A SDO or SRO object.
  • marking – identifier or list of marking identifiers that apply to the SDO or SRO object.
Returns:

bool – True if SDO or SRO has object level markings. False otherwise.

Note

When an identifier or list of identifiers is provided, if ANY of the provided marking refs match, True is returned.

remove_markings(obj, marking)

Remove an object level marking from the object_marking_refs collection.

Parameters:
  • obj – A SDO or SRO object.
  • marking – identifier or list of identifiers that apply to the SDO or SRO object.
Raises:

MarkingNotFoundError – If markings to remove are not found on the provided SDO or SRO.

Returns:

A new version of the given SDO or SRO with specified markings removed.

set_markings(obj, marking)

Remove all object level markings and append new object level markings to the collection. Refer to clear_markings and add_markings for details.

Parameters:
  • obj – A SDO or SRO object.
  • marking – identifier or list of identifiers to apply in the SDO or SRO object.
Returns:

A new version of the given SDO or SRO with specified markings removed and new ones added.