Introduce and relocate version-based pattern checking. Fixes #307
parent
4350680e79
commit
7a47f348a0
|
@ -556,10 +556,7 @@ class EnumProperty(StringProperty):
|
||||||
|
|
||||||
|
|
||||||
class PatternProperty(StringProperty):
|
class PatternProperty(StringProperty):
|
||||||
|
pass
|
||||||
def clean(self, value):
|
|
||||||
cleaned_value = super(PatternProperty, self).clean(value)
|
|
||||||
return cleaned_value
|
|
||||||
|
|
||||||
|
|
||||||
class ObservableProperty(Property):
|
class ObservableProperty(Property):
|
||||||
|
|
|
@ -198,20 +198,6 @@ def test_indicator_stix21_invalid_pattern():
|
||||||
now = dt.datetime(2017, 1, 1, 0, 0, 1, tzinfo=pytz.utc)
|
now = dt.datetime(2017, 1, 1, 0, 0, 1, tzinfo=pytz.utc)
|
||||||
epoch = dt.datetime(1970, 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:
|
with pytest.raises(stix2.exceptions.InvalidValueError) as excinfo:
|
||||||
stix2.v20.Indicator(
|
stix2.v20.Indicator(
|
||||||
type="indicator",
|
type="indicator",
|
||||||
|
|
|
@ -257,19 +257,6 @@ def test_indicator_stix20_invalid_pattern():
|
||||||
now = dt.datetime(2017, 1, 1, 0, 0, 1, tzinfo=pytz.utc)
|
now = dt.datetime(2017, 1, 1, 0, 0, 1, tzinfo=pytz.utc)
|
||||||
epoch = dt.datetime(1970, 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:
|
with pytest.raises(stix2.exceptions.InvalidValueError) as excinfo:
|
||||||
stix2.v21.Indicator(
|
stix2.v21.Indicator(
|
||||||
type="indicator",
|
type="indicator",
|
||||||
|
|
Loading…
Reference in New Issue