properties¶
Classes for representing properties of STIX Objects and Cyber Observables.
-
class
EnumProperty
(allowed, **kwargs)¶ Used for enumeration type properties. Properties of this type do not allow customization.
-
clean
(value, allow_custom)¶
-
-
class
ExtensionsProperty
(spec_version='2.1', required=False)¶ Property for representing extensions on Observable objects.
-
clean
(value, allow_custom)¶
-
-
class
ObjectReferenceProperty
(valid_types=None, **kwargs)¶
-
class
ObservableProperty
(spec_version='2.1', *args, **kwargs)¶ Property for holding Cyber Observable Objects.
-
clean
(value, allow_custom)¶
-
-
class
OpenVocabProperty
(allowed, **kwargs)¶ Used for open vocab type properties.
-
clean
(value, allow_custom)¶
-
-
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__()
.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 explicitly 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.
- a
Subclasses can also define the following functions:
def clean(self, value, allow_custom) -> (any, has_custom):
- Return a value that is valid for this property, and enforce and
detect value customization. If
value
is not valid for this property, you may attempt to transform it first. Ifvalue
is not valid and no such transformation is possible, it must raise an exception. The method is also responsible for enforcing and detecting customizations. If allow_custom is False, no customizations must be allowed. If any are encountered, an exception must be raised (e.g. CustomContentError). If none are encountered, False must be returned for has_custom. If allow_custom is True, then the clean() method is responsible for detecting any customizations in the value (just because the user has elected to allow customizations doesn’t mean there actually are any). The method must return an appropriate value for has_custom. Customization may not be applicable/possible for a property. In that case, allow_custom can be ignored, and has_custom must be returned as False.
- Return a value that is valid for this property, and enforce and
detect value customization. If
def default(self):
- provide a default value for this property.
default()
can return the special valueNOW
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
anddefault
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, allow_custom=False)¶
- required (bool) – If
-
class
ReferenceProperty
(valid_types=None, invalid_types=None, spec_version='2.1', **kwargs)¶ -
clean
(value, allow_custom)¶
-
-
class
TimestampProperty
(precision='any', precision_constraint='exact', **kwargs)¶ -
clean
(value, allow_custom=False)¶
-
-
class
TypeProperty
(type, spec_version='2.1')¶