Skip to content

Commit

Permalink
fix class definitions to use embedded object property
Browse files Browse the repository at this point in the history
  • Loading branch information
rpiazza committed Apr 7, 2024
1 parent 708e132 commit 634d803
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
15 changes: 7 additions & 8 deletions incident-ef7/src/incident/event.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from collections import OrderedDict

import stix2
from stix2.exceptions import ObjectConfigurationError
from stix2.properties import (BooleanProperty, EnumProperty, ListProperty,
OpenVocabProperty, ReferenceProperty,
StringProperty, TimestampProperty)
from stix2.v21.base import _STIXBase21
from stix2.properties import (BooleanProperty, EnumProperty, EmbeddedObjectProperty,
IntegerProperty, ListProperty, OpenVocabProperty,
ReferenceProperty, StringProperty,
TimestampProperty)

import incident.vocab as vocab
from incident.common import StateChange
Expand All @@ -29,7 +28,7 @@ class EventEntry(_STIXBase21):
# required properties
('event_ref', ReferenceProperty(valid_types='event', required=True)),
# optional properties
('next_steps', ListProperty(EventSequenceEntry)),
('next_steps', ListProperty(EmbeddedObjectProperty(EventSequenceEntry))),
('sequence_start', BooleanProperty(default=lambda: True))
])

Expand All @@ -40,7 +39,7 @@ class EventEntry(_STIXBase21):
# required properties
('status', EnumProperty(vocab.EVENT_STATUS, required=True)),
# optional properties
('changed_objects', ListProperty(StateChange)),
('changed_objects', ListProperty(EmbeddedObjectProperty(StateChange))),
('description', StringProperty()),
('end_time', TimestampProperty()),
('end_time_fidelity', EnumProperty(vocab.TIMESTAMP_FIDELITY)),
Expand All @@ -50,7 +49,7 @@ class EventEntry(_STIXBase21):
('sighting_refs', ListProperty(ReferenceProperty(valid_types='sighting'))),
('start_time', TimestampProperty()),
('start_time_fidelity', EnumProperty(vocab.TIMESTAMP_FIDELITY)),
('subevents', ListProperty(EventEntry)),
('subevents', ListProperty(EmbeddedObjectProperty(EventEntry))),
],
EVENT_EXTENSION_DEFINITION_ID
)
Expand Down
8 changes: 4 additions & 4 deletions incident-ef7/src/incident/incident.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import OrderedDict

import stix2
from stix2.properties import (EnumProperty, FloatProperty, IntegerProperty,
from stix2.properties import (EmbeddedObjectProperty, EnumProperty, FloatProperty, IntegerProperty,
ListProperty, OpenVocabProperty,
ReferenceProperty, StringProperty)
from stix2.v21.base import _STIXBase21
Expand Down Expand Up @@ -32,13 +32,13 @@ class IncidentScore(_STIXBase21):
# optional properties
('criticality', IntegerProperty(min=0, max=100)),
('detection_methods', ListProperty(OpenVocabProperty(vocab.DETECTION_METHODS))),
('events', ListProperty(EventEntry)),
('events', ListProperty(EmbeddedObjectProperty(EventEntry))),
('impact_refs', ListProperty(ReferenceProperty(valid_types='impact'))),
('impacted_entity_counts', EntityCountProperty(spec_version='2.1')),
('incident_types', ListProperty(OpenVocabProperty(vocab.EVENT_TYPE))),
('recoverability', EnumProperty(vocab.RECOVERABILITY)),
('scores', ListProperty(IncidentScore)),
('tasks', ListProperty(TaskEntry)),
('scores', ListProperty(EmbeddedObjectProperty(IncidentScore))),
('tasks', ListProperty(EmbeddedObjectProperty(TaskEntry))),
],
)
class IncidentExtension:
Expand Down
10 changes: 5 additions & 5 deletions incident-ef7/src/incident/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import stix2
from stix2.exceptions import ObjectConfigurationError
from stix2.properties import (BooleanProperty, EnumProperty, IntegerProperty,
ListProperty, OpenVocabProperty,
from stix2.properties import (BooleanProperty, EnumProperty, EmbeddedObjectProperty,
IntegerProperty, ListProperty, OpenVocabProperty,
ReferenceProperty, StringProperty,
TimestampProperty)
from stix2.v21 import _STIXBase21
Expand All @@ -30,7 +30,7 @@ class TaskEntry(_STIXBase21):
# required properties
('task_ref', ReferenceProperty(valid_types='task', required=True)),
# optional properties
('next_steps', ListProperty(TaskSequenceEntry)),
('next_steps', ListProperty(EmbeddedObjectProperty(TaskSequenceEntry))),
('sequence_start', BooleanProperty(default=lambda: True))
])

Expand All @@ -41,7 +41,7 @@ class TaskEntry(_STIXBase21):
# required properties
('outcome', EnumProperty(vocab.TASK_OUTCOME, required=True)),
# optional properties
('changed_objects', ListProperty(StateChange)),
('changed_objects', ListProperty(EmbeddedObjectProperty(StateChange))),
('task_types', ListProperty(OpenVocabProperty(vocab.TASK_TYPE))),
('description', StringProperty()),
('end_time', TimestampProperty()),
Expand All @@ -52,7 +52,7 @@ class TaskEntry(_STIXBase21):
('priority', IntegerProperty(min=0, max=100)),
('start_time', TimestampProperty()),
('start_time_fidelity', EnumProperty(vocab.TIMESTAMP_FIDELITY)),
('subtasks', ListProperty(TaskEntry))
('subtasks', ListProperty(EmbeddedObjectProperty(TaskEntry)))
],
TASK_EXTENSION_DEFINITION_ID
)
Expand Down

0 comments on commit 634d803

Please sign in to comment.