MCPcopy
hub / github.com/apache/caldera / OperationSchema

Class OperationSchema

app/objects/c_operation.py:37–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36
37class OperationSchema(ma.Schema):
38
39 class Meta:
40 unknown = ma.EXCLUDE
41
42 id = ma.fields.String()
43 name = ma.fields.String(required=True)
44 host_group = ma.fields.List(ma.fields.Nested(AgentSchema()), attribute='agents', dump_only=True)
45 adversary = ma.fields.Nested(AdversarySchema())
46 jitter = ma.fields.String()
47 planner = ma.fields.Nested(PlannerSchema())
48 start = ma.fields.DateTime(format=BaseObject.TIME_FORMAT, dump_only=True)
49 state = ma.fields.String()
50 obfuscator = ma.fields.String()
51 autonomous = ma.fields.Integer()
52 chain = ma.fields.Function(lambda obj: [lnk.display for lnk in obj.chain])
53 auto_close = ma.fields.Boolean()
54 visibility = ma.fields.Integer()
55 objective = ma.fields.Nested(ObjectiveSchema())
56 use_learning_parsers = ma.fields.Boolean()
57 group = ma.fields.String(load_default='')
58 source = ma.fields.Nested(SourceSchema())
59
60 @ma.pre_load()
61 def remove_properties(self, data, **_):
62 data.pop('host_group', None)
63 data.pop('start', None)
64 data.pop('chain', None)
65 data.pop('objective', None)
66 return data
67
68 @ma.post_load
69 def build_operation(self, data, **kwargs):
70 return None if kwargs.get('partial') is True else Operation(**data)
71
72
73class HostSchema(ma.Schema):

Callers 7

ScheduleSchemaClass · 0.90
setup_operationMethod · 0.90
setup_finished_operationFunction · 0.90
setup_empty_operationFunction · 0.90
test_scheduleFunction · 0.90
OperationClass · 0.85

Calls 5

AgentSchemaClass · 0.90
AdversarySchemaClass · 0.90
PlannerSchemaClass · 0.90
ObjectiveSchemaClass · 0.90
SourceSchemaClass · 0.90

Tested by 4

setup_finished_operationFunction · 0.72
setup_empty_operationFunction · 0.72
test_scheduleFunction · 0.72