Update README, add DEFAULT_VERSION
parent
ef20860400
commit
06a50b0178
|
@ -65,8 +65,9 @@ For more in-depth documentation, please see `https://stix2.readthedocs.io/ <http
|
||||||
STIX 2.X Technical Specification Support
|
STIX 2.X Technical Specification Support
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
The `stix2` Python library is built to support multiple versions of the STIX
|
This version of python-stix2 supports STIX 2.0 by default. Although, the `stix2`
|
||||||
Technical Specification. With every major release of stix2 the ``import stix2``
|
Python library is built to support multiple versions of the STIX Technical
|
||||||
|
Specification. With every major release of stix2 the ``import stix2``
|
||||||
statement will automatically load the SDO/SROs equivalent to the most recent
|
statement will automatically load the SDO/SROs equivalent to the most recent
|
||||||
supported 2.X Technical Specification. Please see the library documentation
|
supported 2.X Technical Specification. Please see the library documentation
|
||||||
for more details.
|
for more details.
|
||||||
|
|
|
@ -203,7 +203,7 @@
|
||||||
"source": [
|
"source": [
|
||||||
"### How will custom work\n",
|
"### How will custom work\n",
|
||||||
"\n",
|
"\n",
|
||||||
"CustomObjects, CustomObservable, CustomMarking and CustomExtensions must be registered explicitly by STIX version. This is a design decision since properties or requirements may change as the STIX Technical Specification advances.\n",
|
"CustomObject, CustomObservable, CustomMarking and CustomExtension must be registered explicitly by STIX version. This is a design decision since properties or requirements may change as the STIX Technical Specification advances.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"You can perform this by,"
|
"You can perform this by,"
|
||||||
]
|
]
|
||||||
|
|
|
@ -49,7 +49,9 @@ from .sources.memory import MemorySink, MemorySource, MemoryStore
|
||||||
from .sources.taxii import (TAXIICollectionSink, TAXIICollectionSource,
|
from .sources.taxii import (TAXIICollectionSink, TAXIICollectionSource,
|
||||||
TAXIICollectionStore)
|
TAXIICollectionStore)
|
||||||
from .utils import get_dict, new_version, revoke
|
from .utils import get_dict, new_version, revoke
|
||||||
from .v20 import * # This import should always be the latest STIX 2.X version
|
from .v20 import * # This import will always be the latest STIX 2.X version
|
||||||
from .version import __version__
|
from .version import __version__
|
||||||
|
|
||||||
_collect_stix2_obj_maps()
|
_collect_stix2_obj_maps()
|
||||||
|
|
||||||
|
DEFAULT_VERSION = "2.0" # Default version will always be the latest STIX 2.X version
|
||||||
|
|
|
@ -4,7 +4,7 @@ from collections import OrderedDict
|
||||||
import importlib
|
import importlib
|
||||||
import pkgutil
|
import pkgutil
|
||||||
|
|
||||||
from . import exceptions
|
from . import DEFAULT_VERSION, exceptions
|
||||||
from .base import _STIXBase
|
from .base import _STIXBase
|
||||||
from .properties import IDProperty, ListProperty, Property, TypeProperty
|
from .properties import IDProperty, ListProperty, Property, TypeProperty
|
||||||
from .utils import get_dict
|
from .utils import get_dict
|
||||||
|
@ -78,11 +78,11 @@ def parse(data, allow_custom=False, version=None):
|
||||||
"""
|
"""
|
||||||
if not version:
|
if not version:
|
||||||
# Use latest version
|
# Use latest version
|
||||||
OBJ_MAP = STIX2_OBJ_MAPS[sorted(STIX2_OBJ_MAPS.keys())[-1]]
|
v = 'v' + DEFAULT_VERSION.replace('.', '')
|
||||||
else:
|
else:
|
||||||
v = 'v' + version.replace('.', '')
|
v = 'v' + version.replace('.', '')
|
||||||
OBJ_MAP = STIX2_OBJ_MAPS[v]
|
|
||||||
|
|
||||||
|
OBJ_MAP = STIX2_OBJ_MAPS[v]
|
||||||
obj = get_dict(data)
|
obj = get_dict(data)
|
||||||
|
|
||||||
if 'type' not in obj:
|
if 'type' not in obj:
|
||||||
|
@ -105,11 +105,11 @@ def _register_type(new_type, version=None):
|
||||||
"""
|
"""
|
||||||
if not version:
|
if not version:
|
||||||
# Use latest version
|
# Use latest version
|
||||||
OBJ_MAP = STIX2_OBJ_MAPS[sorted(STIX2_OBJ_MAPS.keys())[-1]]
|
v = 'v' + DEFAULT_VERSION.replace('.', '')
|
||||||
else:
|
else:
|
||||||
v = 'v' + version.replace('.', '')
|
v = 'v' + version.replace('.', '')
|
||||||
OBJ_MAP = STIX2_OBJ_MAPS[v]
|
|
||||||
|
|
||||||
|
OBJ_MAP = STIX2_OBJ_MAPS[v]
|
||||||
OBJ_MAP[new_type._type] = new_type
|
OBJ_MAP[new_type._type] = new_type
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue