diff --git a/stix2/properties.py b/stix2/properties.py index 33d3917..5e6c3c3 100644 --- a/stix2/properties.py +++ b/stix2/properties.py @@ -309,7 +309,7 @@ class HexProperty(Property): REF_REGEX = re.compile("^[a-z][a-z-]+[a-z]--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}" - "-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") + "-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$") class ReferenceProperty(Property): diff --git a/stix2/test/test_datastore_filters.py b/stix2/test/test_datastore_filters.py index b12eaa8..76ae6de 100644 --- a/stix2/test/test_datastore_filters.py +++ b/stix2/test/test_datastore_filters.py @@ -97,7 +97,7 @@ filters = [ Filter("granular_markings.marking_ref", "=", "marking-definition--5e57c739-391a-4eb3-b6be-7d15ca92d5ed"), Filter("external_references.external_id", "in", "CVE-2014-0160,CVE-2017-6608"), Filter("created_by_ref", "=", "identity--f1350682-3290-4e0d-be58-69e290537647"), - Filter("object_marking_refs", "=", "marking-definition--613f2e26-0000-0000-0000-b8e91df99dc9"), + Filter("object_marking_refs", "=", "marking-definition--613f2e26-0000-4000-8000-b8e91df99dc9"), Filter("granular_markings.selectors", "in", "description"), Filter("external_references.source_name", "=", "CVE"), Filter("objects", "=", {"0": {"type": "file", "name": "HAL 9000.exe"}}) @@ -262,7 +262,7 @@ def test_apply_common_filters9(): def test_apply_common_filters10(): - # "Return any object that matches marking-definition--613f2e26-0000-0000-0000-b8e91df99dc9 in object_marking_refs" (None) + # "Return any object that matches marking-definition--613f2e26-0000-4000-8000-b8e91df99dc9 in object_marking_refs" (None) resp = list(apply_common_filters(stix_objs, [filters[11]])) assert len(resp) == 0 diff --git a/stix2/test/test_memory.py b/stix2/test/test_memory.py index 88078d7..44f90ba 100644 --- a/stix2/test/test_memory.py +++ b/stix2/test/test_memory.py @@ -155,7 +155,7 @@ def test_memory_source_get(mem_source): def test_memory_source_get_nonexistant_object(mem_source): - resp = mem_source.get("tool--d81f86b8-975b-bc0b-775e-810c5ad45a4f") + resp = mem_source.get("tool--8d0b222c-7a3b-44a0-b9c6-31b051efb32e") assert resp is None diff --git a/stix2/test/test_properties.py b/stix2/test/test_properties.py index 462735c..b2e49b5 100644 --- a/stix2/test/test_properties.py +++ b/stix2/test/test_properties.py @@ -245,10 +245,14 @@ def test_boolean_property_invalid(value): def test_reference_property(): ref_prop = ReferenceProperty() - assert ref_prop.clean("my-type--3a331bfe-0566-55e1-a4a0-9a2cd355a300") + assert ref_prop.clean("my-type--00000000-0000-4000-8000-000000000000") with pytest.raises(ValueError): ref_prop.clean("foo") + # This is not a valid V4 UUID + with pytest.raises(ValueError): + ref_prop.clean("my-type--00000000-0000-0000-0000-000000000000") + @pytest.mark.parametrize("value", [ '2017-01-01T12:34:56Z',