flaky
parent
fe919049b8
commit
6e4151aeeb
|
@ -16,9 +16,11 @@ from .exceptions import (
|
|||
MissingPropertiesError, MutuallyExclusivePropertiesError,
|
||||
)
|
||||
from .markings.utils import validate
|
||||
from .utils import NOW, find_property_index, format_datetime, get_timestamp
|
||||
from .utils import (
|
||||
NOW, PREFIX_21_REGEX, find_property_index, format_datetime, get_timestamp,
|
||||
)
|
||||
from .utils import new_version as _new_version
|
||||
from .utils import revoke as _revoke, PREFIX_21_REGEX
|
||||
from .utils import revoke as _revoke
|
||||
|
||||
try:
|
||||
from collections.abc import Mapping
|
||||
|
@ -172,8 +174,10 @@ class _STIXBase(Mapping):
|
|||
if self.get_class_version() == "v21":
|
||||
for prop_name, prop_value in custom_props.items():
|
||||
if not re.match(PREFIX_21_REGEX, prop_name):
|
||||
raise InvalidValueError(self.__class__, prop_name,
|
||||
reason="Property name '%s' must begin with an alpha character." % prop_name)
|
||||
raise InvalidValueError(
|
||||
self.__class__, prop_name,
|
||||
reason="Property name '%s' must begin with an alpha character." % prop_name,
|
||||
)
|
||||
|
||||
# Remove any keyword arguments whose value is None or [] (i.e. empty list)
|
||||
setting_kwargs = {}
|
||||
|
|
|
@ -10,7 +10,7 @@ import stix2
|
|||
from .base import _Observable, _STIXBase
|
||||
from .exceptions import ParseError
|
||||
from .markings import _MarkingsMixin
|
||||
from .utils import _get_dict, TYPE_REGEX, PREFIX_21_REGEX, TYPE_21_REGEX
|
||||
from .utils import PREFIX_21_REGEX, TYPE_21_REGEX, TYPE_REGEX, _get_dict
|
||||
|
||||
STIX2_OBJ_MAPS = {}
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ from .core import (
|
|||
STIXDomainObject, _register_marking, _register_object,
|
||||
_register_observable, _register_observable_extension,
|
||||
)
|
||||
from .utils import get_class_hierarchy_names, TYPE_21_REGEX, TYPE_REGEX, PREFIX_21_REGEX
|
||||
from .utils import (
|
||||
PREFIX_21_REGEX, TYPE_21_REGEX, TYPE_REGEX, get_class_hierarchy_names,
|
||||
)
|
||||
|
||||
|
||||
def _custom_object_builder(cls, type, properties, version):
|
||||
|
|
|
@ -182,6 +182,7 @@ def test_custom_properties_dict_in_bundled_object():
|
|||
|
||||
# Custom properties in SCOs
|
||||
|
||||
|
||||
def test_custom_property_in_observed_data():
|
||||
artifact = stix2.v21.File(
|
||||
allow_custom=True,
|
||||
|
@ -275,6 +276,7 @@ def test_identity_custom_property_revoke():
|
|||
|
||||
# Custom markings
|
||||
|
||||
|
||||
def test_identity_custom_property_edit_markings():
|
||||
marking_obj = stix2.v21.MarkingDefinition(
|
||||
id=MARKING_DEFINITION_ID,
|
||||
|
@ -368,6 +370,7 @@ def test_custom_marking_invalid_type_name():
|
|||
|
||||
# Custom Objects
|
||||
|
||||
|
||||
@stix2.v21.CustomObject(
|
||||
'x-new-type', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
|
@ -499,6 +502,7 @@ def test_parse_unregistered_custom_object_type_w_allow_custom():
|
|||
|
||||
# Custom SCOs
|
||||
|
||||
|
||||
@stix2.v21.CustomObservable(
|
||||
'x-new-observable', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
|
@ -846,6 +850,7 @@ def test_custom_observable_object_no_id_contrib_props():
|
|||
|
||||
# Custom Extensions
|
||||
|
||||
|
||||
@stix2.v21.CustomExtension(
|
||||
stix2.v21.DomainName, 'x-new-ext', [
|
||||
('property1', stix2.properties.StringProperty(required=True)),
|
||||
|
@ -994,7 +999,6 @@ def test_custom_extension_invalid_type_name():
|
|||
assert "Invalid extension type name '7x-new-ext':" in str(excinfo.value)
|
||||
|
||||
|
||||
|
||||
def test_custom_extension_no_properties():
|
||||
with pytest.raises(ValueError):
|
||||
@stix2.v21.CustomExtension(stix2.v21.DomainName, 'x-new2-ext', None)
|
||||
|
@ -1055,7 +1059,6 @@ def test_invalid_custom_property_in_extension():
|
|||
assert "must begin with an alpha character." in str(excinfo.value)
|
||||
|
||||
|
||||
|
||||
def test_parse_observable_with_custom_extension():
|
||||
input_str = """{
|
||||
"type": "domain-name",
|
||||
|
|
Loading…
Reference in New Issue