Add trailing commas for the pre-commit hook......
parent
19707677c9
commit
bf83ca62b3
|
@ -86,7 +86,7 @@ def _detect_spec_version(stix_dict):
|
||||||
"v21",
|
"v21",
|
||||||
max(
|
max(
|
||||||
_detect_spec_version(obj) for obj in stix_dict["objects"]
|
_detect_spec_version(obj) for obj in stix_dict["objects"]
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
elif obj_type in STIX2_OBJ_MAPS["v21"]["observables"]:
|
elif obj_type in STIX2_OBJ_MAPS["v21"]["observables"]:
|
||||||
# Non-bundle object with an ID and without spec_version. Could be a
|
# Non-bundle object with an ID and without spec_version. Could be a
|
||||||
|
|
|
@ -5,7 +5,8 @@ import pytest
|
||||||
from stix2.core import _detect_spec_version
|
from stix2.core import _detect_spec_version
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("obj_dict, expected_ver", [
|
@pytest.mark.parametrize(
|
||||||
|
"obj_dict, expected_ver", [
|
||||||
# STIX 2.0 examples
|
# STIX 2.0 examples
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
|
@ -14,7 +15,7 @@ from stix2.core import _detect_spec_version
|
||||||
"created": "1972-05-21T05:33:09.000Z",
|
"created": "1972-05-21T05:33:09.000Z",
|
||||||
"modified": "1973-05-28T02:10:54.000Z",
|
"modified": "1973-05-28T02:10:54.000Z",
|
||||||
"name": "alice",
|
"name": "alice",
|
||||||
"identity_class": "individual"
|
"identity_class": "individual",
|
||||||
},
|
},
|
||||||
"v20"
|
"v20"
|
||||||
),
|
),
|
||||||
|
@ -26,14 +27,14 @@ from stix2.core import _detect_spec_version
|
||||||
"modified": "2000-02-16T15:33:15.000Z",
|
"modified": "2000-02-16T15:33:15.000Z",
|
||||||
"source_ref": "attack-pattern--9391504a-ef29-4a41-a257-5634d9edc391",
|
"source_ref": "attack-pattern--9391504a-ef29-4a41-a257-5634d9edc391",
|
||||||
"target_ref": "identity--ba18dde2-56d3-4a34-aa0b-fc56f5be568f",
|
"target_ref": "identity--ba18dde2-56d3-4a34-aa0b-fc56f5be568f",
|
||||||
"relationship_type": "targets"
|
"relationship_type": "targets",
|
||||||
},
|
},
|
||||||
"v20"
|
"v20"
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"name": "notes.txt"
|
"name": "notes.txt",
|
||||||
},
|
},
|
||||||
"v20"
|
"v20"
|
||||||
),
|
),
|
||||||
|
@ -44,8 +45,8 @@ from stix2.core import _detect_spec_version
|
||||||
"created": "1998-03-27T19:44:53.000Z",
|
"created": "1998-03-27T19:44:53.000Z",
|
||||||
"definition_type": "statement",
|
"definition_type": "statement",
|
||||||
"definition": {
|
"definition": {
|
||||||
"statement": "Copyright (c) ACME Corp."
|
"statement": "Copyright (c) ACME Corp.",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
"v20"
|
"v20"
|
||||||
),
|
),
|
||||||
|
@ -61,7 +62,7 @@ from stix2.core import _detect_spec_version
|
||||||
"created": "1972-05-21T05:33:09.000Z",
|
"created": "1972-05-21T05:33:09.000Z",
|
||||||
"modified": "1973-05-28T02:10:54.000Z",
|
"modified": "1973-05-28T02:10:54.000Z",
|
||||||
"name": "alice",
|
"name": "alice",
|
||||||
"identity_class": "individual"
|
"identity_class": "individual",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "marking-definition",
|
"type": "marking-definition",
|
||||||
|
@ -69,10 +70,10 @@ from stix2.core import _detect_spec_version
|
||||||
"created": "1998-03-27T19:44:53.000Z",
|
"created": "1998-03-27T19:44:53.000Z",
|
||||||
"definition_type": "statement",
|
"definition_type": "statement",
|
||||||
"definition": {
|
"definition": {
|
||||||
"statement": "Copyright (c) ACME Corp."
|
"statement": "Copyright (c) ACME Corp.",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
"v20"
|
"v20"
|
||||||
),
|
),
|
||||||
|
@ -84,7 +85,7 @@ from stix2.core import _detect_spec_version
|
||||||
"spec_version": "2.1",
|
"spec_version": "2.1",
|
||||||
"created": "1995-07-24T04:07:48.000Z",
|
"created": "1995-07-24T04:07:48.000Z",
|
||||||
"modified": "2001-07-01T09:33:17.000Z",
|
"modified": "2001-07-01T09:33:17.000Z",
|
||||||
"name": "alice"
|
"name": "alice",
|
||||||
},
|
},
|
||||||
"v21"
|
"v21"
|
||||||
),
|
),
|
||||||
|
@ -97,7 +98,7 @@ from stix2.core import _detect_spec_version
|
||||||
"modified": "1983-04-25T20:56:00.000Z",
|
"modified": "1983-04-25T20:56:00.000Z",
|
||||||
"source_ref": "attack-pattern--9391504a-ef29-4a41-a257-5634d9edc391",
|
"source_ref": "attack-pattern--9391504a-ef29-4a41-a257-5634d9edc391",
|
||||||
"target_ref": "identity--ba18dde2-56d3-4a34-aa0b-fc56f5be568f",
|
"target_ref": "identity--ba18dde2-56d3-4a34-aa0b-fc56f5be568f",
|
||||||
"relationship_type": "targets"
|
"relationship_type": "targets",
|
||||||
},
|
},
|
||||||
"v21"
|
"v21"
|
||||||
),
|
),
|
||||||
|
@ -106,7 +107,7 @@ from stix2.core import _detect_spec_version
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
|
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
|
||||||
"spec_version": "2.1",
|
"spec_version": "2.1",
|
||||||
"name": "notes.txt"
|
"name": "notes.txt",
|
||||||
},
|
},
|
||||||
"v21"
|
"v21"
|
||||||
),
|
),
|
||||||
|
@ -114,7 +115,7 @@ from stix2.core import _detect_spec_version
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
|
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
|
||||||
"name": "notes.txt"
|
"name": "notes.txt",
|
||||||
},
|
},
|
||||||
"v21"
|
"v21"
|
||||||
),
|
),
|
||||||
|
@ -127,8 +128,8 @@ from stix2.core import _detect_spec_version
|
||||||
"definition_type": "tlp",
|
"definition_type": "tlp",
|
||||||
"name": "TLP:GREEN",
|
"name": "TLP:GREEN",
|
||||||
"definition": {
|
"definition": {
|
||||||
"tlp": "green"
|
"tlp": "green",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
"v21"
|
"v21"
|
||||||
),
|
),
|
||||||
|
@ -143,14 +144,14 @@ from stix2.core import _detect_spec_version
|
||||||
"spec_version": "2.1",
|
"spec_version": "2.1",
|
||||||
"created": "1995-07-24T04:07:48.000Z",
|
"created": "1995-07-24T04:07:48.000Z",
|
||||||
"modified": "2001-07-01T09:33:17.000Z",
|
"modified": "2001-07-01T09:33:17.000Z",
|
||||||
"name": "alice"
|
"name": "alice",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
|
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
|
||||||
"name": "notes.txt"
|
"name": "notes.txt",
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
"v21"
|
"v21"
|
||||||
),
|
),
|
||||||
|
@ -166,7 +167,7 @@ from stix2.core import _detect_spec_version
|
||||||
"created": "1972-05-21T05:33:09.000Z",
|
"created": "1972-05-21T05:33:09.000Z",
|
||||||
"modified": "1973-05-28T02:10:54.000Z",
|
"modified": "1973-05-28T02:10:54.000Z",
|
||||||
"name": "alice",
|
"name": "alice",
|
||||||
"identity_class": "individual"
|
"identity_class": "individual",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "relationship",
|
"type": "relationship",
|
||||||
|
@ -175,9 +176,9 @@ from stix2.core import _detect_spec_version
|
||||||
"modified": "2000-02-16T15:33:15.000Z",
|
"modified": "2000-02-16T15:33:15.000Z",
|
||||||
"source_ref": "attack-pattern--9391504a-ef29-4a41-a257-5634d9edc391",
|
"source_ref": "attack-pattern--9391504a-ef29-4a41-a257-5634d9edc391",
|
||||||
"target_ref": "identity--ba18dde2-56d3-4a34-aa0b-fc56f5be568f",
|
"target_ref": "identity--ba18dde2-56d3-4a34-aa0b-fc56f5be568f",
|
||||||
"relationship_type": "targets"
|
"relationship_type": "targets",
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
"v21"
|
"v21"
|
||||||
),
|
),
|
||||||
|
@ -192,18 +193,19 @@ from stix2.core import _detect_spec_version
|
||||||
"created": "1972-05-21T05:33:09.000Z",
|
"created": "1972-05-21T05:33:09.000Z",
|
||||||
"modified": "1973-05-28T02:10:54.000Z",
|
"modified": "1973-05-28T02:10:54.000Z",
|
||||||
"name": "alice",
|
"name": "alice",
|
||||||
"identity_class": "individual"
|
"identity_class": "individual",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
|
"id": "file--5eef3404-6a94-4db3-9a1a-5684cbea0dfe",
|
||||||
"name": "notes.txt"
|
"name": "notes.txt",
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
"v21"
|
"v21"
|
||||||
|
),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
])
|
|
||||||
def test_spec_version_detect(obj_dict, expected_ver):
|
def test_spec_version_detect(obj_dict, expected_ver):
|
||||||
detected_ver = _detect_spec_version(obj_dict)
|
detected_ver = _detect_spec_version(obj_dict)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue