From f241ed5c6c878a224b80a397e6b5d22fb52c6742 Mon Sep 17 00:00:00 2001 From: "Desai, Kartikey H" Date: Wed, 18 Sep 2019 10:56:42 -0400 Subject: [PATCH 1/2] Remove at_least_one=False from Artifact SCO --- stix2/v21/observables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stix2/v21/observables.py b/stix2/v21/observables.py index 9fffeed..0d27bb4 100644 --- a/stix2/v21/observables.py +++ b/stix2/v21/observables.py @@ -50,7 +50,7 @@ class Artifact(_Observable): def _check_object_constraints(self): super(Artifact, self)._check_object_constraints() - self._check_mutually_exclusive_properties(['payload_bin', 'url'], at_least_one=False) + self._check_mutually_exclusive_properties(['payload_bin', 'url']) self._check_properties_dependency(['hashes'], ['url']) From 113d481e84ef2a3ea426413f610eede1bf3c0e18 Mon Sep 17 00:00:00 2001 From: "Desai, Kartikey H" Date: Thu, 19 Sep 2019 10:31:14 -0400 Subject: [PATCH 2/2] Make SCO deterministic ID namespace a global var for better software hygiene --- stix2/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stix2/base.py b/stix2/base.py index dbe6461..a13cb98 100644 --- a/stix2/base.py +++ b/stix2/base.py @@ -23,6 +23,7 @@ from .utils import revoke as _revoke __all__ = ['STIXJSONEncoder', '_STIXBase'] DEFAULT_ERROR = "{type} must have {property}='{expected}'." +SCO_DET_ID_NAMESPACE = uuid.UUID("00abedb4-aa42-466c-9c01-fed23315a9b7") class STIXJSONEncoder(json.JSONEncoder): @@ -368,7 +369,6 @@ class _Observable(_STIXBase): def _generate_id(self, kwargs): required_prefix = self._type + "--" - namespace = uuid.UUID("00abedb4-aa42-466c-9c01-fed23315a9b7") properties_to_use = self._id_contributing_properties if properties_to_use: @@ -396,9 +396,9 @@ class _Observable(_STIXBase): # try/except here to enable python 2 compatibility try: - return required_prefix + six.text_type(uuid.uuid5(namespace, data)) + return required_prefix + six.text_type(uuid.uuid5(SCO_DET_ID_NAMESPACE, data)) except UnicodeDecodeError: - return required_prefix + six.text_type(uuid.uuid5(namespace, six.binary_type(data))) + return required_prefix + six.text_type(uuid.uuid5(SCO_DET_ID_NAMESPACE, six.binary_type(data))) # We return None if there are no values specified for any of the id-contributing-properties return None