properties

Classes for representing properties of STIX Objects and Cyber Observables.

class BinaryProperty(required=False, fixed=None, default=None)
clean(value)
class BooleanProperty(required=False, fixed=None, default=None)
clean(value)
class CallableValues(parent_instance, *args, **kwargs)

Wrapper to allow values() method on WindowsRegistryKey objects. Needed because values is also a property.

class DictionaryProperty(spec_version='2.0', **kwargs)
clean(value)
class EmbeddedObjectProperty(type, **kwargs)
clean(value)
class EnumProperty(allowed, **kwargs)
clean(value)
class ExtensionsProperty(spec_version='2.0', allow_custom=False, enclosing_type=None, required=False)

Property for representing extensions on Observable objects.

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

Property for holding Cyber Observable Objects.

clean(value)
class PatternProperty(**kwargs)
clean(value)
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__().

Parameters:
  • 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 a ValueError.
  • 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.

clean(value)
class ReferenceProperty(type=None, **kwargs)
clean(value)
class STIXObjectProperty(spec_version='2.0', allow_custom=False, *args, **kwargs)
clean(value)
class SelectorProperty(required=False, fixed=None, default=None)
clean(value)
class StringProperty(**kwargs)
clean(value)
class TimestampProperty(precision=None, **kwargs)
clean(value)
class TypeProperty(type)