diff --git a/stix2/test/v21/test_observed_data.py b/stix2/test/v21/test_observed_data.py index 0e97ca6..b4e3f31 100644 --- a/stix2/test/v21/test_observed_data.py +++ b/stix2/test/v21/test_observed_data.py @@ -1375,3 +1375,18 @@ def test_new_version_with_related_objects(): new_version = data.new_version(last_observed="2017-12-12T12:00:00Z") assert new_version.last_observed.year == 2017 assert new_version.objects['domain'].resolves_to_refs[0] == 'src_ip' + + +def test_objects_deprecation(): + with pytest.deprecated_call(): + stix2.v21.ObservedData( + first_observed="2016-03-12T12:00:00Z", + last_observed="2016-03-12T12:00:00Z", + number_observed=1, + objects={ + "0": { + "type": "file", + "name": "foo", + }, + }, + ) diff --git a/stix2/v21/sdo.py b/stix2/v21/sdo.py index 490de39..f04ea98 100644 --- a/stix2/v21/sdo.py +++ b/stix2/v21/sdo.py @@ -2,6 +2,7 @@ from collections import OrderedDict import itertools +import warnings from six.moves.urllib.parse import quote_plus @@ -573,6 +574,13 @@ class ObservedData(STIXDomainObject): self.__allow_custom = kwargs.get('allow_custom', False) self._properties['objects'].allow_custom = kwargs.get('allow_custom', False) + if "objects" in kwargs: + warnings.warn( + "The 'objects' property of observed-data is deprecated in " + "STIX 2.1.", + DeprecationWarning, + ) + super(ObservedData, self).__init__(*args, **kwargs) def _check_object_constraints(self):