From ef98c3893753cc1fce6c420d623b66ca6d523d27 Mon Sep 17 00:00:00 2001 From: Emmanuelle Vargas-Gonzalez Date: Mon, 23 Oct 2017 08:04:18 -0400 Subject: [PATCH] Minor changes --- stix2/__init__.py | 3 ++- stix2/common.py | 5 +++-- stix2/observables.py | 2 +- stix2/sdo.py | 2 +- stix2/utils.py | 6 +++++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/stix2/__init__.py b/stix2/__init__.py index db14aa7..661c247 100644 --- a/stix2/__init__.py +++ b/stix2/__init__.py @@ -22,7 +22,8 @@ from . import exceptions from .common import (TLP_AMBER, TLP_GREEN, TLP_RED, TLP_WHITE, CustomMarking, ExternalReference, GranularMarking, KillChainPhase, - MarkingDefinition, StatementMarking, TLPMarking) + LanguageContent, MarkingDefinition, StatementMarking, + TLPMarking) from .core import Bundle, _register_type, parse from .environment import Environment, ObjectFactory from .markings import (add_markings, clear_markings, get_markings, is_marked, diff --git a/stix2/common.py b/stix2/common.py index 0d624ff..fdeef03 100644 --- a/stix2/common.py +++ b/stix2/common.py @@ -41,7 +41,7 @@ class GranularMarking(_STIXBase): _properties = OrderedDict() _properties.update([ ('lang', StringProperty()), - ('marking_ref', ReferenceProperty(type="marking-definition")), # TODO: In 2.0 is required, not in 2.1 + ('marking_ref', ReferenceProperty(type="marking-definition")), ('selectors', ListProperty(SelectorProperty, required=True)), ]) @@ -51,6 +51,7 @@ class GranularMarking(_STIXBase): class LanguageContent(_STIXBase): + _type = 'language-content' _properties = OrderedDict() _properties.update([ @@ -61,7 +62,7 @@ class LanguageContent(_STIXBase): ('modified', TimestampProperty(default=lambda: NOW, precision='millisecond')), ('object_ref', ReferenceProperty(required=True)), # TODO: 'object_modified' it MUST be an exact match for the modified time of the STIX Object (SRO or SDO) being referenced. - ('object_modified', TimestampProperty(required=True)), + ('object_modified', TimestampProperty(required=True, precision='millisecond')), # TODO: 'contents' https://docs.google.com/document/d/1ShNq4c3e1CkfANmD9O--mdZ5H0O_GLnjN28a_yrEaco/edit#heading=h.cfz5hcantmvx ('contents', DictionaryProperty(required=True)), ('revoked', BooleanProperty()), diff --git a/stix2/observables.py b/stix2/observables.py index 45c3066..aaec2d7 100644 --- a/stix2/observables.py +++ b/stix2/observables.py @@ -460,7 +460,7 @@ class SocketExt(_Extension): "SOCK_SEQPACKET", ])), ('socket_descriptor', IntegerProperty()), - ('socket_handle', IntegerProperty()) + ('socket_handle', IntegerProperty()), ]) diff --git a/stix2/sdo.py b/stix2/sdo.py index d5d093e..da8fa65 100644 --- a/stix2/sdo.py +++ b/stix2/sdo.py @@ -281,7 +281,7 @@ class Opinion(STIXDomainObject): ('created_by_ref', ReferenceProperty(type="identity")), ('created', TimestampProperty(default=lambda: NOW, precision='millisecond')), ('modified', TimestampProperty(default=lambda: NOW, precision='millisecond')), - ('description', StringProperty), + ('description', StringProperty()), ('authors', ListProperty(StringProperty)), ('object_refs', ListProperty(ReferenceProperty, required=True)), ('opinion', EnumProperty(allowed=[ diff --git a/stix2/utils.py b/stix2/utils.py index 8df4323..32aba72 100644 --- a/stix2/utils.py +++ b/stix2/utils.py @@ -87,7 +87,7 @@ def format_datetime(dttm): ms = zoned.strftime("%f") precision = getattr(dttm, "precision", None) if precision == 'second': - pass # Alredy precise to the second + pass # Already precise to the second elif precision == "millisecond": ts = ts + '.' + ms[:3] elif zoned.microsecond > 0: @@ -191,6 +191,10 @@ def find_property_index(obj, properties, tuple_to_find): tuple_to_find) if val is not None: return val + elif isinstance(item, dict) and tuple_to_find[0] in item: + for num, t in enumerate(item.keys(), start=1): + if t == tuple_to_find[0]: + return num def new_version(data, **kwargs):