-
Notifications
You must be signed in to change notification settings - Fork 33
/
constants.py
220 lines (199 loc) · 6.34 KB
/
constants.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
import enum
import os
from assemblyline.common.path import modulepath
SUBMISSION_QUEUE = 'dispatch-submission-queue'
DISPATCH_TASK_HASH = 'dispatch-active-submissions'
DISPATCH_RUNNING_TASK_HASH = 'dispatch-active-tasks'
SCALER_TIMEOUT_QUEUE = 'scaler-timeout-queue'
# Some pure functions for getting queue lengths (effectively for appending/prepending constants to strings)
def service_queue_name(service: str) -> str:
"""Take the name of a service, and provide the queue name to send tasks to that service."""
return 'service-queue-' + service
def make_watcher_list_name(sid: str) -> str:
"""Get the name of the list dispatcher will pull for sending out submission events."""
return 'dispatch-watcher-list-' + sid
def get_temporary_submission_data_name(sid: str, file_hash: str) -> str:
"""The HashMap used for tracking auxiliary processing data."""
return '/'.join((sid, file_hash, 'temp_data'))
def get_tag_set_name(sid: str, file_hash: str) -> str:
"""The HashSet used to track the tags for an in-process file."""
return '/'.join((sid, file_hash, 'tags'))
# A table storing information about the state of a service, expected type is ExpiringHash
# with a default ttl of None, and the ttl set per field based on the timeouts of queries
# and service operation
class ServiceStatus(enum.IntEnum):
Idle = 0
Running = 1
SERVICE_STATE_HASH = 'service-stasis-table'
# A null empty accepts, accepts all. A null rejects, rejects nothing
DEFAULT_SERVICE_ACCEPTS = ".*"
DEFAULT_SERVICE_REJECTS = "empty|metadata/.*"
# Queue priority values for each bucket in the ingester
PRIORITIES = {
'low': 100, # 0 -> 100
'medium': 200, # 101 -> 200
'high': 300,
'critical': 400,
'user-low': 500,
'user-medium': 1000,
'user-high': 1500
}
MAX_PRIORITY = 2000
# The above priority values presented as a range for consistency
PRIORITY_RANGES = {}
_start = -1
for _end, _level in sorted((val, key) for key, val in PRIORITIES.items()):
PRIORITY_RANGES[_level] = (_start + 1, _end)
_start = _end
# Score thresholds for determining which queue priority a reingested item
# gets based on its previous score.
# eg.: item with a previous score of 99 will get 'low' priority
# item with a previous score of 300 will get a 'high' priority
PRIORITY_THRESHOLDS = {
'critical': 500,
'high': 100,
}
RECOGNIZED_TYPES = {
'android/apk': True,
'android/dex': True,
'android/resource': True,
'android/xml': True,
'archive/7-zip': True,
'archive/ace': True,
'archive/ar': True,
'archive/audiovisual/flash': True,
'archive/bzip2': True,
'archive/cabinet': True,
'archive/cart': True,
'archive/chm': True,
'archive/cpio': True,
'archive/gzip': True,
'archive/iso': True,
'archive/lzma': True,
'archive/rar': True,
'archive/tar': True,
'archive/tnef': True,
'archive/unknown': True,
'archive/xz': True,
'archive/zip': True,
'audiovisual/afs': True,
'audiovisual/acb': True,
'audiovisual/flash': True,
'audiovisual/fsb': True,
'audiovisual/unknown': True,
'certificate/rsa': True,
'code/animation/ccb': True,
'code/autorun': True,
'code/batch': True,
'code/c': True,
'code/css': True,
'code/csharp': True,
'code/erlang': True,
'code/gles': True,
'code/glsl': True,
'code/go': True,
'code/hta': True,
'code/html': True,
'code/java': True,
'code/javascript': True,
'code/jscript': True,
'code/ida': True,
'code/lisp': True,
'code/nu': True,
'code/pdfjs': True,
'code/perl': True,
'code/php': True,
'code/ps1': True,
'code/python': True,
'code/ruby': True,
'code/rust': True,
'code/shell': True,
'code/sgml': True,
'code/sql': True,
'code/vbe': True,
'code/vbs': True,
'code/wsf': True,
'code/xml': True,
'db/dbf': True,
'db/sqlite': True,
'document/installer/windows': True,
'document/office/equation': True,
'document/office/excel': True,
'document/office/email': True,
'document/office/mhtml': True,
'document/office/paintbrush': True,
'document/office/package': True,
'document/office/powerpoint': True,
'document/office/passwordprotected': True,
'document/office/ole': True,
'document/office/onenote': True,
'document/office/rtf': True,
'document/office/unknown': True,
'document/office/visio': True,
'document/office/word': True,
'document/office/wordpro': True,
'document/office/wordperfect': True,
'document/email': True,
'document/pdf': True,
'document/unknown': True,
'executable/unknown': True,
'executable/mach-o': True,
'executable/windows/com': True,
'executable/windows/dos': True,
'executable/windows/pe': True,
'executable/windows/pe32': True,
'executable/windows/pe64': True,
'executable/windows/dll32': True,
'executable/windows/dll64': True,
'executable/linux/elf32': True,
'executable/linux/elf64': True,
'executable/linux/so32': True,
'executable/linux/so64': True,
'font/texture/pvr': True,
'image/bmp': True,
'image/gif': True,
'image/jpg': True,
'image/png': True,
'image/svg': True,
'image/texture/ka3d': True,
'image/texture/ktx': True,
'image/texture/pkm': True,
'image/texture/powervr': True,
'image/texture/rvio': True,
'image/unknown': True,
'ios/ipa': True,
'java/class': True,
'java/jar': True,
'java/java': True,
'java/jbdiff': True,
'java/manifest': True,
'java/signature': True,
'java/unknown': True,
'meta/torrent': True,
'meta/shortcut/windows': True,
'metadata/sysmon': True,
'network/sff': True,
'network/tcpdump': True,
'network/unknown': True,
'resource/big': True,
'resource/ccz': True,
'resource/cpk': True,
'resource/dz': True,
'resource/mo': True,
'resource/pak': True,
'resource/ptc': True,
'resource/sbm': True,
'resource/sbr': True,
'resource/sc': True,
'resource/unity': True,
'text/calendar': True,
'text/markdown': True,
'quarantine/ahnlab': True,
'quarantine/avast': True,
'quarantine/avira': True,
'quarantine/mcafee': True,
'quarantine/windowsdefender': True,
'unknown': True,
}
custom_rules = os.path.join(modulepath(__name__), 'custom.magic')
RULE_PATH = ':'.join((custom_rules, '/usr/share/file/magic.mgc'))