From 7a47f348a01927d6dc2887996195415c094f0264 Mon Sep 17 00:00:00 2001 From: "Desai, Kartikey H" Date: Fri, 3 Jan 2020 14:00:15 -0500 Subject: [PATCH] Introduce and relocate version-based pattern checking. Fixes #307 --- stix2/properties.py | 5 +---- stix2/test/v20/test_indicator.py | 14 -------------- stix2/test/v21/test_indicator.py | 13 ------------- 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/stix2/properties.py b/stix2/properties.py index 4f1ebd2..bd1e114 100644 --- a/stix2/properties.py +++ b/stix2/properties.py @@ -556,10 +556,7 @@ class EnumProperty(StringProperty): class PatternProperty(StringProperty): - - def clean(self, value): - cleaned_value = super(PatternProperty, self).clean(value) - return cleaned_value + pass class ObservableProperty(Property): diff --git a/stix2/test/v20/test_indicator.py b/stix2/test/v20/test_indicator.py index 8fe8d5d..f20c902 100644 --- a/stix2/test/v20/test_indicator.py +++ b/stix2/test/v20/test_indicator.py @@ -198,20 +198,6 @@ def test_indicator_stix21_invalid_pattern(): now = dt.datetime(2017, 1, 1, 0, 0, 1, tzinfo=pytz.utc) epoch = dt.datetime(1970, 1, 1, 0, 0, 1, tzinfo=pytz.utc) - ind1 = stix2.v21.Indicator( - type="indicator", - id=INDICATOR_ID, - created=now, - modified=now, - pattern="[EXISTS windows-registry-key:values]", - pattern_type="stix", - valid_from=epoch, - indicator_types=['malicious-activity'], - ) - - assert ind1.id == INDICATOR_ID - assert ind1.pattern == "[EXISTS windows-registry-key:values]" - with pytest.raises(stix2.exceptions.InvalidValueError) as excinfo: stix2.v20.Indicator( type="indicator", diff --git a/stix2/test/v21/test_indicator.py b/stix2/test/v21/test_indicator.py index ff5c7cc..77f9fde 100644 --- a/stix2/test/v21/test_indicator.py +++ b/stix2/test/v21/test_indicator.py @@ -257,19 +257,6 @@ def test_indicator_stix20_invalid_pattern(): now = dt.datetime(2017, 1, 1, 0, 0, 1, tzinfo=pytz.utc) epoch = dt.datetime(1970, 1, 1, 0, 0, 1, tzinfo=pytz.utc) - ind1 = stix2.v20.Indicator( - type="indicator", - id=INDICATOR_ID, - created=now, - modified=now, - pattern="[win-registry-key:key = 'hkey_local_machine\\\\foo\\\\bar'] WITHIN 5 SECONDS WITHIN 6 SECONDS", - valid_from=epoch, - labels=["malicious-activity"], - ) - - assert ind1.id == INDICATOR_ID - assert ind1.pattern == "[win-registry-key:key = 'hkey_local_machine\\\\foo\\\\bar'] WITHIN 5 SECONDS WITHIN 6 SECONDS" - with pytest.raises(stix2.exceptions.InvalidValueError) as excinfo: stix2.v21.Indicator( type="indicator",