Sort imports.
							parent
							
								
									5cbe886cdb
								
							
						
					
					
						commit
						9baaad6e08
					
				|  | @ -56,7 +56,7 @@ class STIXJSONIncludeOptionalDefaultsEncoder(json.JSONEncoder): | |||
|         elif isinstance(obj, _STIXBase): | ||||
|             return dict(obj) | ||||
|         else: | ||||
|             return super(STIXJSONEncoder, self).default(obj) | ||||
|             return super(STIXJSONIncludeOptionalDefaultsEncoder, self).default(obj) | ||||
| 
 | ||||
| 
 | ||||
| def get_required_properties(properties): | ||||
|  |  | |||
|  | @ -2,8 +2,7 @@ import importlib | |||
| import pkgutil | ||||
| 
 | ||||
| import stix2 | ||||
| 
 | ||||
| from . import exceptions | ||||
| from .exceptions import ParseError | ||||
| from .utils import _get_dict | ||||
| 
 | ||||
| STIX2_OBJ_MAPS = {} | ||||
|  | @ -74,7 +73,7 @@ def dict_to_stix2(stix_dict, allow_custom=False, version=None): | |||
| 
 | ||||
|     """ | ||||
|     if 'type' not in stix_dict: | ||||
|         raise exceptions.ParseError("Can't parse object with no 'type' property: %s" % str(stix_dict)) | ||||
|         raise ParseError("Can't parse object with no 'type' property: %s" % str(stix_dict)) | ||||
| 
 | ||||
|     if "spec_version" in stix_dict: | ||||
|         # For STIX 2.0, applies to bundles only. | ||||
|  | @ -87,7 +86,7 @@ def dict_to_stix2(stix_dict, allow_custom=False, version=None): | |||
|         else: | ||||
|             v = 'v' + stix2.DEFAULT_VERSION.replace('.', '') | ||||
|     else: | ||||
|         v = 'v20' | ||||
|         v = 'v' + stix2.DEFAULT_VERSION.replace('.', '') | ||||
| 
 | ||||
|     OBJ_MAP = STIX2_OBJ_MAPS[v] | ||||
| 
 | ||||
|  | @ -98,7 +97,7 @@ def dict_to_stix2(stix_dict, allow_custom=False, version=None): | |||
|             # flag allows for unknown custom objects too, but will not | ||||
|             # be parsed into STIX object, returned as is | ||||
|             return stix_dict | ||||
|         raise exceptions.ParseError("Can't parse unknown object type '%s'! For custom types, use the CustomObject decorator." % stix_dict['type']) | ||||
|         raise ParseError("Can't parse unknown object type '%s'! For custom types, use the CustomObject decorator." % stix_dict['type']) | ||||
| 
 | ||||
|     return obj_class(allow_custom=allow_custom, **stix_dict) | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,10 +1,10 @@ | |||
| from collections import OrderedDict | ||||
| 
 | ||||
| from stix2 import parse | ||||
| from stix2.base import _STIXBase | ||||
| from .properties import (IDProperty, ListProperty, Property, | ||||
|                          StringProperty, TypeProperty) | ||||
| from stix2.utils import _get_dict, get_class_hierarchy_names | ||||
| from ..base import _STIXBase | ||||
| from ..core import parse | ||||
| from ..utils import _get_dict, get_class_hierarchy_names | ||||
| from .properties import (IDProperty, ListProperty, Property, StringProperty, | ||||
|                          TypeProperty) | ||||
| 
 | ||||
| 
 | ||||
| class STIXObjectProperty(Property): | ||||
|  |  | |||
|  | @ -4,10 +4,10 @@ from collections import OrderedDict | |||
| 
 | ||||
| from ..base import _STIXBase | ||||
| from ..markings import _MarkingsMixin | ||||
| from ..utils import NOW, _get_dict | ||||
| from .properties import (HashesProperty, IDProperty, ListProperty, Property, | ||||
|                          ReferenceProperty, SelectorProperty, StringProperty, | ||||
|                          TimestampProperty, TypeProperty) | ||||
| from ..utils import NOW, _get_dict | ||||
| 
 | ||||
| 
 | ||||
| class ExternalReference(_STIXBase): | ||||
|  |  | |||
|  | @ -12,12 +12,12 @@ import re | |||
| from ..base import _Extension, _Observable, _STIXBase | ||||
| from ..exceptions import (AtLeastOnePropertyError, CustomContentError, | ||||
|                           DependentPropertiesError, ParseError) | ||||
| from ..utils import TYPE_REGEX, _get_dict | ||||
| from .properties import (BinaryProperty, BooleanProperty, DictionaryProperty, | ||||
|                          EmbeddedObjectProperty, EnumProperty, FloatProperty, | ||||
|                          HashesProperty, HexProperty, IntegerProperty, | ||||
|                          ListProperty, ObjectReferenceProperty, Property, | ||||
|                          StringProperty, TimestampProperty, TypeProperty) | ||||
| from ..utils import TYPE_REGEX, _get_dict | ||||
| 
 | ||||
| 
 | ||||
| class ObservableProperty(Property): | ||||
|  |  | |||
|  | @ -10,9 +10,9 @@ import uuid | |||
| from six import string_types, text_type | ||||
| from stix2patterns.validator import run_validator | ||||
| 
 | ||||
| from stix2.base import _STIXBase | ||||
| from stix2.exceptions import DictionaryKeyError | ||||
| from stix2.utils import _get_dict, parse_into_datetime | ||||
| from ..base import _STIXBase | ||||
| from ..exceptions import DictionaryKeyError | ||||
| from ..utils import _get_dict, parse_into_datetime | ||||
| 
 | ||||
| 
 | ||||
| class Property(object): | ||||
|  |  | |||
|  | @ -4,16 +4,15 @@ | |||
| from collections import OrderedDict | ||||
| import re | ||||
| 
 | ||||
| import stix2 | ||||
| 
 | ||||
| from ..base import _STIXBase | ||||
| from ..core import _register_type | ||||
| from ..markings import _MarkingsMixin | ||||
| from .properties import (BooleanProperty, IDProperty, IntegerProperty, | ||||
|                          ListProperty, PatternProperty, ReferenceProperty, | ||||
|                          StringProperty, TimestampProperty, TypeProperty) | ||||
| from ..utils import NOW, TYPE_REGEX | ||||
| from .common import ExternalReference, GranularMarking, KillChainPhase | ||||
| from .observables import ObservableProperty | ||||
| from .properties import (BooleanProperty, IDProperty, IntegerProperty, | ||||
|                          ListProperty, PatternProperty, ReferenceProperty, | ||||
|                          StringProperty, TimestampProperty, TypeProperty) | ||||
| 
 | ||||
| 
 | ||||
| class STIXDomainObject(_STIXBase, _MarkingsMixin): | ||||
|  | @ -409,7 +408,7 @@ def CustomObject(type='x-custom-type', properties=None): | |||
|                         return | ||||
|                     raise e | ||||
| 
 | ||||
|         stix2._register_type(_Custom, version="2.0") | ||||
|         _register_type(_Custom, version="2.0") | ||||
|         return _Custom | ||||
| 
 | ||||
|     return custom_builder | ||||
|  |  | |||
|  | @ -4,11 +4,11 @@ from collections import OrderedDict | |||
| 
 | ||||
| from ..base import _STIXBase | ||||
| from ..markings import _MarkingsMixin | ||||
| from ..utils import NOW | ||||
| from .common import ExternalReference, GranularMarking | ||||
| from .properties import (BooleanProperty, IDProperty, IntegerProperty, | ||||
|                          ListProperty, ReferenceProperty, StringProperty, | ||||
|                          TimestampProperty, TypeProperty) | ||||
| from ..utils import NOW | ||||
| from .common import ExternalReference, GranularMarking | ||||
| 
 | ||||
| 
 | ||||
| class STIXRelationshipObject(_STIXBase, _MarkingsMixin): | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| from collections import OrderedDict | ||||
| 
 | ||||
| from stix2 import parse | ||||
| from stix2.base import _STIXBase | ||||
| from ..base import _STIXBase | ||||
| from ..core import parse | ||||
| from ..utils import _get_dict, get_class_hierarchy_names | ||||
| from .properties import IDProperty, ListProperty, Property, TypeProperty | ||||
| from stix2.utils import _get_dict, get_class_hierarchy_names | ||||
| 
 | ||||
| 
 | ||||
| class STIXObjectProperty(Property): | ||||
|  |  | |||
|  | @ -4,11 +4,11 @@ from collections import OrderedDict | |||
| 
 | ||||
| from ..base import _STIXBase | ||||
| from ..markings import _MarkingsMixin | ||||
| from .properties import (BooleanProperty, DictionaryProperty, HashesProperty, | ||||
|                          IDProperty, ListProperty, Property, | ||||
|                          ReferenceProperty, SelectorProperty, StringProperty, | ||||
|                          TimestampProperty, TypeProperty) | ||||
| from ..utils import NOW, _get_dict | ||||
| from .properties import (BooleanProperty, DictionaryProperty, HashesProperty, | ||||
|                          IDProperty, ListProperty, Property, ReferenceProperty, | ||||
|                          SelectorProperty, StringProperty, TimestampProperty, | ||||
|                          TypeProperty) | ||||
| 
 | ||||
| 
 | ||||
| class ExternalReference(_STIXBase): | ||||
|  |  | |||
|  | @ -12,12 +12,12 @@ import re | |||
| from ..base import _Extension, _Observable, _STIXBase | ||||
| from ..exceptions import (AtLeastOnePropertyError, CustomContentError, | ||||
|                           DependentPropertiesError, ParseError) | ||||
| from ..utils import TYPE_REGEX, _get_dict | ||||
| from .properties import (BinaryProperty, BooleanProperty, DictionaryProperty, | ||||
|                          EmbeddedObjectProperty, EnumProperty, FloatProperty, | ||||
|                          HashesProperty, HexProperty, IntegerProperty, | ||||
|                          ListProperty, ObjectReferenceProperty, Property, | ||||
|                          StringProperty, TimestampProperty, TypeProperty) | ||||
| from ..utils import TYPE_REGEX, _get_dict | ||||
| 
 | ||||
| 
 | ||||
| class ObservableProperty(Property): | ||||
|  |  | |||
|  | @ -10,9 +10,9 @@ import uuid | |||
| from six import string_types, text_type | ||||
| from stix2patterns.validator import run_validator | ||||
| 
 | ||||
| from stix2.base import _STIXBase | ||||
| from stix2.exceptions import DictionaryKeyError | ||||
| from stix2.utils import _get_dict, parse_into_datetime | ||||
| from ..base import _STIXBase | ||||
| from ..exceptions import DictionaryKeyError | ||||
| from ..utils import _get_dict, parse_into_datetime | ||||
| 
 | ||||
| 
 | ||||
| class Property(object): | ||||
|  |  | |||
|  | @ -3,18 +3,17 @@ | |||
| from collections import OrderedDict | ||||
| import re | ||||
| 
 | ||||
| import stix2 | ||||
| 
 | ||||
| from ..base import _STIXBase | ||||
| from ..core import _register_type | ||||
| from ..markings import _MarkingsMixin | ||||
| from ..utils import NOW, TYPE_REGEX | ||||
| from .common import ExternalReference, GranularMarking, KillChainPhase | ||||
| from .observables import ObservableProperty | ||||
| from .properties import (BooleanProperty, DictionaryProperty, | ||||
|                          EmbeddedObjectProperty, EnumProperty, FloatProperty, | ||||
|                          IDProperty, IntegerProperty, ListProperty, | ||||
|                          PatternProperty, ReferenceProperty, StringProperty, | ||||
|                          TimestampProperty, TypeProperty) | ||||
| from ..utils import NOW, TYPE_REGEX | ||||
| from .common import ExternalReference, GranularMarking, KillChainPhase | ||||
| from .observables import ObservableProperty | ||||
| 
 | ||||
| 
 | ||||
| class STIXDomainObject(_STIXBase, _MarkingsMixin): | ||||
|  | @ -585,7 +584,7 @@ def CustomObject(type='x-custom-type', properties=None): | |||
|                         return | ||||
|                     raise e | ||||
| 
 | ||||
|         stix2._register_type(_Custom, version="2.1") | ||||
|         _register_type(_Custom, version="2.1") | ||||
|         return _Custom | ||||
| 
 | ||||
|     return custom_builder | ||||
|  |  | |||
|  | @ -4,11 +4,11 @@ from collections import OrderedDict | |||
| 
 | ||||
| from ..base import _STIXBase | ||||
| from ..markings import _MarkingsMixin | ||||
| from ..utils import NOW | ||||
| from .common import ExternalReference, GranularMarking | ||||
| from .properties import (BooleanProperty, IDProperty, IntegerProperty, | ||||
|                          ListProperty, ReferenceProperty, StringProperty, | ||||
|                          TimestampProperty, TypeProperty) | ||||
| from ..utils import NOW | ||||
| from .common import ExternalReference, GranularMarking | ||||
| 
 | ||||
| 
 | ||||
| class STIXRelationshipObject(_STIXBase, _MarkingsMixin): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Emmanuelle Vargas-Gonzalez
						Emmanuelle Vargas-Gonzalez