2020-03-22 03:22:36 +01:00
|
|
|
"""Base classes for STIX 2.1 type definitions."""
|
|
|
|
|
2020-03-27 07:40:42 +01:00
|
|
|
from ..base import (
|
|
|
|
_DomainObject, _Extension, _Observable, _RelationshipObject, _STIXBase,
|
|
|
|
)
|
2020-03-22 03:22:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
class _STIXBase21(_STIXBase):
|
2021-06-26 04:10:31 +02:00
|
|
|
pass
|
2020-03-22 03:22:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
class _Observable(_Observable, _STIXBase21):
|
2020-11-11 00:32:58 +01:00
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
super(_Observable, self).__init__(**kwargs)
|
|
|
|
if 'id' not in kwargs:
|
|
|
|
# Specific to 2.1+ observables: generate a deterministic ID
|
|
|
|
id_ = self._generate_id()
|
|
|
|
|
|
|
|
# Spec says fall back to UUIDv4 if no contributing properties were
|
|
|
|
# given. That's what already happened (the following is actually
|
|
|
|
# overwriting the default uuidv4), so nothing to do here.
|
|
|
|
if id_ is not None:
|
|
|
|
# Can't assign to self (we're immutable), so slip the ID in
|
|
|
|
# more sneakily.
|
|
|
|
self._inner["id"] = id_
|
2020-03-22 03:22:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
class _Extension(_Extension, _STIXBase21):
|
2020-12-23 03:41:46 +01:00
|
|
|
extension_type = None
|
2020-11-11 00:32:58 +01:00
|
|
|
|
2020-03-22 03:22:36 +01:00
|
|
|
|
2020-03-27 07:40:42 +01:00
|
|
|
class _DomainObject(_DomainObject, _STIXBase21):
|
2020-03-22 03:22:36 +01:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2020-03-27 07:40:42 +01:00
|
|
|
class _RelationshipObject(_RelationshipObject, _STIXBase21):
|
2020-03-22 03:22:36 +01:00
|
|
|
pass
|