Minor changes
parent
be3e841ecb
commit
ef98c38937
|
@ -22,7 +22,8 @@
|
||||||
from . import exceptions
|
from . import exceptions
|
||||||
from .common import (TLP_AMBER, TLP_GREEN, TLP_RED, TLP_WHITE, CustomMarking,
|
from .common import (TLP_AMBER, TLP_GREEN, TLP_RED, TLP_WHITE, CustomMarking,
|
||||||
ExternalReference, GranularMarking, KillChainPhase,
|
ExternalReference, GranularMarking, KillChainPhase,
|
||||||
MarkingDefinition, StatementMarking, TLPMarking)
|
LanguageContent, MarkingDefinition, StatementMarking,
|
||||||
|
TLPMarking)
|
||||||
from .core import Bundle, _register_type, parse
|
from .core import Bundle, _register_type, parse
|
||||||
from .environment import Environment, ObjectFactory
|
from .environment import Environment, ObjectFactory
|
||||||
from .markings import (add_markings, clear_markings, get_markings, is_marked,
|
from .markings import (add_markings, clear_markings, get_markings, is_marked,
|
||||||
|
|
|
@ -41,7 +41,7 @@ class GranularMarking(_STIXBase):
|
||||||
_properties = OrderedDict()
|
_properties = OrderedDict()
|
||||||
_properties.update([
|
_properties.update([
|
||||||
('lang', StringProperty()),
|
('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)),
|
('selectors', ListProperty(SelectorProperty, required=True)),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ class GranularMarking(_STIXBase):
|
||||||
|
|
||||||
|
|
||||||
class LanguageContent(_STIXBase):
|
class LanguageContent(_STIXBase):
|
||||||
|
|
||||||
_type = 'language-content'
|
_type = 'language-content'
|
||||||
_properties = OrderedDict()
|
_properties = OrderedDict()
|
||||||
_properties.update([
|
_properties.update([
|
||||||
|
@ -61,7 +62,7 @@ class LanguageContent(_STIXBase):
|
||||||
('modified', TimestampProperty(default=lambda: NOW, precision='millisecond')),
|
('modified', TimestampProperty(default=lambda: NOW, precision='millisecond')),
|
||||||
('object_ref', ReferenceProperty(required=True)),
|
('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.
|
# 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
|
# TODO: 'contents' https://docs.google.com/document/d/1ShNq4c3e1CkfANmD9O--mdZ5H0O_GLnjN28a_yrEaco/edit#heading=h.cfz5hcantmvx
|
||||||
('contents', DictionaryProperty(required=True)),
|
('contents', DictionaryProperty(required=True)),
|
||||||
('revoked', BooleanProperty()),
|
('revoked', BooleanProperty()),
|
||||||
|
|
|
@ -460,7 +460,7 @@ class SocketExt(_Extension):
|
||||||
"SOCK_SEQPACKET",
|
"SOCK_SEQPACKET",
|
||||||
])),
|
])),
|
||||||
('socket_descriptor', IntegerProperty()),
|
('socket_descriptor', IntegerProperty()),
|
||||||
('socket_handle', IntegerProperty())
|
('socket_handle', IntegerProperty()),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -281,7 +281,7 @@ class Opinion(STIXDomainObject):
|
||||||
('created_by_ref', ReferenceProperty(type="identity")),
|
('created_by_ref', ReferenceProperty(type="identity")),
|
||||||
('created', TimestampProperty(default=lambda: NOW, precision='millisecond')),
|
('created', TimestampProperty(default=lambda: NOW, precision='millisecond')),
|
||||||
('modified', TimestampProperty(default=lambda: NOW, precision='millisecond')),
|
('modified', TimestampProperty(default=lambda: NOW, precision='millisecond')),
|
||||||
('description', StringProperty),
|
('description', StringProperty()),
|
||||||
('authors', ListProperty(StringProperty)),
|
('authors', ListProperty(StringProperty)),
|
||||||
('object_refs', ListProperty(ReferenceProperty, required=True)),
|
('object_refs', ListProperty(ReferenceProperty, required=True)),
|
||||||
('opinion', EnumProperty(allowed=[
|
('opinion', EnumProperty(allowed=[
|
||||||
|
|
|
@ -87,7 +87,7 @@ def format_datetime(dttm):
|
||||||
ms = zoned.strftime("%f")
|
ms = zoned.strftime("%f")
|
||||||
precision = getattr(dttm, "precision", None)
|
precision = getattr(dttm, "precision", None)
|
||||||
if precision == 'second':
|
if precision == 'second':
|
||||||
pass # Alredy precise to the second
|
pass # Already precise to the second
|
||||||
elif precision == "millisecond":
|
elif precision == "millisecond":
|
||||||
ts = ts + '.' + ms[:3]
|
ts = ts + '.' + ms[:3]
|
||||||
elif zoned.microsecond > 0:
|
elif zoned.microsecond > 0:
|
||||||
|
@ -191,6 +191,10 @@ def find_property_index(obj, properties, tuple_to_find):
|
||||||
tuple_to_find)
|
tuple_to_find)
|
||||||
if val is not None:
|
if val is not None:
|
||||||
return val
|
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):
|
def new_version(data, **kwargs):
|
||||||
|
|
Loading…
Reference in New Issue