Classes for representing properties of STIX Objects and Cyber Observables.

class BinaryProperty(required=False, fixed=None, default=None)
class BooleanProperty(required=False, fixed=None, default=None)
class DictionaryProperty(spec_version='2.0', **kwargs)
class EmbeddedObjectProperty(type, **kwargs)
class EnumProperty(allowed, **kwargs)
class ExtensionsProperty(spec_version='2.0', allow_custom=False, enclosing_type=None, required=False)

Property for representing extensions on Observable objects.

class FloatProperty(min=None, max=None, **kwargs)
class HashesProperty(spec_version='2.0', **kwargs)
class HexProperty(required=False, fixed=None, default=None)
class IDProperty(type, spec_version='2.0')
class IntegerProperty(min=None, max=None, **kwargs)
class ListProperty(contained, **kwargs)
class ObjectReferenceProperty(valid_types=None, **kwargs)
class ObservableProperty(spec_version='2.0', allow_custom=False, *args, **kwargs)

Property for holding Cyber Observable Objects.

class PatternProperty(**kwargs)
class Property(required=False, fixed=None, default=None)

Represent a property of STIX data type.

Subclasses can define the following attributes as keyword arguments to __init__().

  • required (bool) – If True, the property must be provided when creating an object with that property. No default value exists for these properties. (Default: False)
  • fixed

    This provides a constant default value. Users are free to provide this value explicity when constructing an object (which allows you to copy all values from an existing object to a new object), but if the user provides a value other than the fixed value, it will raise an error. This is semantically equivalent to defining both:

    • a clean() function that checks if the value matches the fixed value, and
    • a default() function that returns the fixed value.

Subclasses can also define the following functions:

  • def clean(self, value) -> any:
    • Return a value that is valid for this property. If value is not valid for this property, this will attempt to transform it first. If value is not valid and no such transformation is possible, it should raise an exception.
  • def default(self):
    • provide a default value for this property.
    • default() can return the special value NOW to use the current
      time. This is useful when several timestamps in the same object need to use the same default value, so calling now() for each property– likely several microseconds apart– does not work.

Subclasses can instead provide a lambda function for default as a keyword argument. clean should not be provided as a lambda since lambdas cannot raise their own exceptions.

When instantiating Properties, required and default should not be used together. default implies that the property is required in the specification so this function will be used to supply a value if none is provided. required means that the user must provide this; it is required in the specification and we can’t or don’t want to create a default value.

class ReferenceProperty(valid_types=None, invalid_types=None, spec_version='2.0', **kwargs)
class STIXObjectProperty(spec_version='2.0', allow_custom=False, *args, **kwargs)
class SelectorProperty(required=False, fixed=None, default=None)
class StringProperty(**kwargs)
class TimestampProperty(precision='any', precision_constraint='exact', **kwargs)
class TypeProperty(type, spec_version='2.0')
enumerate_types(types, spec_version)
types is meant to be a list; it may contain specific object types and/or
the any of the words “SCO”, “SDO”, or “SRO”
Since “SCO”, “SDO”, and “SRO” are general types that encompass various specific object types,
once each of those words is being processed, that word will be removed from return_types, so as not to mistakenly allow objects to be created of types “SCO”, “SDO”, or “SRO”