Introduce and relocate version-based pattern checking. Fixes #307

master
Desai, Kartikey H 2020-01-03 14:00:15 -05:00 committed by Chris Lenk
parent 4350680e79
commit 7a47f348a0
3 changed files with 1 additions and 31 deletions

View File

@ -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):

View File

@ -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",

View File

@ -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",