Fixes #338
parent
380926cff5
commit
36f7035785
|
@ -8,42 +8,23 @@ import stix2.utils
|
|||
|
||||
COA_WITH_BIN_JSON = """{
|
||||
"type": "course-of-action",
|
||||
"spec_version": "2.1",
|
||||
"id": "course-of-action--8e2e2d2b-17d4-4cbf-938f-98ee46b3cd3f",
|
||||
"created_by_ref": "identity--311b2d2d-f010-4473-83ec-1edf84858f4c",
|
||||
"created": "2016-04-06T20:03:48.000Z",
|
||||
"modified": "2016-04-06T20:03:48.000Z",
|
||||
"name": "Add TCP port 80 Filter Rule to the existing Block UDP 1434 Filter",
|
||||
"description": "This is how to add a filter rule to block inbound access to TCP port 80 to the existing UDP 1434 filter ...",
|
||||
"action_type": "textual:text/plain",
|
||||
"os_execution_envs": [
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
],
|
||||
"action_bin": "aGVsbG8gd29ybGQ="
|
||||
"description": "This is how to add a filter rule to block inbound access to TCP port 80 to the existing UDP 1434 filter ..."
|
||||
}"""
|
||||
|
||||
|
||||
COA_WITH_REF_JSON = """{
|
||||
"type": "course-of-action",
|
||||
"spec_version": "2.1",
|
||||
"id": "course-of-action--8e2e2d2b-17d4-4cbf-938f-98ee46b3cd3f",
|
||||
"created_by_ref": "identity--311b2d2d-f010-4473-83ec-1edf84858f4c",
|
||||
"created": "2016-04-06T20:03:48.000Z",
|
||||
"modified": "2016-04-06T20:03:48.000Z",
|
||||
"name": "Add TCP port 80 Filter Rule to the existing Block UDP 1434 Filter",
|
||||
"description": "This is how to add a filter rule to block inbound access to TCP port 80 to the existing UDP 1434 filter ...",
|
||||
"action_type": "textual:text/plain",
|
||||
"os_execution_envs": [
|
||||
"a",
|
||||
"b",
|
||||
"c"
|
||||
],
|
||||
"action_reference": {
|
||||
"source_name": "a source",
|
||||
"description": "description of a source"
|
||||
}
|
||||
"description": "This is how to add a filter rule to block inbound access to TCP port 80 to the existing UDP 1434 filter ..."
|
||||
}"""
|
||||
|
||||
|
||||
|
@ -84,15 +65,4 @@ def test_parse_course_of_action(sdo_json, sdo_dict):
|
|||
assert getattr(coa, attr_name) == cmp_value
|
||||
|
||||
|
||||
def test_course_of_action_constraint():
|
||||
with pytest.raises(stix2.exceptions.MutuallyExclusivePropertiesError):
|
||||
stix2.v21.CourseOfAction(
|
||||
name="Add TCP port 80 Filter Rule to the existing Block UDP 1434 Filter",
|
||||
action_bin="aGVsbG8gd29ybGQ=",
|
||||
action_reference=stix2.v21.ExternalReference(
|
||||
source_name="a source",
|
||||
description="description of a source",
|
||||
),
|
||||
)
|
||||
|
||||
# TODO: Add other examples
|
||||
|
|
|
@ -13,10 +13,9 @@ from ..exceptions import (
|
|||
InvalidValueError, PropertyPresenceError, STIXDeprecationWarning,
|
||||
)
|
||||
from ..properties import (
|
||||
BinaryProperty, BooleanProperty, EmbeddedObjectProperty, EnumProperty,
|
||||
FloatProperty, IDProperty, IntegerProperty, ListProperty,
|
||||
ObservableProperty, PatternProperty, ReferenceProperty, StringProperty,
|
||||
TimestampProperty, TypeProperty,
|
||||
BooleanProperty, EnumProperty, FloatProperty, IDProperty, IntegerProperty,
|
||||
ListProperty, ObservableProperty, PatternProperty, ReferenceProperty,
|
||||
StringProperty, TimestampProperty, TypeProperty,
|
||||
)
|
||||
from ..utils import NOW
|
||||
from .common import ExternalReference, GranularMarking, KillChainPhase
|
||||
|
@ -99,23 +98,16 @@ class CourseOfAction(STIXDomainObject):
|
|||
_type = 'course-of-action'
|
||||
_properties = OrderedDict([
|
||||
('type', TypeProperty(_type)),
|
||||
('spec_version', StringProperty(fixed='2.1')),
|
||||
('id', IDProperty(_type, spec_version='2.1')),
|
||||
('created_by_ref', ReferenceProperty(valid_types='identity', spec_version='2.1')),
|
||||
('id', IDProperty(_type, spec_version='2.0')),
|
||||
('created_by_ref', ReferenceProperty(valid_types='identity', spec_version='2.0')),
|
||||
('created', TimestampProperty(default=lambda: NOW, precision='millisecond')),
|
||||
('modified', TimestampProperty(default=lambda: NOW, precision='millisecond')),
|
||||
('name', StringProperty(required=True)),
|
||||
('description', StringProperty()),
|
||||
('action_type', StringProperty()),
|
||||
('os_execution_envs', ListProperty(StringProperty)),
|
||||
('action_bin', BinaryProperty()),
|
||||
('action_reference', EmbeddedObjectProperty(ExternalReference)),
|
||||
('revoked', BooleanProperty(default=lambda: False)),
|
||||
('labels', ListProperty(StringProperty)),
|
||||
('confidence', IntegerProperty()),
|
||||
('lang', StringProperty()),
|
||||
('external_references', ListProperty(ExternalReference)),
|
||||
('object_marking_refs', ListProperty(ReferenceProperty(valid_types='marking-definition', spec_version='2.1'))),
|
||||
('object_marking_refs', ListProperty(ReferenceProperty(valid_types='marking-definition', spec_version='2.0'))),
|
||||
('granular_markings', ListProperty(GranularMarking)),
|
||||
])
|
||||
|
||||
|
|
Loading…
Reference in New Issue