Merge branch 'khdesai-fix_issue_338'; Close #347
commit
5abc139e79
|
@ -14,14 +14,7 @@ COA_WITH_BIN_JSON = """{
|
||||||
"created": "2016-04-06T20:03:48.000Z",
|
"created": "2016-04-06T20:03:48.000Z",
|
||||||
"modified": "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",
|
"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 ...",
|
"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="
|
|
||||||
}"""
|
}"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,17 +26,7 @@ COA_WITH_REF_JSON = """{
|
||||||
"created": "2016-04-06T20:03:48.000Z",
|
"created": "2016-04-06T20:03:48.000Z",
|
||||||
"modified": "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",
|
"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 ...",
|
"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"
|
|
||||||
}
|
|
||||||
}"""
|
}"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,15 +67,4 @@ def test_parse_course_of_action(sdo_json, sdo_dict):
|
||||||
assert getattr(coa, attr_name) == cmp_value
|
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
|
# TODO: Add other examples
|
||||||
|
|
|
@ -13,10 +13,9 @@ from ..exceptions import (
|
||||||
InvalidValueError, PropertyPresenceError, STIXDeprecationWarning,
|
InvalidValueError, PropertyPresenceError, STIXDeprecationWarning,
|
||||||
)
|
)
|
||||||
from ..properties import (
|
from ..properties import (
|
||||||
BinaryProperty, BooleanProperty, EmbeddedObjectProperty, EnumProperty,
|
BooleanProperty, EnumProperty, FloatProperty, IDProperty, IntegerProperty,
|
||||||
FloatProperty, IDProperty, IntegerProperty, ListProperty,
|
ListProperty, ObservableProperty, PatternProperty, ReferenceProperty,
|
||||||
ObservableProperty, PatternProperty, ReferenceProperty, StringProperty,
|
StringProperty, TimestampProperty, TypeProperty,
|
||||||
TimestampProperty, TypeProperty,
|
|
||||||
)
|
)
|
||||||
from ..utils import NOW
|
from ..utils import NOW
|
||||||
from .common import ExternalReference, GranularMarking, KillChainPhase
|
from .common import ExternalReference, GranularMarking, KillChainPhase
|
||||||
|
@ -106,10 +105,6 @@ class CourseOfAction(STIXDomainObject):
|
||||||
('modified', TimestampProperty(default=lambda: NOW, precision='millisecond')),
|
('modified', TimestampProperty(default=lambda: NOW, precision='millisecond')),
|
||||||
('name', StringProperty(required=True)),
|
('name', StringProperty(required=True)),
|
||||||
('description', StringProperty()),
|
('description', StringProperty()),
|
||||||
('action_type', StringProperty()),
|
|
||||||
('os_execution_envs', ListProperty(StringProperty)),
|
|
||||||
('action_bin', BinaryProperty()),
|
|
||||||
('action_reference', EmbeddedObjectProperty(ExternalReference)),
|
|
||||||
('revoked', BooleanProperty(default=lambda: False)),
|
('revoked', BooleanProperty(default=lambda: False)),
|
||||||
('labels', ListProperty(StringProperty)),
|
('labels', ListProperty(StringProperty)),
|
||||||
('confidence', IntegerProperty()),
|
('confidence', IntegerProperty()),
|
||||||
|
@ -119,14 +114,6 @@ class CourseOfAction(STIXDomainObject):
|
||||||
('granular_markings', ListProperty(GranularMarking)),
|
('granular_markings', ListProperty(GranularMarking)),
|
||||||
])
|
])
|
||||||
|
|
||||||
def _check_object_constraints(self):
|
|
||||||
super(CourseOfAction, self)._check_object_constraints()
|
|
||||||
|
|
||||||
self._check_mutually_exclusive_properties(
|
|
||||||
["action_bin", "action_reference"],
|
|
||||||
at_least_one=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Grouping(STIXDomainObject):
|
class Grouping(STIXDomainObject):
|
||||||
# TODO: Add link
|
# TODO: Add link
|
||||||
|
|
Loading…
Reference in New Issue