-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
267 lines (236 loc) · 5.69 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import { boolean } from "yargs"
// set defaults
export const DEFAULT_PORT = 3000;
export type ComponentInstance = {
name: string,
startState?: string,
startStateGenerator?: string,
startStateArgs?: object,
}
export type DebugFrontendInfos = {
portToOpenHost?: number,
portToOpenContainer?: number,
// todo: change to deviceName to be consistent
hostName?: string,
pinnedNodePort?: PinnedNodePort,
}
export type Port = {
name: string,
eventTypes: string[],
direction: "in" | "out"
}
export type ComponentInfo = {
name: string,
ports: Port[],
tsType: "Component"
}
export enum conn_protocol {
REST = 'REST',
MQTT = 'MQTT',
MQTT_EXTERNAL = 'MQTT_EXTERNAL',
BLUETOOTH = 'BLUETOOTH',
TOM = 'TOM',
ON_UNIT = 'ON_UNIT',
}
export enum availableHpNames {
cowrie = 'cowrie',
honeyku = 'honeyku',
log4pot = 'log4pot',
}
export type Connection = {
sourceComponent: string,
sourcePort: string,
targetComponent: string,
targetPort: string,
}
export type Data = {
setupInfo: {
components: {
[key: string]: ComponentInfo,
},
startStates?: {
[key: string]: {
state: any,
events: any[],
tsType: "State"
}
},
stateGenerators?: Map<string,object>
},
componentInstances: Record<string, ComponentInstance[]>,
connections: Connection[],
units: Unit[],
devices: Device[],
resilienceInfo: ResilienceInfo,
securityConfig: SecConfig,
extToolsConfig: ExtToolsConfig,
npmConfig: NpmConfig,
degradationInfo: DegradationInfo,
migrationStatus: MigrationStatus,
debuggingConfiguration: DebuggingConfiguration
}
export enum MigrationType {
stateful = "stateful",
stateless = "stateless",
}
export type MigrationFields = {
migrationType:MigrationType,
unit: string,
fromDevice: string,
toDevice: string
}
export interface CheckPointRecoveryErrors {
unitNameUnique: boolean,
hasCheckPointing: boolean,
}
export type MigrationStatus = {
history: MigrationFields[],
pending: MigrationFields[],
finalizing: MigrationFields[],
}
export type DebuggingConfiguration = {
[unit: string]: {
debuggingAgent: {
enabled: boolean,
isServer: boolean,
webSocketPort: number,
checkForChangesIntervalMs: number,
}
}
}
export type Device = {
deviceName: string,
// todo: enum
architecture: string,
// todo: elems -> enum
protocols: conn_protocol[],
location: string,
units: string[],
}
export interface ComponentInstanceExtended {
type?: ComponentInfo,
instance?: ComponentInstance,
}
export type UnitConnection = {
componentOnUnit?: string,
sourceComponent: string,
sourcePort: string,
targetComponent: string,
targetPort: string,
protocol: conn_protocol
}
export type ShadowModeConfig = {
shadowAgent?: {
enabled: boolean,
commOptions: conn_protocol[],
autoUpdate: {
intervalSeconds: number,
strategy: string,
limit: number,
content: string
}
},
inMessageSharing?: {
enabled: boolean,
limit: number,
content: string
}
}
export type PinnedNodePort = {
portNumber: number,
type: string,
}
export type Unit = {
id: string,
components: ComponentInstanceExtended[],
unitConnections: UnitConnection[],
shadowModeConfig: ShadowModeConfig,
pinnedNodePort?: PinnedNodePort,
}
export type ActiveReplication = {
activeReplication: {
faultModel: string,
n: number,
f: number,
enabled: boolean,
executionSites: string [],
}
}
export type CheckPointRecovery = {
checkpointRecovery: {
recovery: {
enabled: boolean,
},
checkpoint: {
enabled: boolean,
},
}
}
type ResilienceInfoComponent = {
id: string,
mechanisms: ActiveReplication | CheckPointRecovery
}
type CommunicationSecretDirection = {
from: string,
to: string,
}
export type ResilienceInfo = {
resilienceLibraryPath: string,
components: ResilienceInfoComponent[]
}
export type DegradationInfo = {
degradation?: boolean,
degradationFileName?: string,
}
export type SecConfig = {
ssl?: boolean,
communicationSecret: CommunicationSecretDirection[]
}
export type HoneyPotConfig = {
hpName:string,
portToOpenHost:number,
portToOpenContainer:number,
// todo: change to deviceName to be consistent
hostName:string
}
export type ExtToolsConfig = {
honeyPots?: HoneyPotConfig[],
useIds?: boolean,
debugFrontendInfos?: DebugFrontendInfos
// todo: intrusion_det
}
export type NpmConfig = {
startScriptName: string
}
//todo: das hier final typsicher machen und Bezeichner anpassen/erweitern/reduzieren
export type ConfigurationOutput = {
//naming anpassen
elements: [{
deviceName: string,
id: string,
architecture: string,
protocols: string[],
location: string,
units: {
id: string,
components: {
type: string,
id: string,
ports: {
name: string,
eventTypes: string[],
direction: "in" | "out"
}[]
}[]
}
}],
resilienceLibrary: {
directoryPath: string,
},
resilienceConfiguration: {
components: ResilienceInfoComponent[]
} | {},
SecurityConfiguration: SecConfig | {},
ExtToolsConfiguration: ExtToolsConfig | {},
NpmConfiguration: NpmConfig,
}