diff --git a/stix2/registration.py b/stix2/registration.py index 65d2714..6d426f2 100644 --- a/stix2/registration.py +++ b/stix2/registration.py @@ -68,9 +68,7 @@ def _register_marking(new_marking, version=DEFAULT_VERSION): if not re.match(PREFIX_21_REGEX, prop_name): raise ValueError("Property name '%s' must begin with an alpha character." % prop_name) - class_maps = registry.get_stix2_class_maps(version) - - OBJ_MAP_MARKING = class_maps['markings'] + OBJ_MAP_MARKING = registry.STIX2_OBJ_MAPS[version]['markings'] if mark_type in OBJ_MAP_MARKING.keys(): raise DuplicateRegistrationError("STIX Marking", mark_type) OBJ_MAP_MARKING[mark_type] = new_marking @@ -129,9 +127,7 @@ def _register_observable(new_observable, version=DEFAULT_VERSION): "is not a ListProperty containing ReferenceProperty." % prop_name, ) - class_maps = registry.get_stix2_class_maps(version) - - OBJ_MAP_OBSERVABLE = class_maps['observables'] + OBJ_MAP_OBSERVABLE = registry.STIX2_OBJ_MAPS[version]['observables'] if new_observable._type in OBJ_MAP_OBSERVABLE.keys(): raise DuplicateRegistrationError("Cyber Observable", new_observable._type) OBJ_MAP_OBSERVABLE[new_observable._type] = new_observable @@ -185,9 +181,8 @@ def _register_observable_extension( "created with the @CustomObservable decorator.", ) - class_maps = registry.get_stix2_class_maps(version) - OBJ_MAP_OBSERVABLE = class_maps['observables'] - EXT_MAP = class_maps['observable-extensions'] + OBJ_MAP_OBSERVABLE = registry.STIX2_OBJ_MAPS[version]['observables'] + EXT_MAP = registry.STIX2_OBJ_MAPS[version]['observable-extensions'] try: if ext_type in EXT_MAP[observable_type].keys(): diff --git a/stix2/registry.py b/stix2/registry.py index 3b45e48..3849913 100644 --- a/stix2/registry.py +++ b/stix2/registry.py @@ -42,17 +42,3 @@ def _collect_stix2_mappings(): ver = _stix_vid_to_version(stix_vid) mod = importlib.import_module(name, str(top_level_module.__name__)) STIX2_OBJ_MAPS[ver]['markings'] = mod.OBJ_MAP_MARKING - - -def get_stix2_class_maps(stix_version): - """ - Get the stix2 class mappings for the given STIX version. - - :param stix_version: A STIX version as a string - :return: The class mappings. This will be a dict mapping from some general - category name, e.g. "object" to another mapping from STIX type - to a stix2 class. - """ - cls_maps = STIX2_OBJ_MAPS[stix_version] - - return cls_maps diff --git a/stix2/utils.py b/stix2/utils.py index 34915d9..c44dbe1 100644 --- a/stix2/utils.py +++ b/stix2/utils.py @@ -350,7 +350,7 @@ def is_sdo(value, stix_version=stix2.DEFAULT_VERSION): :return: True if the type of the given value is an SDO type; False if not """ - cls_maps = mappings.get_stix2_class_maps(stix_version) + cls_maps = mappings.STIX2_OBJ_MAPS[stix_version] type_ = _stix_type_of(value) result = type_ in cls_maps["objects"] and type_ not in { "relationship", "sighting", "marking-definition", "bundle", @@ -370,7 +370,7 @@ def is_sco(value, stix_version=stix2.DEFAULT_VERSION): :return: True if the type of the given value is an SCO type; False if not """ - cls_maps = mappings.get_stix2_class_maps(stix_version) + cls_maps = mappings.STIX2_OBJ_MAPS[stix_version] type_ = _stix_type_of(value) result = type_ in cls_maps["observables"] @@ -406,7 +406,7 @@ def is_object(value, stix_version=stix2.DEFAULT_VERSION): :return: True if the type of the given value is a valid STIX type with respect to the given STIX version; False if not """ - cls_maps = mappings.get_stix2_class_maps(stix_version) + cls_maps = mappings.STIX2_OBJ_MAPS[stix_version] type_ = _stix_type_of(value) result = type_ in cls_maps["observables"] or type_ in cls_maps["objects"]