From 86f9e51a42673674cc9826767e44b7ecbbf4d64e Mon Sep 17 00:00:00 2001 From: "Desai, Kartikey H" Date: Wed, 19 Feb 2020 09:11:30 -0500 Subject: [PATCH 1/2] Fixes #336 --- stix2/test/v21/test_observed_data.py | 36 -------------------------- stix2/v21/observables.py | 38 ---------------------------- 2 files changed, 74 deletions(-) diff --git a/stix2/test/v21/test_observed_data.py b/stix2/test/v21/test_observed_data.py index 371018c..6f36d88 100644 --- a/stix2/test/v21/test_observed_data.py +++ b/stix2/test/v21/test_observed_data.py @@ -1538,39 +1538,3 @@ def test_deterministic_id_no_contributing_props(): uuid_obj_2 = uuid.UUID(email_msg_2.id[-36:]) assert uuid_obj_2.variant == uuid.RFC_4122 assert uuid_obj_2.version == 4 - - -def test_ipv4_resolves_to_refs_deprecation(): - with pytest.warns(stix2.exceptions.STIXDeprecationWarning): - - stix2.v21.IPv4Address( - value="26.09.19.70", - resolves_to_refs=["mac-addr--08900593-0265-52fc-93c0-5b4a942f5887"], - ) - - -def test_ipv4_belongs_to_refs_deprecation(): - with pytest.warns(stix2.exceptions.STIXDeprecationWarning): - - stix2.v21.IPv4Address( - value="21.12.19.64", - belongs_to_refs=["autonomous-system--52e0a49d-d683-5801-a7b8-145765a1e116"], - ) - - -def test_ipv6_resolves_to_refs_deprecation(): - with pytest.warns(stix2.exceptions.STIXDeprecationWarning): - - stix2.v21.IPv6Address( - value="2001:0db8:85a3:0000:0000:8a2e:0370:7334", - resolves_to_refs=["mac-addr--08900593-0265-52fc-93c0-5b4a942f5887"], - ) - - -def test_ipv6_belongs_to_refs_deprecation(): - with pytest.warns(stix2.exceptions.STIXDeprecationWarning): - - stix2.v21.IPv6Address( - value="2001:0db8:85a3:0000:0000:8a2e:0370:7334", - belongs_to_refs=["autonomous-system--52e0a49d-d683-5801-a7b8-145765a1e116"], - ) diff --git a/stix2/v21/observables.py b/stix2/v21/observables.py index 1703263..35c1e05 100644 --- a/stix2/v21/observables.py +++ b/stix2/v21/observables.py @@ -122,14 +122,6 @@ class DomainName(_Observable): ]) _id_contributing_properties = ["value"] - def _check_object_constraints(self): - if self.get('resolves_to_refs'): - warnings.warn( - "The 'resolves_to_refs' property of domain-name is deprecated in " - "STIX 2.1. Use the 'resolves-to' relationship type instead", - STIXDeprecationWarning, - ) - class EmailAddress(_Observable): # TODO: Add link @@ -421,21 +413,6 @@ class IPv4Address(_Observable): ]) _id_contributing_properties = ["value"] - def _check_object_constraints(self): - if self.get('resolves_to_refs'): - warnings.warn( - "The 'resolves_to_refs' property of ipv4-addr is deprecated in " - "STIX 2.1. Use the 'resolves-to' relationship type instead", - STIXDeprecationWarning, - ) - - if self.get('belongs_to_refs'): - warnings.warn( - "The 'belongs_to_refs' property of ipv4-addr is deprecated in " - "STIX 2.1. Use the 'belongs-to' relationship type instead", - STIXDeprecationWarning, - ) - class IPv6Address(_Observable): # TODO: Add link @@ -458,21 +435,6 @@ class IPv6Address(_Observable): ]) _id_contributing_properties = ["value"] - def _check_object_constraints(self): - if self.get('resolves_to_refs'): - warnings.warn( - "The 'resolves_to_refs' property of ipv6-addr is deprecated in " - "STIX 2.1. Use the 'resolves-to' relationship type instead", - STIXDeprecationWarning, - ) - - if self.get('belongs_to_refs'): - warnings.warn( - "The 'belongs_to_refs' property of ipv6-addr is deprecated in " - "STIX 2.1. Use the 'belongs-to' relationship type instead", - STIXDeprecationWarning, - ) - class MACAddress(_Observable): # TODO: Add link From 8219b34ea4a4cef8cefb3d44af28375f28b6f11e Mon Sep 17 00:00:00 2001 From: "Desai, Kartikey H" Date: Wed, 19 Feb 2020 09:24:27 -0500 Subject: [PATCH 2/2] Fix formatting issues. Fixes #336 --- stix2/v21/observables.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/stix2/v21/observables.py b/stix2/v21/observables.py index 35c1e05..ed560a6 100644 --- a/stix2/v21/observables.py +++ b/stix2/v21/observables.py @@ -7,13 +7,10 @@ Observable and do not have a ``_type`` attribute. from collections import OrderedDict import itertools -import warnings from ..base import _Extension, _Observable, _STIXBase from ..custom import _custom_extension_builder, _custom_observable_builder -from ..exceptions import ( - AtLeastOnePropertyError, DependentPropertiesError, STIXDeprecationWarning, -) +from ..exceptions import AtLeastOnePropertyError, DependentPropertiesError from ..properties import ( BinaryProperty, BooleanProperty, DictionaryProperty, EmbeddedObjectProperty, EnumProperty, ExtensionsProperty, FloatProperty,