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