forked from microsoft/onefuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enums.py
330 lines (263 loc) · 8.36 KB
/
enums.py
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#!/usr/bin/env python
#
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from enum import Enum
from typing import List
class OS(Enum):
windows = "windows"
linux = "linux"
class DashboardEvent(Enum):
heartbeat = "heartbeat"
new_file = "new_file"
repro_state = "repro_state"
task_state = "task_state"
job_state = "job_state"
proxy_state = "proxy_state"
pool_state = "pool_state"
node_state = "node_state"
scaleset_state = "scaleset_state"
class TelemetryEvent(Enum):
task = "task"
state_changed = "state_changed"
@classmethod
def can_share(cls) -> List["TelemetryEvent"]:
""" only these events will be shared to the central telemetry """
return [cls.task, cls.state_changed]
class TelemetryData(Enum):
component_type = "component_type"
current_state = "current_state"
job_id = "job_id"
task_id = "task_id"
task_type = "task_type"
vm_id = "vm_id"
@classmethod
def can_share(cls) -> List["TelemetryData"]:
""" only these types of data will be shared to the central telemetry """
return [cls.current_state, cls.vm_id, cls.job_id, cls.task_id, cls.task_type]
class TaskFeature(Enum):
input_queue_from_container = "input_queue_from_container"
supervisor_exe = "supervisor_exe"
supervisor_env = "supervisor_env"
supervisor_options = "supervisor_options"
supervisor_input_marker = "supervisor_input_marker"
stats_file = "stats_file"
stats_format = "stats_format"
target_exe = "target_exe"
target_env = "target_env"
target_options = "target_options"
analyzer_exe = "analyzer_exe"
analyzer_env = "analyzer_env"
analyzer_options = "analyzer_options"
rename_output = "rename_output"
target_options_merge = "target_options_merge"
target_workers = "target_workers"
generator_exe = "generator_exe"
generator_env = "generator_env"
generator_options = "generator_options"
wait_for_files = "wait_for_files"
target_timeout = "target_timeout"
check_asan_log = "check_asan_log"
check_debugger = "check_debugger"
check_retry_count = "check_retry_count"
# Permissions for an Azure Blob Storage Container.
#
# See: https://docs.microsoft.com/en-us/rest/api/storageservices/create-service-sas#permissions-for-a-container # noqa: E501
class ContainerPermission(Enum):
Read = "Read"
Write = "Write"
Create = "Create"
List = "List"
Delete = "Delete"
Add = "Add"
class JobState(Enum):
init = "init"
enabled = "enabled"
stopping = "stopping"
stopped = "stopped"
@classmethod
def available(cls) -> List["JobState"]:
""" set of states that indicate if tasks can be added to it """
return [x for x in cls if x not in [cls.stopping, cls.stopped]]
@classmethod
def needs_work(cls) -> List["JobState"]:
"""
set of states that indicate work is needed during eventing
"""
return [cls.init, cls.stopping]
class TaskState(Enum):
init = "init"
waiting = "waiting"
scheduled = "scheduled"
setting_up = "setting_up"
running = "running"
stopping = "stopping"
stopped = "stopped"
wait_job = "wait_job"
@classmethod
def has_started(cls) -> List["TaskState"]:
return [cls.running, cls.stopping, cls.stopped]
@classmethod
def needs_work(cls) -> List["TaskState"]:
"""
set of states that indicate work is needed during eventing
"""
return [cls.init, cls.stopping]
@classmethod
def available(cls) -> List["TaskState"]:
""" set of states that indicate if the task isn't stopping """
return [x for x in cls if x not in [TaskState.stopping, TaskState.stopped]]
@classmethod
def shutting_down(cls) -> List["TaskState"]:
return [TaskState.stopping, TaskState.stopped]
class TaskType(Enum):
libfuzzer_fuzz = "libfuzzer_fuzz"
libfuzzer_coverage = "libfuzzer_coverage"
libfuzzer_crash_report = "libfuzzer_crash_report"
libfuzzer_merge = "libfuzzer_merge"
generic_analysis = "generic_analysis"
generic_supervisor = "generic_supervisor"
generic_merge = "generic_merge"
generic_generator = "generic_generator"
generic_crash_report = "generic_crash_report"
class VmState(Enum):
init = "init"
extensions_launch = "extensions_launch"
extensions_failed = "extensions_failed"
vm_allocation_failed = "vm_allocation_failed"
running = "running"
stopping = "stopping"
stopped = "stopped"
@classmethod
def needs_work(cls) -> List["VmState"]:
"""
set of states that indicate work is needed during eventing
"""
return [cls.init, cls.extensions_launch, cls.stopping]
@classmethod
def available(cls) -> List["VmState"]:
""" set of states that indicate if the repro vm isn't stopping """
return [x for x in cls if x not in [cls.stopping, cls.stopped]]
class UpdateType(Enum):
Task = "Task"
Job = "Job"
Repro = "Repro"
Proxy = "Proxy"
Pool = "Pool"
Node = "Node"
Scaleset = "Scaleset"
TaskScheduler = "TaskScheduler"
class Compare(Enum):
Equal = "Equal"
AtLeast = "AtLeast"
AtMost = "AtMost"
class ContainerType(Enum):
setup = "setup"
crashes = "crashes"
inputs = "inputs"
readonly_inputs = "readonly_inputs"
unique_inputs = "unique_inputs"
coverage = "coverage"
reports = "reports"
unique_reports = "unique_reports"
no_repro = "no_repro"
tools = "tools"
analysis = "analysis"
class StatsFormat(Enum):
AFL = "AFL"
class ErrorCode(Enum):
INVALID_REQUEST = 450
INVALID_PERMISSION = 451
MISSING_EULA_AGREEMENT = 452
INVALID_JOB = 453
INVALID_TASK = 453
UNABLE_TO_ADD_TASK_TO_JOB = 454
INVALID_CONTAINER = 455
UNABLE_TO_RESIZE = 456
UNAUTHORIZED = 457
UNABLE_TO_USE_STOPPED_JOB = 458
UNABLE_TO_CHANGE_JOB_DURATION = 459
UNABLE_TO_CREATE_NETWORK = 460
VM_CREATE_FAILED = 461
MISSING_NOTIFICATION = 462
INVALID_IMAGE = 463
UNABLE_TO_CREATE = 464
UNABLE_TO_PORT_FORWARD = 465
UNABLE_TO_FIND = 467
TASK_FAILED = 468
INVALID_NODE = 469
NOTIFICATION_FAILURE = 470
class HeartbeatType(Enum):
MachineAlive = "MachineAlive"
TaskAlive = "TaskAlive"
class PoolType(Enum):
managed = "managed"
unmanaged = "unmanaged"
class PoolState(Enum):
init = "init"
running = "running"
shutdown = "shutdown"
halt = "halt"
@classmethod
def needs_work(cls) -> List["PoolState"]:
"""
set of states that indicate work is needed during eventing
"""
return [cls.init, cls.shutdown, cls.halt]
@classmethod
def available(cls) -> List["PoolState"]:
""" set of states that indicate if it's available for work """
return [cls.init, cls.running]
class ScalesetState(Enum):
init = "init"
setup = "setup"
resize = "resize"
running = "running"
shutdown = "shutdown"
halt = "halt"
creation_failed = "creation_failed"
@classmethod
def needs_work(cls) -> List["ScalesetState"]:
"""
set of states that indicate work is needed during eventing
"""
return [cls.init, cls.setup, cls.resize, cls.shutdown, cls.halt]
@classmethod
def available(cls) -> List["ScalesetState"]:
""" set of states that indicate if it's available for work """
unavailable = [cls.shutdown, cls.halt, cls.creation_failed]
return [x for x in cls if x not in unavailable]
class Architecture(Enum):
x86_64 = "x86_64"
class NodeTaskState(Enum):
init = "init"
setting_up = "setting_up"
running = "running"
class AgentMode(Enum):
fuzz = "fuzz"
repro = "repro"
proxy = "proxy"
class NodeState(Enum):
init = "init"
free = "free"
setting_up = "setting_up"
rebooting = "rebooting"
ready = "ready"
busy = "busy"
done = "done"
shutdown = "shutdown"
halt = "halt"
@classmethod
def needs_work(cls) -> List["NodeState"]:
return [cls.done, cls.shutdown, cls.halt]
@classmethod
def ready_for_reset(cls) -> List["NodeState"]:
# If Node is in one of these states, ignore updates
# from the agent.
return [cls.done, cls.shutdown, cls.halt]
class GithubIssueState(Enum):
open = "open"
closed = "closed"
class GithubIssueSearchMatch(Enum):
title = "title"
body = "body"