prelude-sdk-beta 1406__py3-none-any.whl → 1407__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of prelude-sdk-beta might be problematic. Click here for more details.
- prelude_sdk_beta/controllers/build_controller.py +8 -2
- prelude_sdk_beta/controllers/detect_controller.py +17 -4
- prelude_sdk_beta/controllers/http_controller.py +20 -0
- prelude_sdk_beta/controllers/iam_controller.py +11 -4
- prelude_sdk_beta/controllers/jobs_controller.py +13 -2
- prelude_sdk_beta/controllers/scm_controller.py +159 -15
- prelude_sdk_beta/models/account.py +6 -1
- prelude_sdk_beta/models/codes.py +89 -14
- {prelude_sdk_beta-1406.dist-info → prelude_sdk_beta-1407.dist-info}/METADATA +1 -1
- prelude_sdk_beta-1407.dist-info/RECORD +20 -0
- prelude_sdk_beta-1406.dist-info/RECORD +0 -20
- {prelude_sdk_beta-1406.dist-info → prelude_sdk_beta-1407.dist-info}/WHEEL +0 -0
- {prelude_sdk_beta-1406.dist-info → prelude_sdk_beta-1407.dist-info}/licenses/LICENSE +0 -0
- {prelude_sdk_beta-1406.dist-info → prelude_sdk_beta-1407.dist-info}/top_level.txt +0 -0
|
@@ -271,7 +271,10 @@ class BuildController(HttpController):
|
|
|
271
271
|
headers=self.account.headers,
|
|
272
272
|
timeout=10,
|
|
273
273
|
)
|
|
274
|
-
|
|
274
|
+
threat_hunt = res.json()
|
|
275
|
+
if self.account.resolve_enums:
|
|
276
|
+
self.resolve_enums(threat_hunt, [(Control, "control")])
|
|
277
|
+
return threat_hunt
|
|
275
278
|
|
|
276
279
|
@verify_credentials
|
|
277
280
|
def update_threat_hunt(
|
|
@@ -296,7 +299,10 @@ class BuildController(HttpController):
|
|
|
296
299
|
headers=self.account.headers,
|
|
297
300
|
timeout=10,
|
|
298
301
|
)
|
|
299
|
-
|
|
302
|
+
threat_hunt = res.json()
|
|
303
|
+
if self.account.resolve_enums:
|
|
304
|
+
self.resolve_enums(threat_hunt, [(Control, "control")])
|
|
305
|
+
return threat_hunt
|
|
300
306
|
|
|
301
307
|
@verify_credentials
|
|
302
308
|
def delete_threat_hunt(self, threat_hunt_id: str):
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from prelude_sdk_beta.controllers.http_controller import HttpController
|
|
2
2
|
from prelude_sdk_beta.models.account import verify_credentials
|
|
3
|
+
from prelude_sdk_beta.models.codes import Control, RunCode
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
class DetectController(HttpController):
|
|
@@ -59,7 +60,10 @@ class DetectController(HttpController):
|
|
|
59
60
|
params=params,
|
|
60
61
|
timeout=10,
|
|
61
62
|
)
|
|
62
|
-
|
|
63
|
+
endpoints = res.json()
|
|
64
|
+
if self.account.resolve_enums:
|
|
65
|
+
self.resolve_enums(endpoints, [(Control, "control")])
|
|
66
|
+
return endpoints
|
|
63
67
|
|
|
64
68
|
@verify_credentials
|
|
65
69
|
def describe_activity(self, filters: dict, view: str = "protected"):
|
|
@@ -169,7 +173,10 @@ class DetectController(HttpController):
|
|
|
169
173
|
params=filters if filters else {},
|
|
170
174
|
timeout=10,
|
|
171
175
|
)
|
|
172
|
-
|
|
176
|
+
threat_hunts = res.json()
|
|
177
|
+
if self.account.resolve_enums:
|
|
178
|
+
self.resolve_enums(threat_hunts, [(Control, "control")])
|
|
179
|
+
return threat_hunts
|
|
173
180
|
|
|
174
181
|
@verify_credentials
|
|
175
182
|
def get_threat_hunt(self, threat_hunt_id):
|
|
@@ -179,7 +186,10 @@ class DetectController(HttpController):
|
|
|
179
186
|
headers=self.account.headers,
|
|
180
187
|
timeout=10,
|
|
181
188
|
)
|
|
182
|
-
|
|
189
|
+
threat_hunt = res.json()
|
|
190
|
+
if self.account.resolve_enums:
|
|
191
|
+
self.resolve_enums(threat_hunt, [(Control, "control")])
|
|
192
|
+
return threat_hunt
|
|
183
193
|
|
|
184
194
|
@verify_credentials
|
|
185
195
|
def do_threat_hunt(self, threat_hunt_id):
|
|
@@ -214,7 +224,10 @@ class DetectController(HttpController):
|
|
|
214
224
|
json=dict(items=items),
|
|
215
225
|
timeout=10,
|
|
216
226
|
)
|
|
217
|
-
|
|
227
|
+
schedule = res.json()
|
|
228
|
+
if self.account.resolve_enums:
|
|
229
|
+
self.resolve_enums(schedule, [(RunCode, "run_code")])
|
|
230
|
+
return schedule
|
|
218
231
|
|
|
219
232
|
@verify_credentials
|
|
220
233
|
def unschedule(self, items: list):
|
|
@@ -22,6 +22,26 @@ class HttpController(object):
|
|
|
22
22
|
self._session.mount("http://", HTTPAdapter(max_retries=retry))
|
|
23
23
|
self._session.mount("https://", HTTPAdapter(max_retries=retry))
|
|
24
24
|
|
|
25
|
+
def resolve_enums(self, data, enum_params: list[tuple]):
|
|
26
|
+
for [enum_class, key] in enum_params:
|
|
27
|
+
self._resolve_enum(data, enum_class, key)
|
|
28
|
+
|
|
29
|
+
def _resolve_enum(self, data, enum_class, key):
|
|
30
|
+
if isinstance(data, list):
|
|
31
|
+
for item in data:
|
|
32
|
+
if isinstance(item, dict):
|
|
33
|
+
self._resolve_enum(item, enum_class, key)
|
|
34
|
+
elif isinstance(data, dict):
|
|
35
|
+
for k, v in data.items():
|
|
36
|
+
if k == key:
|
|
37
|
+
if isinstance(v, list):
|
|
38
|
+
for i, item in enumerate(v):
|
|
39
|
+
v[i] = enum_class[item].name
|
|
40
|
+
elif v is not None:
|
|
41
|
+
data[k] = enum_class[v].name
|
|
42
|
+
elif isinstance(v, dict) or isinstance(v, list):
|
|
43
|
+
self._resolve_enum(v, enum_class, key)
|
|
44
|
+
|
|
25
45
|
def get(self, url, retry=True, **kwargs):
|
|
26
46
|
res = self._session.get(url, **kwargs)
|
|
27
47
|
if res.status_code == 200:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from prelude_sdk_beta.controllers.http_controller import HttpController
|
|
2
2
|
from prelude_sdk_beta.models.account import verify_credentials
|
|
3
|
-
from prelude_sdk_beta.models.codes import Mode, Permission
|
|
3
|
+
from prelude_sdk_beta.models.codes import Control, Mode, Permission
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class IAMAccountController(HttpController):
|
|
@@ -14,7 +14,12 @@ class IAMAccountController(HttpController):
|
|
|
14
14
|
res = self.get(
|
|
15
15
|
f"{self.account.hq}/iam/account", headers=self.account.headers, timeout=10
|
|
16
16
|
)
|
|
17
|
-
|
|
17
|
+
account = res.json()
|
|
18
|
+
if self.account.resolve_enums:
|
|
19
|
+
self.resolve_enums(
|
|
20
|
+
account, [(Mode, "mode"), (Permission, "permission"), (Control, "id")]
|
|
21
|
+
)
|
|
22
|
+
return account
|
|
18
23
|
|
|
19
24
|
@verify_credentials
|
|
20
25
|
def purge_account(self):
|
|
@@ -100,7 +105,10 @@ class IAMAccountController(HttpController):
|
|
|
100
105
|
headers=self.account.headers,
|
|
101
106
|
timeout=10,
|
|
102
107
|
)
|
|
103
|
-
|
|
108
|
+
user = res.json()
|
|
109
|
+
if self.account.resolve_enums:
|
|
110
|
+
self.resolve_enums(user, [(Permission, "permission")])
|
|
111
|
+
return user
|
|
104
112
|
|
|
105
113
|
@verify_credentials
|
|
106
114
|
def create_service_user(self, name: str):
|
|
@@ -173,7 +181,6 @@ class IAMAccountController(HttpController):
|
|
|
173
181
|
)
|
|
174
182
|
return res.json()
|
|
175
183
|
|
|
176
|
-
|
|
177
184
|
def sign_up(self, company, email, name):
|
|
178
185
|
"""(NOT AVAIABLE IN PRODUCTION) Create a new user and account"""
|
|
179
186
|
body = dict(company=company, email=email, name=name)
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
from itertools import chain
|
|
2
|
+
|
|
1
3
|
from prelude_sdk_beta.controllers.http_controller import HttpController
|
|
2
4
|
from prelude_sdk_beta.models.account import verify_credentials
|
|
5
|
+
from prelude_sdk_beta.models.codes import BackgroundJobTypes, Control
|
|
3
6
|
|
|
4
7
|
|
|
5
8
|
class JobsController(HttpController):
|
|
@@ -13,7 +16,10 @@ class JobsController(HttpController):
|
|
|
13
16
|
res = self.get(
|
|
14
17
|
f"{self.account.hq}/jobs/statuses", headers=self.account.headers, timeout=30
|
|
15
18
|
)
|
|
16
|
-
|
|
19
|
+
jobs = res.json()
|
|
20
|
+
if self.account.resolve_enums:
|
|
21
|
+
self.resolve_enums(jobs, [(Control, "control")])
|
|
22
|
+
return jobs
|
|
17
23
|
|
|
18
24
|
@verify_credentials
|
|
19
25
|
def job_status(self, job_id: str):
|
|
@@ -23,4 +29,9 @@ class JobsController(HttpController):
|
|
|
23
29
|
headers=self.account.headers,
|
|
24
30
|
timeout=30,
|
|
25
31
|
)
|
|
26
|
-
|
|
32
|
+
job = res.json()
|
|
33
|
+
if self.account.resolve_enums:
|
|
34
|
+
self.resolve_enums(
|
|
35
|
+
job, [(Control, "control"), (BackgroundJobTypes, "job_type")]
|
|
36
|
+
)
|
|
37
|
+
return job
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
from prelude_sdk_beta.controllers.http_controller import HttpController
|
|
2
2
|
from prelude_sdk_beta.models.account import verify_credentials
|
|
3
|
-
from prelude_sdk_beta.models.codes import
|
|
3
|
+
from prelude_sdk_beta.models.codes import (
|
|
4
|
+
Control,
|
|
5
|
+
ControlCategory,
|
|
6
|
+
PartnerEvents,
|
|
7
|
+
PolicyType,
|
|
8
|
+
NotationType,
|
|
9
|
+
RunCode,
|
|
10
|
+
)
|
|
4
11
|
|
|
5
12
|
|
|
6
13
|
class ScmController(HttpController):
|
|
7
|
-
default = -1
|
|
14
|
+
default = "-1"
|
|
8
15
|
|
|
9
16
|
def __init__(self, account):
|
|
10
17
|
super().__init__(account)
|
|
@@ -19,7 +26,18 @@ class ScmController(HttpController):
|
|
|
19
26
|
params=params,
|
|
20
27
|
timeout=30,
|
|
21
28
|
)
|
|
22
|
-
|
|
29
|
+
data = res.json()
|
|
30
|
+
if self.account.resolve_enums:
|
|
31
|
+
self.resolve_enums(
|
|
32
|
+
data,
|
|
33
|
+
[
|
|
34
|
+
(Control, "controls"),
|
|
35
|
+
(Control, "control"),
|
|
36
|
+
(ControlCategory, "category"),
|
|
37
|
+
(PartnerEvents, "event"),
|
|
38
|
+
],
|
|
39
|
+
)
|
|
40
|
+
return data
|
|
23
41
|
|
|
24
42
|
@verify_credentials
|
|
25
43
|
def inboxes(self, filter: str = None, orderby: str = None, top: int = None):
|
|
@@ -31,7 +49,18 @@ class ScmController(HttpController):
|
|
|
31
49
|
params=params,
|
|
32
50
|
timeout=30,
|
|
33
51
|
)
|
|
34
|
-
|
|
52
|
+
data = res.json()
|
|
53
|
+
if self.account.resolve_enums:
|
|
54
|
+
self.resolve_enums(
|
|
55
|
+
data,
|
|
56
|
+
[
|
|
57
|
+
(Control, "controls"),
|
|
58
|
+
(Control, "control"),
|
|
59
|
+
(ControlCategory, "category"),
|
|
60
|
+
(PartnerEvents, "event"),
|
|
61
|
+
],
|
|
62
|
+
)
|
|
63
|
+
return data
|
|
35
64
|
|
|
36
65
|
@verify_credentials
|
|
37
66
|
def users(self, filter: str = None, orderby: str = None, top: int = None):
|
|
@@ -43,7 +72,18 @@ class ScmController(HttpController):
|
|
|
43
72
|
params=params,
|
|
44
73
|
timeout=30,
|
|
45
74
|
)
|
|
46
|
-
|
|
75
|
+
data = res.json()
|
|
76
|
+
if self.account.resolve_enums:
|
|
77
|
+
self.resolve_enums(
|
|
78
|
+
data,
|
|
79
|
+
[
|
|
80
|
+
(Control, "controls"),
|
|
81
|
+
(Control, "control"),
|
|
82
|
+
(ControlCategory, "category"),
|
|
83
|
+
(PartnerEvents, "event"),
|
|
84
|
+
],
|
|
85
|
+
)
|
|
86
|
+
return data
|
|
47
87
|
|
|
48
88
|
@verify_credentials
|
|
49
89
|
def technique_summary(self, techniques: str):
|
|
@@ -78,7 +118,12 @@ class ScmController(HttpController):
|
|
|
78
118
|
headers=self.account.headers,
|
|
79
119
|
timeout=30,
|
|
80
120
|
)
|
|
81
|
-
|
|
121
|
+
data = res.json()
|
|
122
|
+
if self.account.resolve_enums:
|
|
123
|
+
self.resolve_enums(
|
|
124
|
+
data, [(Control, "control"), (ControlCategory, "category")]
|
|
125
|
+
)
|
|
126
|
+
return data
|
|
82
127
|
|
|
83
128
|
@verify_credentials
|
|
84
129
|
def evaluation(
|
|
@@ -98,7 +143,10 @@ class ScmController(HttpController):
|
|
|
98
143
|
headers=self.account.headers,
|
|
99
144
|
timeout=30,
|
|
100
145
|
)
|
|
101
|
-
|
|
146
|
+
data = res.json()
|
|
147
|
+
if self.account.resolve_enums:
|
|
148
|
+
self.resolve_enums(data, [(PolicyType, "policy_type")])
|
|
149
|
+
return data
|
|
102
150
|
|
|
103
151
|
@verify_credentials
|
|
104
152
|
def update_evaluation(self, partner: Control, instance_id: str):
|
|
@@ -120,7 +168,10 @@ class ScmController(HttpController):
|
|
|
120
168
|
params=params,
|
|
121
169
|
timeout=10,
|
|
122
170
|
)
|
|
123
|
-
|
|
171
|
+
groups = res.json()
|
|
172
|
+
if self.account.resolve_enums:
|
|
173
|
+
self.resolve_enums(groups, [(Control, "control")])
|
|
174
|
+
return groups
|
|
124
175
|
|
|
125
176
|
@verify_credentials
|
|
126
177
|
def update_partner_groups(
|
|
@@ -144,7 +195,10 @@ class ScmController(HttpController):
|
|
|
144
195
|
headers=self.account.headers,
|
|
145
196
|
timeout=10,
|
|
146
197
|
)
|
|
147
|
-
|
|
198
|
+
exceptions = res.json()
|
|
199
|
+
if self.account.resolve_enums:
|
|
200
|
+
self.resolve_enums(exceptions, [(ControlCategory, "category")])
|
|
201
|
+
return exceptions
|
|
148
202
|
|
|
149
203
|
@verify_credentials
|
|
150
204
|
def create_object_exception(
|
|
@@ -202,13 +256,18 @@ class ScmController(HttpController):
|
|
|
202
256
|
headers=self.account.headers,
|
|
203
257
|
timeout=10,
|
|
204
258
|
)
|
|
205
|
-
|
|
259
|
+
exceptions = res.json()
|
|
260
|
+
if self.account.resolve_enums:
|
|
261
|
+
self.resolve_enums(
|
|
262
|
+
exceptions, [(Control, "control"), (ControlCategory, "category")]
|
|
263
|
+
)
|
|
264
|
+
return exceptions
|
|
206
265
|
|
|
207
266
|
@verify_credentials
|
|
208
|
-
def
|
|
209
|
-
self, partner: Control,
|
|
267
|
+
def create_policy_exception(
|
|
268
|
+
self, partner: Control, instance_id: str, policy_id, setting_names, expires=None
|
|
210
269
|
):
|
|
211
|
-
"""
|
|
270
|
+
"""Create policy exceptions"""
|
|
212
271
|
body = dict(
|
|
213
272
|
control=partner.name,
|
|
214
273
|
expires=expires,
|
|
@@ -216,6 +275,29 @@ class ScmController(HttpController):
|
|
|
216
275
|
policy_id=policy_id,
|
|
217
276
|
setting_names=setting_names,
|
|
218
277
|
)
|
|
278
|
+
res = self.post(
|
|
279
|
+
f"{self.account.hq}/scm/exceptions/policies",
|
|
280
|
+
json=body,
|
|
281
|
+
headers=self.account.headers,
|
|
282
|
+
timeout=10,
|
|
283
|
+
)
|
|
284
|
+
return res.json()
|
|
285
|
+
|
|
286
|
+
@verify_credentials
|
|
287
|
+
def update_policy_exception(
|
|
288
|
+
self,
|
|
289
|
+
partner: Control,
|
|
290
|
+
instance_id: str,
|
|
291
|
+
policy_id,
|
|
292
|
+
expires=default,
|
|
293
|
+
setting_names=None,
|
|
294
|
+
):
|
|
295
|
+
"""Update policy exceptions"""
|
|
296
|
+
body = dict(control=partner.name, instance_id=instance_id, policy_id=policy_id)
|
|
297
|
+
if expires != self.default:
|
|
298
|
+
body["expires"] = expires
|
|
299
|
+
if setting_names:
|
|
300
|
+
body["setting_names"] = setting_names
|
|
219
301
|
res = self.put(
|
|
220
302
|
f"{self.account.hq}/scm/exceptions/policies",
|
|
221
303
|
json=body,
|
|
@@ -224,6 +306,18 @@ class ScmController(HttpController):
|
|
|
224
306
|
)
|
|
225
307
|
return res.json()
|
|
226
308
|
|
|
309
|
+
@verify_credentials
|
|
310
|
+
def delete_policy_exception(self, instance_id: str, policy_id: str):
|
|
311
|
+
"""Delete policy exceptions"""
|
|
312
|
+
body = dict(instance_id=instance_id, policy_id=policy_id)
|
|
313
|
+
res = self.delete(
|
|
314
|
+
f"{self.account.hq}/scm/exceptions/policies",
|
|
315
|
+
json=body,
|
|
316
|
+
headers=self.account.headers,
|
|
317
|
+
timeout=10,
|
|
318
|
+
)
|
|
319
|
+
return res.json()
|
|
320
|
+
|
|
227
321
|
@verify_credentials
|
|
228
322
|
def list_views(self):
|
|
229
323
|
"""List views"""
|
|
@@ -232,7 +326,10 @@ class ScmController(HttpController):
|
|
|
232
326
|
headers=self.account.headers,
|
|
233
327
|
timeout=10,
|
|
234
328
|
)
|
|
235
|
-
|
|
329
|
+
views = res.json()
|
|
330
|
+
if self.account.resolve_enums:
|
|
331
|
+
self.resolve_enums(views, [(ControlCategory, "category")])
|
|
332
|
+
return views
|
|
236
333
|
|
|
237
334
|
@verify_credentials
|
|
238
335
|
def create_view(self, category: ControlCategory, filter: str, name: str):
|
|
@@ -371,7 +468,17 @@ class ScmController(HttpController):
|
|
|
371
468
|
headers=self.account.headers,
|
|
372
469
|
timeout=10,
|
|
373
470
|
)
|
|
374
|
-
|
|
471
|
+
notifications = res.json()
|
|
472
|
+
if self.account.resolve_enums:
|
|
473
|
+
self.resolve_enums(
|
|
474
|
+
notifications,
|
|
475
|
+
[
|
|
476
|
+
(ControlCategory, "control_category"),
|
|
477
|
+
(PartnerEvents, "event"),
|
|
478
|
+
(RunCode, "run_code"),
|
|
479
|
+
],
|
|
480
|
+
)
|
|
481
|
+
return notifications
|
|
375
482
|
|
|
376
483
|
@verify_credentials
|
|
377
484
|
def delete_notification(self, notification_id: str):
|
|
@@ -422,3 +529,40 @@ class ScmController(HttpController):
|
|
|
422
529
|
timeout=10,
|
|
423
530
|
)
|
|
424
531
|
return res.json()
|
|
532
|
+
|
|
533
|
+
@verify_credentials
|
|
534
|
+
def list_notations(self):
|
|
535
|
+
"""List notations"""
|
|
536
|
+
res = self.get(
|
|
537
|
+
f"{self.account.hq}/scm/notations",
|
|
538
|
+
headers=self.account.headers,
|
|
539
|
+
timeout=10,
|
|
540
|
+
)
|
|
541
|
+
notations = res.json()
|
|
542
|
+
if self.account.resolve_enums:
|
|
543
|
+
self.resolve_enums(notations, [(NotationType, "event")])
|
|
544
|
+
return notations
|
|
545
|
+
|
|
546
|
+
@verify_credentials
|
|
547
|
+
def list_history(
|
|
548
|
+
self, start_date: str = None, end_date: str = None, filter: str = None
|
|
549
|
+
):
|
|
550
|
+
"""List history"""
|
|
551
|
+
params = {"start_date": start_date, "end_date": end_date, "$filter": filter}
|
|
552
|
+
res = self.get(
|
|
553
|
+
f"{self.account.hq}/scm/history",
|
|
554
|
+
headers=self.account.headers,
|
|
555
|
+
params=params,
|
|
556
|
+
timeout=10,
|
|
557
|
+
)
|
|
558
|
+
history = res.json()
|
|
559
|
+
if self.account.resolve_enums:
|
|
560
|
+
self.resolve_enums(
|
|
561
|
+
history,
|
|
562
|
+
[
|
|
563
|
+
(Control, "control"),
|
|
564
|
+
(ControlCategory, "category"),
|
|
565
|
+
(PartnerEvents, "event"),
|
|
566
|
+
],
|
|
567
|
+
)
|
|
568
|
+
return history
|
|
@@ -83,7 +83,7 @@ def exchange_token(
|
|
|
83
83
|
class Account:
|
|
84
84
|
|
|
85
85
|
@staticmethod
|
|
86
|
-
def from_keychain(profile: str = "default"):
|
|
86
|
+
def from_keychain(profile: str = "default", resolve_enums: bool = False):
|
|
87
87
|
"""
|
|
88
88
|
Create an account object from a pre-configured profile in your keychain file
|
|
89
89
|
"""
|
|
@@ -100,6 +100,7 @@ class Account:
|
|
|
100
100
|
oidc=profile_items.get("oidc"),
|
|
101
101
|
profile=profile,
|
|
102
102
|
slug=profile_items.get("slug"),
|
|
103
|
+
resolve_enums=resolve_enums,
|
|
103
104
|
)
|
|
104
105
|
|
|
105
106
|
@staticmethod
|
|
@@ -111,6 +112,7 @@ class Account:
|
|
|
111
112
|
hq: str = "https://api.us1.preludesecurity.com",
|
|
112
113
|
oidc: str | None = None,
|
|
113
114
|
slug: str | None = None,
|
|
115
|
+
resolve_enums: bool = False,
|
|
114
116
|
):
|
|
115
117
|
"""
|
|
116
118
|
Create an account object from an access token or a refresh token
|
|
@@ -131,6 +133,7 @@ class Account:
|
|
|
131
133
|
slug=slug,
|
|
132
134
|
token=token,
|
|
133
135
|
token_location=None,
|
|
136
|
+
resolve_enums=resolve_enums,
|
|
134
137
|
)
|
|
135
138
|
|
|
136
139
|
|
|
@@ -151,6 +154,7 @@ class _Account:
|
|
|
151
154
|
token_location: str | None = os.path.join(
|
|
152
155
|
Path.home(), ".prelude", "tokens.json"
|
|
153
156
|
),
|
|
157
|
+
resolve_enums: bool = False,
|
|
154
158
|
):
|
|
155
159
|
if token is None and token_location is None:
|
|
156
160
|
raise ValueError(
|
|
@@ -168,6 +172,7 @@ class _Account:
|
|
|
168
172
|
self.slug = slug
|
|
169
173
|
self.token = token
|
|
170
174
|
self.token_location = token_location
|
|
175
|
+
self.resolve_enums = resolve_enums
|
|
171
176
|
if self.token_location and not os.path.exists(self.token_location):
|
|
172
177
|
head, _ = os.path.split(Path(self.token_location))
|
|
173
178
|
Path(head).mkdir(parents=True, exist_ok=True)
|
prelude_sdk_beta/models/codes.py
CHANGED
|
@@ -171,7 +171,6 @@ class Control(Enum, metaclass=MissingItem):
|
|
|
171
171
|
M365 = 10
|
|
172
172
|
ENTRA = 11
|
|
173
173
|
JAMF = 12
|
|
174
|
-
CROWDSTRIKE_IDENTITY = 13
|
|
175
174
|
GMAIL = 14
|
|
176
175
|
GOOGLE_IDENTITY = 15
|
|
177
176
|
DEFENDER_DISCOVERY = 16
|
|
@@ -183,6 +182,9 @@ class Control(Enum, metaclass=MissingItem):
|
|
|
183
182
|
TENABLE_DISCOVERY = 22
|
|
184
183
|
QUALYS = 23
|
|
185
184
|
QUALYS_DISCOVERY = 24
|
|
185
|
+
RAPID7 = 25
|
|
186
|
+
RAPID7_DISCOVERY = 26
|
|
187
|
+
INTUNE_HOST_FIREWALL = 27
|
|
186
188
|
|
|
187
189
|
@classmethod
|
|
188
190
|
def _missing_(cls, value):
|
|
@@ -202,6 +204,36 @@ class Control(Enum, metaclass=MissingItem):
|
|
|
202
204
|
return k
|
|
203
205
|
return SCMCategory.NONE
|
|
204
206
|
|
|
207
|
+
@property
|
|
208
|
+
def parent(self):
|
|
209
|
+
match self:
|
|
210
|
+
case Control.DEFENDER_DISCOVERY:
|
|
211
|
+
return Control.DEFENDER
|
|
212
|
+
case Control.QUALYS_DISCOVERY:
|
|
213
|
+
return Control.QUALYS
|
|
214
|
+
case Control.RAPID7_DISCOVERY:
|
|
215
|
+
return Control.RAPID7
|
|
216
|
+
case Control.TENABLE_DISCOVERY:
|
|
217
|
+
return Control.TENABLE
|
|
218
|
+
case Control.INTUNE_HOST_FIREWALL:
|
|
219
|
+
return Control.INTUNE
|
|
220
|
+
|
|
221
|
+
@property
|
|
222
|
+
def children(self):
|
|
223
|
+
match self:
|
|
224
|
+
case Control.DEFENDER:
|
|
225
|
+
return [Control.DEFENDER_DISCOVERY]
|
|
226
|
+
case Control.QUALYS:
|
|
227
|
+
return [Control.QUALYS_DISCOVERY]
|
|
228
|
+
case Control.RAPID7:
|
|
229
|
+
return [Control.RAPID7_DISCOVERY]
|
|
230
|
+
case Control.TENABLE:
|
|
231
|
+
return [Control.TENABLE_DISCOVERY]
|
|
232
|
+
case Control.INTUNE:
|
|
233
|
+
return [Control.INTUNE_HOST_FIREWALL]
|
|
234
|
+
case _:
|
|
235
|
+
return []
|
|
236
|
+
|
|
205
237
|
|
|
206
238
|
class ControlCategory(Enum, metaclass=MissingItem):
|
|
207
239
|
INVALID = -1
|
|
@@ -216,6 +248,7 @@ class ControlCategory(Enum, metaclass=MissingItem):
|
|
|
216
248
|
VULN_MANAGER = 8
|
|
217
249
|
SIEM = 9
|
|
218
250
|
PRIVATE_REPO = 10
|
|
251
|
+
HOST_FIREWALL = 11
|
|
219
252
|
|
|
220
253
|
@classmethod
|
|
221
254
|
def _missing_(cls, value):
|
|
@@ -235,6 +268,7 @@ class ControlCategory(Enum, metaclass=MissingItem):
|
|
|
235
268
|
Control.DEFENDER_DISCOVERY,
|
|
236
269
|
Control.EC2,
|
|
237
270
|
Control.QUALYS_DISCOVERY,
|
|
271
|
+
Control.RAPID7_DISCOVERY,
|
|
238
272
|
Control.SERVICENOW,
|
|
239
273
|
Control.TENABLE_DISCOVERY,
|
|
240
274
|
],
|
|
@@ -242,8 +276,10 @@ class ControlCategory(Enum, metaclass=MissingItem):
|
|
|
242
276
|
Control.GMAIL,
|
|
243
277
|
Control.M365,
|
|
244
278
|
],
|
|
279
|
+
ControlCategory.HOST_FIREWALL: [
|
|
280
|
+
Control.INTUNE_HOST_FIREWALL,
|
|
281
|
+
],
|
|
245
282
|
ControlCategory.IDENTITY: [
|
|
246
|
-
Control.CROWDSTRIKE_IDENTITY,
|
|
247
283
|
Control.ENTRA,
|
|
248
284
|
Control.GOOGLE_IDENTITY,
|
|
249
285
|
Control.OKTA,
|
|
@@ -257,7 +293,11 @@ class ControlCategory(Enum, metaclass=MissingItem):
|
|
|
257
293
|
Control.SPLUNK,
|
|
258
294
|
Control.VECTR,
|
|
259
295
|
],
|
|
260
|
-
ControlCategory.VULN_MANAGER: [
|
|
296
|
+
ControlCategory.VULN_MANAGER: [
|
|
297
|
+
Control.QUALYS,
|
|
298
|
+
Control.RAPID7,
|
|
299
|
+
Control.TENABLE,
|
|
300
|
+
],
|
|
261
301
|
ControlCategory.XDR: [
|
|
262
302
|
Control.CROWDSTRIKE,
|
|
263
303
|
Control.DEFENDER,
|
|
@@ -288,16 +328,18 @@ class SCMCategory(Enum, metaclass=MissingItem):
|
|
|
288
328
|
Control.DEFENDER_DISCOVERY,
|
|
289
329
|
Control.EC2,
|
|
290
330
|
Control.INTUNE,
|
|
331
|
+
Control.INTUNE_HOST_FIREWALL,
|
|
291
332
|
Control.JAMF,
|
|
292
333
|
Control.QUALYS,
|
|
293
334
|
Control.QUALYS_DISCOVERY,
|
|
335
|
+
Control.RAPID7,
|
|
336
|
+
Control.RAPID7_DISCOVERY,
|
|
294
337
|
Control.SENTINELONE,
|
|
295
338
|
Control.SERVICENOW,
|
|
296
339
|
Control.TENABLE,
|
|
297
340
|
Control.TENABLE_DISCOVERY,
|
|
298
341
|
],
|
|
299
342
|
SCMCategory.USER: [
|
|
300
|
-
Control.CROWDSTRIKE_IDENTITY,
|
|
301
343
|
Control.ENTRA,
|
|
302
344
|
Control.GOOGLE_IDENTITY,
|
|
303
345
|
Control.OKTA,
|
|
@@ -314,6 +356,7 @@ class SCMCategory(Enum, metaclass=MissingItem):
|
|
|
314
356
|
SCMCategory.ENDPOINT: [
|
|
315
357
|
ControlCategory.ASSET_MANAGER,
|
|
316
358
|
ControlCategory.DISCOVERED_DEVICES,
|
|
359
|
+
ControlCategory.HOST_FIREWALL,
|
|
317
360
|
ControlCategory.VULN_MANAGER,
|
|
318
361
|
ControlCategory.XDR,
|
|
319
362
|
],
|
|
@@ -362,6 +405,10 @@ class PartnerEvents(Enum, metaclass=MissingItem):
|
|
|
362
405
|
USER_MISSING_ASSET_MANAGER = 11
|
|
363
406
|
USER_MISSING_EDR = 12
|
|
364
407
|
USER_MISSING_VULN_MANAGER = 13
|
|
408
|
+
NO_SERVER_MANAGER = 14
|
|
409
|
+
NO_HOST_FIREWALL = 15
|
|
410
|
+
MISSING_HOST_FIREWALL_POLICY = 16
|
|
411
|
+
USER_MISSING_HOST_FIREWALL = 17
|
|
365
412
|
|
|
366
413
|
@classmethod
|
|
367
414
|
def _missing_(cls, value):
|
|
@@ -370,24 +417,27 @@ class PartnerEvents(Enum, metaclass=MissingItem):
|
|
|
370
417
|
@classmethod
|
|
371
418
|
def control_category_mapping(cls):
|
|
372
419
|
return {
|
|
373
|
-
PartnerEvents.REDUCED_FUNCTIONALITY_MODE: [ControlCategory.XDR],
|
|
374
|
-
PartnerEvents.NO_EDR: [
|
|
375
|
-
ControlCategory.XDR,
|
|
376
|
-
],
|
|
377
|
-
PartnerEvents.MISSING_EDR_POLICY: [ControlCategory.XDR],
|
|
378
|
-
PartnerEvents.MISSING_AV_POLICY: [ControlCategory.XDR],
|
|
379
|
-
PartnerEvents.MISSING_MFA: [ControlCategory.IDENTITY],
|
|
380
|
-
PartnerEvents.NO_ASSET_MANAGER: [ControlCategory.ASSET_MANAGER],
|
|
381
420
|
PartnerEvents.MISCONFIGURED_POLICY_SETTING: [
|
|
382
|
-
ControlCategory.XDR,
|
|
383
421
|
ControlCategory.EMAIL,
|
|
422
|
+
ControlCategory.HOST_FIREWALL,
|
|
384
423
|
ControlCategory.IDENTITY,
|
|
424
|
+
ControlCategory.XDR,
|
|
385
425
|
],
|
|
426
|
+
PartnerEvents.MISSING_AV_POLICY: [ControlCategory.XDR],
|
|
427
|
+
PartnerEvents.MISSING_EDR_POLICY: [ControlCategory.XDR],
|
|
428
|
+
PartnerEvents.MISSING_HOST_FIREWALL_POLICY: [ControlCategory.HOST_FIREWALL],
|
|
429
|
+
PartnerEvents.MISSING_MFA: [ControlCategory.IDENTITY],
|
|
386
430
|
PartnerEvents.MISSING_SCAN: [ControlCategory.VULN_MANAGER],
|
|
387
|
-
PartnerEvents.
|
|
431
|
+
PartnerEvents.NO_ASSET_MANAGER: [ControlCategory.ASSET_MANAGER],
|
|
432
|
+
PartnerEvents.NO_EDR: [ControlCategory.XDR],
|
|
433
|
+
PartnerEvents.NO_HOST_FIREWALL: [ControlCategory.HOST_FIREWALL],
|
|
434
|
+
PartnerEvents.NO_SERVER_MANAGER: [ControlCategory.ASSET_MANAGER],
|
|
388
435
|
PartnerEvents.NO_VULN_MANAGER: [ControlCategory.VULN_MANAGER],
|
|
436
|
+
PartnerEvents.OUT_OF_DATE_SCAN: [ControlCategory.VULN_MANAGER],
|
|
437
|
+
PartnerEvents.REDUCED_FUNCTIONALITY_MODE: [ControlCategory.XDR],
|
|
389
438
|
PartnerEvents.USER_MISSING_ASSET_MANAGER: [ControlCategory.IDENTITY],
|
|
390
439
|
PartnerEvents.USER_MISSING_EDR: [ControlCategory.IDENTITY],
|
|
440
|
+
PartnerEvents.USER_MISSING_HOST_FIREWALL: [ControlCategory.HOST_FIREWALL],
|
|
391
441
|
PartnerEvents.USER_MISSING_VULN_MANAGER: [ControlCategory.IDENTITY],
|
|
392
442
|
}
|
|
393
443
|
|
|
@@ -408,6 +458,10 @@ class AlertTypes(Enum, metaclass=MissingItem):
|
|
|
408
458
|
NEW_USER_MISSING_ASSET_MANAGER = 12
|
|
409
459
|
NEW_USER_MISSING_EDR = 13
|
|
410
460
|
NEW_USER_MISSING_VULN_MANAGER = 14
|
|
461
|
+
NEW_NO_SERVER_MANAGER_ENDPOINTS = 15
|
|
462
|
+
NEW_NO_HOST_FIREWALL_ENDPOINTS = 16
|
|
463
|
+
NEW_MISSING_HOST_FIREWALL_POLICY_ENDPOINTS = 17
|
|
464
|
+
NEW_USER_MISSING_HOST_FIREWALL = 18
|
|
411
465
|
|
|
412
466
|
@classmethod
|
|
413
467
|
def _missing_(cls, value):
|
|
@@ -428,6 +482,7 @@ class PolicyType(Enum, metaclass=MissingItem):
|
|
|
428
482
|
EMAIL_DKIM = 10
|
|
429
483
|
DEVICE_COMPLIANCE = 11
|
|
430
484
|
IDENTITY_MFA = 12
|
|
485
|
+
HOST_FIREWALL = 13
|
|
431
486
|
|
|
432
487
|
@classmethod
|
|
433
488
|
def _missing_(cls, value):
|
|
@@ -444,3 +499,23 @@ class Platform(Enum, metaclass=MissingItem):
|
|
|
444
499
|
@classmethod
|
|
445
500
|
def _missing_(cls, value):
|
|
446
501
|
return Platform.INVALID
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
class NotationType(Enum, metaclass=MissingItem):
|
|
505
|
+
INVALID = -1
|
|
506
|
+
OBJECT_EXCEPTION_CREATED = 1
|
|
507
|
+
OBJECT_EXCEPTION_DELETED = 2
|
|
508
|
+
OBJECT_EXCEPTION_UPDATED = 3
|
|
509
|
+
OBJECT_EXCEPTION_EXPIRED = 4
|
|
510
|
+
POLICY_EXCEPTION_CREATED = 10
|
|
511
|
+
POLICY_EXCEPTION_DELETED = 11
|
|
512
|
+
POLICY_EXCEPTION_UPDATED = 5
|
|
513
|
+
POLICY_EXCEPTION_EXPIRED = 6
|
|
514
|
+
PARTNER_ATTACHED = 7
|
|
515
|
+
PARTNER_DETACHED = 8
|
|
516
|
+
PARTNER_UPDATED = 9
|
|
517
|
+
# Next value: 12
|
|
518
|
+
|
|
519
|
+
@classmethod
|
|
520
|
+
def _missing_(cls, value):
|
|
521
|
+
return NotationType.INVALID
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
prelude_sdk_beta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
prelude_sdk_beta/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
prelude_sdk_beta/controllers/build_controller.py,sha256=_O-pPkB22vnvT5nh40TUIv9VmRNX8qBMkS4wqtAdtxg,9099
|
|
4
|
+
prelude_sdk_beta/controllers/detect_controller.py,sha256=aBF_552-DLK6zGg49dNMzqBgtkPB0ksIWWGQr44Agh8,8121
|
|
5
|
+
prelude_sdk_beta/controllers/export_controller.py,sha256=sTbRGmMa0xa7pB8AjSlJgifpXzutPHWw4bJBGygoAc4,862
|
|
6
|
+
prelude_sdk_beta/controllers/generate_controller.py,sha256=gNSr2yV1o8kdTy7heJ9bI31efEKyTKdacIkKl_eRIRg,1319
|
|
7
|
+
prelude_sdk_beta/controllers/http_controller.py,sha256=zomZo8OCWcJ-8zQIlBtukXbnJeqM9PkQn303APojLSA,3160
|
|
8
|
+
prelude_sdk_beta/controllers/iam_controller.py,sha256=sbkq1xzAGefmUnRrAQ811fRBiNzyE7cwgHKFlpG7bd0,8203
|
|
9
|
+
prelude_sdk_beta/controllers/jobs_controller.py,sha256=cYsqXViDycVgUAjN0GuJrNUMaTFC-dUTJSpIYHcfUgs,1165
|
|
10
|
+
prelude_sdk_beta/controllers/partner_controller.py,sha256=WV51CY-Bsf8Ms59y7RjtfvCmsArBoXt5-AHqrN8Eras,5128
|
|
11
|
+
prelude_sdk_beta/controllers/probe_controller.py,sha256=d2Aa74Css1uMNgBKGWqavbkEbXtVcOkYIIWbhDxzLS0,411
|
|
12
|
+
prelude_sdk_beta/controllers/scm_controller.py,sha256=6CNi4yp77wjlfyQH9A_rmp80mjnzuYCWUd-SlFLHZW8,17402
|
|
13
|
+
prelude_sdk_beta/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
prelude_sdk_beta/models/account.py,sha256=dRKhX6_mrqDTyqyfIsvHFVavcedgZ5hZAIDYVF7YlZI,8962
|
|
15
|
+
prelude_sdk_beta/models/codes.py,sha256=oDdHSR1Y0DfOxCUVdEbntkKGPEhazCactuZe-xT7e8s,13978
|
|
16
|
+
prelude_sdk_beta-1407.dist-info/licenses/LICENSE,sha256=ttdT5omfN6LNmtQoIjUhkkFhz6i44SDMRNwKrbfyTf8,1069
|
|
17
|
+
prelude_sdk_beta-1407.dist-info/METADATA,sha256=sIzvNYLW8zOb_o1Dr7QTigEEAw-PijAVXgZt3Ci28yo,1190
|
|
18
|
+
prelude_sdk_beta-1407.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
prelude_sdk_beta-1407.dist-info/top_level.txt,sha256=pqXTtEd5ElvJKoO6HAz232H9FW5j6X7gW4kEEakfSFM,17
|
|
20
|
+
prelude_sdk_beta-1407.dist-info/RECORD,,
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
prelude_sdk_beta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
prelude_sdk_beta/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
prelude_sdk_beta/controllers/build_controller.py,sha256=XpsjsVJCcJ9jDOugBAqf2-tsvJYjyBk-_2wgVwaYfEw,8817
|
|
4
|
-
prelude_sdk_beta/controllers/detect_controller.py,sha256=0FAtg_HEZ2Z3ZDbfO8mpOKViF25tqHaFR5rUGRuULJA,7509
|
|
5
|
-
prelude_sdk_beta/controllers/export_controller.py,sha256=sTbRGmMa0xa7pB8AjSlJgifpXzutPHWw4bJBGygoAc4,862
|
|
6
|
-
prelude_sdk_beta/controllers/generate_controller.py,sha256=gNSr2yV1o8kdTy7heJ9bI31efEKyTKdacIkKl_eRIRg,1319
|
|
7
|
-
prelude_sdk_beta/controllers/http_controller.py,sha256=cj1SxmAX049ioAhTOQR4atuM82nJgd11S60-ISCg738,2300
|
|
8
|
-
prelude_sdk_beta/controllers/iam_controller.py,sha256=w40NO1kxPxLMFDICx32pqfZbTfDJTL9G-jxF6nR01Lw,7871
|
|
9
|
-
prelude_sdk_beta/controllers/jobs_controller.py,sha256=dwoBGX-gAVNKE8sbx1N_4jUJVDVSdNRYD826G0pfix0,765
|
|
10
|
-
prelude_sdk_beta/controllers/partner_controller.py,sha256=WV51CY-Bsf8Ms59y7RjtfvCmsArBoXt5-AHqrN8Eras,5128
|
|
11
|
-
prelude_sdk_beta/controllers/probe_controller.py,sha256=d2Aa74Css1uMNgBKGWqavbkEbXtVcOkYIIWbhDxzLS0,411
|
|
12
|
-
prelude_sdk_beta/controllers/scm_controller.py,sha256=X2CU11Se_zgGLKAR_whIlWMZdgT72XSfKCSP-gxNJaI,12793
|
|
13
|
-
prelude_sdk_beta/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
prelude_sdk_beta/models/account.py,sha256=ksyTZDOZpbT8XDu-Ygs_51ZG25oBd8qiwjO6-L6HH9Y,8734
|
|
15
|
-
prelude_sdk_beta/models/codes.py,sha256=-gxBflkV-RdE3LwGSDDSO48eK-J8skZ5CivMD2MYc5w,11425
|
|
16
|
-
prelude_sdk_beta-1406.dist-info/licenses/LICENSE,sha256=ttdT5omfN6LNmtQoIjUhkkFhz6i44SDMRNwKrbfyTf8,1069
|
|
17
|
-
prelude_sdk_beta-1406.dist-info/METADATA,sha256=L5B1pm77Vyl6sSukal59cWaI0uT5hw4tid0TkZTdzGs,1190
|
|
18
|
-
prelude_sdk_beta-1406.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
-
prelude_sdk_beta-1406.dist-info/top_level.txt,sha256=pqXTtEd5ElvJKoO6HAz232H9FW5j6X7gW4kEEakfSFM,17
|
|
20
|
-
prelude_sdk_beta-1406.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|