Fix `created` millisecond precision in TLPs
A marking definition's `created` property doesn't require millisecond preprecision, but for TLP markings the TLP instances provided in the spec must be used and they all use millisecond precision.stix2.0
parent
6613b55a43
commit
db300d1f21
|
@ -11,7 +11,7 @@ from .constants import MARKING_DEFINITION_ID
|
||||||
EXPECTED_TLP_MARKING_DEFINITION = """{
|
EXPECTED_TLP_MARKING_DEFINITION = """{
|
||||||
"type": "marking-definition",
|
"type": "marking-definition",
|
||||||
"id": "marking-definition--613f2e26-407d-48c7-9eca-b8e91df99dc9",
|
"id": "marking-definition--613f2e26-407d-48c7-9eca-b8e91df99dc9",
|
||||||
"created": "2017-01-20T00:00:00Z",
|
"created": "2017-01-20T00:00:00.000Z",
|
||||||
"definition_type": "tlp",
|
"definition_type": "tlp",
|
||||||
"definition": {
|
"definition": {
|
||||||
"tlp": "white"
|
"tlp": "white"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""STIX 2 Common Data Types and Properties."""
|
"""STIX 2 Common Data Types and Properties."""
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
import copy
|
||||||
|
|
||||||
from ..base import _cls_init, _STIXBase
|
from ..base import _cls_init, _STIXBase
|
||||||
from ..markings import _MarkingsMixin
|
from ..markings import _MarkingsMixin
|
||||||
|
@ -124,6 +125,13 @@ class MarkingDefinition(_STIXBase, _MarkingsMixin):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise ValueError("definition_type must be a valid marking type")
|
raise ValueError("definition_type must be a valid marking type")
|
||||||
|
|
||||||
|
if marking_type == TLPMarking:
|
||||||
|
# TLP instances in the spec have millisecond precision unlike other markings
|
||||||
|
self._properties = copy.deepcopy(self._properties)
|
||||||
|
self._properties.update([
|
||||||
|
('created', TimestampProperty(default=lambda: NOW, precision='millisecond')),
|
||||||
|
])
|
||||||
|
|
||||||
if not isinstance(kwargs['definition'], marking_type):
|
if not isinstance(kwargs['definition'], marking_type):
|
||||||
defn = _get_dict(kwargs['definition'])
|
defn = _get_dict(kwargs['definition'])
|
||||||
kwargs['definition'] = marking_type(**defn)
|
kwargs['definition'] = marking_type(**defn)
|
||||||
|
|
Loading…
Reference in New Issue