prelude-sdk 2.6.38__py3-none-any.whl → 2.6.40__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.
- prelude_sdk/controllers/build_controller.py +16 -84
- prelude_sdk/controllers/detect_controller.py +33 -102
- prelude_sdk/controllers/export_controller.py +3 -7
- prelude_sdk/controllers/generate_controller.py +3 -6
- prelude_sdk/controllers/http_controller.py +28 -12
- prelude_sdk/controllers/iam_controller.py +20 -99
- prelude_sdk/controllers/jobs_controller.py +2 -8
- prelude_sdk/controllers/partner_controller.py +13 -30
- prelude_sdk/controllers/probe_controller.py +1 -3
- prelude_sdk/controllers/scm_controller.py +69 -183
- prelude_sdk/models/codes.py +1 -0
- {prelude_sdk-2.6.38.dist-info → prelude_sdk-2.6.40.dist-info}/METADATA +1 -1
- prelude_sdk-2.6.40.dist-info/RECORD +20 -0
- prelude_sdk-2.6.38.dist-info/RECORD +0 -20
- {prelude_sdk-2.6.38.dist-info → prelude_sdk-2.6.40.dist-info}/WHEEL +0 -0
- {prelude_sdk-2.6.38.dist-info → prelude_sdk-2.6.40.dist-info}/licenses/LICENSE +0 -0
- {prelude_sdk-2.6.38.dist-info → prelude_sdk-2.6.40.dist-info}/top_level.txt +0 -0
|
@@ -11,9 +11,7 @@ class IAMAccountController(HttpController):
|
|
|
11
11
|
@verify_credentials
|
|
12
12
|
def get_account(self):
|
|
13
13
|
"""Get account properties"""
|
|
14
|
-
res = self.get(
|
|
15
|
-
f"{self.account.hq}/iam/account", headers=self.account.headers, timeout=10
|
|
16
|
-
)
|
|
14
|
+
res = self.get(f"{self.account.hq}/iam/account")
|
|
17
15
|
account = res.json()
|
|
18
16
|
if self.account.resolve_enums:
|
|
19
17
|
self.resolve_enums(
|
|
@@ -24,9 +22,7 @@ class IAMAccountController(HttpController):
|
|
|
24
22
|
@verify_credentials
|
|
25
23
|
def purge_account(self):
|
|
26
24
|
"""Delete an account and all things in it"""
|
|
27
|
-
res = self.delete(
|
|
28
|
-
f"{self.account.hq}/iam/account", headers=self.account.headers, timeout=10
|
|
29
|
-
)
|
|
25
|
+
res = self.delete(f"{self.account.hq}/iam/account")
|
|
30
26
|
return res.json()
|
|
31
27
|
|
|
32
28
|
@verify_credentials
|
|
@@ -48,12 +44,7 @@ class IAMAccountController(HttpController):
|
|
|
48
44
|
if slug is not None:
|
|
49
45
|
body["slug"] = slug
|
|
50
46
|
|
|
51
|
-
res = self.put(
|
|
52
|
-
f"{self.account.hq}/iam/account",
|
|
53
|
-
headers=self.account.headers,
|
|
54
|
-
json=body,
|
|
55
|
-
timeout=10,
|
|
56
|
-
)
|
|
47
|
+
res = self.put(f"{self.account.hq}/iam/account", json=body)
|
|
57
48
|
return res.json()
|
|
58
49
|
|
|
59
50
|
@verify_credentials
|
|
@@ -65,33 +56,21 @@ class IAMAccountController(HttpController):
|
|
|
65
56
|
oidc_url: str,
|
|
66
57
|
):
|
|
67
58
|
"""Attach OIDC to an account"""
|
|
68
|
-
email_attr = "email"
|
|
69
|
-
if issuer == "azure":
|
|
70
|
-
email_attr = "upn"
|
|
71
59
|
body = dict(
|
|
72
60
|
client_id=client_id,
|
|
73
61
|
client_secret=client_secret,
|
|
74
|
-
email_attr=
|
|
62
|
+
email_attr="upn" if issuer == "azure" else "email",
|
|
75
63
|
issuer=issuer,
|
|
76
64
|
oidc_url=oidc_url,
|
|
77
65
|
)
|
|
78
66
|
|
|
79
|
-
res = self.post(
|
|
80
|
-
f"{self.account.hq}/iam/account/oidc",
|
|
81
|
-
headers=self.account.headers,
|
|
82
|
-
json=body,
|
|
83
|
-
timeout=10,
|
|
84
|
-
)
|
|
67
|
+
res = self.post(f"{self.account.hq}/iam/account/oidc", json=body)
|
|
85
68
|
return res.json()
|
|
86
69
|
|
|
87
70
|
@verify_credentials
|
|
88
71
|
def detach_oidc(self):
|
|
89
72
|
"""Detach OIDC to an account"""
|
|
90
|
-
res = self.delete(
|
|
91
|
-
f"{self.account.hq}/iam/account/oidc",
|
|
92
|
-
headers=self.account.headers,
|
|
93
|
-
timeout=10,
|
|
94
|
-
)
|
|
73
|
+
res = self.delete(f"{self.account.hq}/iam/account/oidc")
|
|
95
74
|
return res.json()
|
|
96
75
|
|
|
97
76
|
@verify_credentials
|
|
@@ -107,12 +86,7 @@ class IAMAccountController(HttpController):
|
|
|
107
86
|
if name:
|
|
108
87
|
body["name"] = name
|
|
109
88
|
|
|
110
|
-
res = self.post(
|
|
111
|
-
url=f"{self.account.hq}/iam/account/user",
|
|
112
|
-
json=body,
|
|
113
|
-
headers=self.account.headers,
|
|
114
|
-
timeout=10,
|
|
115
|
-
)
|
|
89
|
+
res = self.post(url=f"{self.account.hq}/iam/account/user", json=body)
|
|
116
90
|
user = res.json()
|
|
117
91
|
if self.account.resolve_enums:
|
|
118
92
|
self.resolve_enums(user, [(Permission, "permission")])
|
|
@@ -123,12 +97,7 @@ class IAMAccountController(HttpController):
|
|
|
123
97
|
"""Create a service user"""
|
|
124
98
|
body = dict(name=name)
|
|
125
99
|
|
|
126
|
-
res = self.post(
|
|
127
|
-
f"{self.account.hq}/iam/account/service_user",
|
|
128
|
-
json=body,
|
|
129
|
-
headers=self.account.headers,
|
|
130
|
-
timeout=10,
|
|
131
|
-
)
|
|
100
|
+
res = self.post(f"{self.account.hq}/iam/account/service_user", json=body)
|
|
132
101
|
return res.json()
|
|
133
102
|
|
|
134
103
|
@verify_credentials
|
|
@@ -136,12 +105,7 @@ class IAMAccountController(HttpController):
|
|
|
136
105
|
"""Delete service user"""
|
|
137
106
|
body = dict(handle=handle)
|
|
138
107
|
|
|
139
|
-
res = self.delete(
|
|
140
|
-
f"{self.account.hq}/iam/account/service_user",
|
|
141
|
-
json=body,
|
|
142
|
-
headers=self.account.headers,
|
|
143
|
-
timeout=10,
|
|
144
|
-
)
|
|
108
|
+
res = self.delete(f"{self.account.hq}/iam/account/service_user", json=body)
|
|
145
109
|
return res.json()
|
|
146
110
|
|
|
147
111
|
@verify_credentials
|
|
@@ -156,12 +120,7 @@ class IAMAccountController(HttpController):
|
|
|
156
120
|
if permission is not None:
|
|
157
121
|
body["permission"] = permission.name
|
|
158
122
|
|
|
159
|
-
res = self.put(
|
|
160
|
-
f"{self.account.hq}/iam/account/user",
|
|
161
|
-
json=body,
|
|
162
|
-
headers=self.account.headers,
|
|
163
|
-
timeout=10,
|
|
164
|
-
)
|
|
123
|
+
res = self.put(f"{self.account.hq}/iam/account/user", json=body)
|
|
165
124
|
return res.json()
|
|
166
125
|
|
|
167
126
|
@verify_credentials
|
|
@@ -169,24 +128,15 @@ class IAMAccountController(HttpController):
|
|
|
169
128
|
"""Remove user from the account"""
|
|
170
129
|
params = dict(handle=email, oidc=oidc)
|
|
171
130
|
|
|
172
|
-
res = self.delete(
|
|
173
|
-
f"{self.account.hq}/iam/account/user",
|
|
174
|
-
params=params,
|
|
175
|
-
headers=self.account.headers,
|
|
176
|
-
timeout=10,
|
|
177
|
-
)
|
|
131
|
+
res = self.delete(f"{self.account.hq}/iam/account/user", params=params)
|
|
178
132
|
return res.json()
|
|
179
133
|
|
|
180
134
|
@verify_credentials
|
|
181
135
|
def audit_logs(self, days: int = 7, limit: int = 1000):
|
|
182
136
|
"""Get audit logs from the last X days"""
|
|
183
137
|
params = dict(days=days, limit=limit)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
headers=self.account.headers,
|
|
187
|
-
params=params,
|
|
188
|
-
timeout=30,
|
|
189
|
-
)
|
|
138
|
+
|
|
139
|
+
res = self.get(f"{self.account.hq}/iam/audit", params=params, timeout=30)
|
|
190
140
|
return res.json()
|
|
191
141
|
|
|
192
142
|
def sign_up(self, company, email, name):
|
|
@@ -194,10 +144,7 @@ class IAMAccountController(HttpController):
|
|
|
194
144
|
body = dict(company=company, email=email, name=name)
|
|
195
145
|
|
|
196
146
|
res = self._session.post(
|
|
197
|
-
f"{self.account.hq}/iam/new_user_and_account",
|
|
198
|
-
headers=self.account.headers,
|
|
199
|
-
json=body,
|
|
200
|
-
timeout=20,
|
|
147
|
+
f"{self.account.hq}/iam/new_user_and_account", json=body, timeout=20
|
|
201
148
|
)
|
|
202
149
|
data = res.json()
|
|
203
150
|
if self.account.profile:
|
|
@@ -218,19 +165,13 @@ class IAMUserController(HttpController):
|
|
|
218
165
|
@verify_credentials
|
|
219
166
|
def list_accounts(self):
|
|
220
167
|
"""List all accounts for your user"""
|
|
221
|
-
res = self.get(
|
|
222
|
-
f"{self.account.hq}/iam/user/account",
|
|
223
|
-
headers=self.account.headers,
|
|
224
|
-
timeout=10,
|
|
225
|
-
)
|
|
168
|
+
res = self.get(f"{self.account.hq}/iam/user/account")
|
|
226
169
|
return res.json()
|
|
227
170
|
|
|
228
171
|
@verify_credentials
|
|
229
172
|
def purge_user(self):
|
|
230
173
|
"""Delete your user"""
|
|
231
|
-
res = self.delete(
|
|
232
|
-
f"{self.account.hq}/iam/user", headers=self.account.headers, timeout=10
|
|
233
|
-
)
|
|
174
|
+
res = self.delete(f"{self.account.hq}/iam/user")
|
|
234
175
|
return res.json()
|
|
235
176
|
|
|
236
177
|
@verify_credentials
|
|
@@ -243,24 +184,14 @@ class IAMUserController(HttpController):
|
|
|
243
184
|
if name is not None:
|
|
244
185
|
body["name"] = name
|
|
245
186
|
|
|
246
|
-
res = self.put(
|
|
247
|
-
f"{self.account.hq}/iam/user",
|
|
248
|
-
json=body,
|
|
249
|
-
headers=self.account.headers,
|
|
250
|
-
timeout=10,
|
|
251
|
-
)
|
|
187
|
+
res = self.put(f"{self.account.hq}/iam/user", json=body)
|
|
252
188
|
return res.json()
|
|
253
189
|
|
|
254
190
|
def forgot_password(self):
|
|
255
191
|
"""Send a forgot password email"""
|
|
256
192
|
body = dict(handle=self.account.handle)
|
|
257
193
|
|
|
258
|
-
res = self.post(
|
|
259
|
-
f"{self.account.hq}/iam/user/forgot_password",
|
|
260
|
-
json=body,
|
|
261
|
-
headers=self.account.headers,
|
|
262
|
-
timeout=10,
|
|
263
|
-
)
|
|
194
|
+
res = self.post(f"{self.account.hq}/iam/user/forgot_password", json=body)
|
|
264
195
|
return res.json()
|
|
265
196
|
|
|
266
197
|
def confirm_forgot_password(self, confirmation_code: str, new_password: str):
|
|
@@ -271,12 +202,7 @@ class IAMUserController(HttpController):
|
|
|
271
202
|
password=new_password,
|
|
272
203
|
)
|
|
273
204
|
|
|
274
|
-
res = self.post(
|
|
275
|
-
f"{self.account.hq}/iam/user/forgot_password",
|
|
276
|
-
json=body,
|
|
277
|
-
headers=self.account.headers,
|
|
278
|
-
timeout=10,
|
|
279
|
-
)
|
|
205
|
+
res = self.post(f"{self.account.hq}/iam/user/forgot_password", json=body)
|
|
280
206
|
return res.json()
|
|
281
207
|
|
|
282
208
|
@verify_credentials
|
|
@@ -284,10 +210,5 @@ class IAMUserController(HttpController):
|
|
|
284
210
|
"""Change your password"""
|
|
285
211
|
body = dict(current_password=current_password, new_password=new_password)
|
|
286
212
|
|
|
287
|
-
res = self.post(
|
|
288
|
-
f"{self.account.hq}/iam/user/change_password",
|
|
289
|
-
json=body,
|
|
290
|
-
headers=self.account.headers,
|
|
291
|
-
timeout=10,
|
|
292
|
-
)
|
|
213
|
+
res = self.post(f"{self.account.hq}/iam/user/change_password", json=body)
|
|
293
214
|
return res.json()
|
|
@@ -13,9 +13,7 @@ class JobsController(HttpController):
|
|
|
13
13
|
@verify_credentials
|
|
14
14
|
def job_statuses(self):
|
|
15
15
|
"""Get job statuses"""
|
|
16
|
-
res = self.get(
|
|
17
|
-
f"{self.account.hq}/jobs/statuses", headers=self.account.headers, timeout=30
|
|
18
|
-
)
|
|
16
|
+
res = self.get(f"{self.account.hq}/jobs/statuses", timeout=30)
|
|
19
17
|
jobs = res.json()
|
|
20
18
|
if self.account.resolve_enums:
|
|
21
19
|
self.resolve_enums(jobs, [(Control, "control")])
|
|
@@ -24,11 +22,7 @@ class JobsController(HttpController):
|
|
|
24
22
|
@verify_credentials
|
|
25
23
|
def job_status(self, job_id: str):
|
|
26
24
|
"""Get job status given job ID"""
|
|
27
|
-
res = self.get(
|
|
28
|
-
f"{self.account.hq}/jobs/statuses/{job_id}",
|
|
29
|
-
headers=self.account.headers,
|
|
30
|
-
timeout=30,
|
|
31
|
-
)
|
|
25
|
+
res = self.get(f"{self.account.hq}/jobs/statuses/{job_id}", timeout=30)
|
|
32
26
|
job = res.json()
|
|
33
27
|
if self.account.resolve_enums:
|
|
34
28
|
self.resolve_enums(
|
|
@@ -31,21 +31,15 @@ class PartnerController(HttpController):
|
|
|
31
31
|
if secret:
|
|
32
32
|
params["secret"] = secret
|
|
33
33
|
extra = f"/{instance_id}" if instance_id else ""
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
headers=self.account.headers,
|
|
37
|
-
json=params,
|
|
38
|
-
timeout=10,
|
|
39
|
-
)
|
|
34
|
+
|
|
35
|
+
res = self.post(f"{self.account.hq}/partner/{partner.name}{extra}", json=params)
|
|
40
36
|
return res.json()
|
|
41
37
|
|
|
42
38
|
@verify_credentials
|
|
43
39
|
def detach(self, partner: Control, instance_id: str):
|
|
44
40
|
"""Detach a partner from your Detect account"""
|
|
45
41
|
res = self.delete(
|
|
46
|
-
f"{self.account.hq}/partner/{partner.name}/{instance_id}",
|
|
47
|
-
headers=self.account.headers,
|
|
48
|
-
timeout=30,
|
|
42
|
+
f"{self.account.hq}/partner/{partner.name}/{instance_id}", timeout=30
|
|
49
43
|
)
|
|
50
44
|
return res.json()
|
|
51
45
|
|
|
@@ -53,11 +47,9 @@ class PartnerController(HttpController):
|
|
|
53
47
|
def block(self, partner: Control, test_id: str):
|
|
54
48
|
"""Report to a partner to block a test"""
|
|
55
49
|
params = dict(test_id=test_id)
|
|
50
|
+
|
|
56
51
|
res = self.post(
|
|
57
|
-
f"{self.account.hq}/partner/block/{partner.name}",
|
|
58
|
-
headers=self.account.headers,
|
|
59
|
-
json=params,
|
|
60
|
-
timeout=30,
|
|
52
|
+
f"{self.account.hq}/partner/block/{partner.name}", json=params, timeout=30
|
|
61
53
|
)
|
|
62
54
|
return res.json()
|
|
63
55
|
|
|
@@ -72,9 +64,9 @@ class PartnerController(HttpController):
|
|
|
72
64
|
):
|
|
73
65
|
"""Get a list of endpoints from a partner"""
|
|
74
66
|
params = dict(platform=platform, hostname=hostname, offset=offset, count=count)
|
|
67
|
+
|
|
75
68
|
res = self.get(
|
|
76
69
|
f"{self.account.hq}/partner/endpoints/{partner.name}",
|
|
77
|
-
headers=self.account.headers,
|
|
78
70
|
params=params,
|
|
79
71
|
timeout=30,
|
|
80
72
|
)
|
|
@@ -84,11 +76,9 @@ class PartnerController(HttpController):
|
|
|
84
76
|
def deploy(self, partner: Control, host_ids: list):
|
|
85
77
|
"""Deploy probes on all specified partner endpoints"""
|
|
86
78
|
params = dict(host_ids=host_ids)
|
|
79
|
+
|
|
87
80
|
res = self.post(
|
|
88
|
-
f"{self.account.hq}/partner/deploy/{partner.name}",
|
|
89
|
-
headers=self.account.headers,
|
|
90
|
-
json=params,
|
|
91
|
-
timeout=30,
|
|
81
|
+
f"{self.account.hq}/partner/deploy/{partner.name}", json=params, timeout=30
|
|
92
82
|
)
|
|
93
83
|
return res.json()
|
|
94
84
|
|
|
@@ -96,11 +86,9 @@ class PartnerController(HttpController):
|
|
|
96
86
|
def list_reports(self, partner: Control, test_id: str | None):
|
|
97
87
|
"""Get reports to a partner for a test"""
|
|
98
88
|
params = dict(test_id=test_id) if test_id else dict()
|
|
89
|
+
|
|
99
90
|
res = self.get(
|
|
100
|
-
f"{self.account.hq}/partner/reports/{partner.name}",
|
|
101
|
-
headers=self.account.headers,
|
|
102
|
-
json=params,
|
|
103
|
-
timeout=30,
|
|
91
|
+
f"{self.account.hq}/partner/reports/{partner.name}", json=params, timeout=30
|
|
104
92
|
)
|
|
105
93
|
return res.json()
|
|
106
94
|
|
|
@@ -116,10 +104,7 @@ class PartnerController(HttpController):
|
|
|
116
104
|
) * 1000
|
|
117
105
|
|
|
118
106
|
res = self.get(
|
|
119
|
-
f"{self.account.hq}/partner/observed_detected",
|
|
120
|
-
headers=self.account.headers,
|
|
121
|
-
json=params,
|
|
122
|
-
timeout=30,
|
|
107
|
+
f"{self.account.hq}/partner/observed_detected", json=params, timeout=30
|
|
123
108
|
)
|
|
124
109
|
return res.json()
|
|
125
110
|
|
|
@@ -135,9 +120,9 @@ class PartnerController(HttpController):
|
|
|
135
120
|
params["limit"] = limit
|
|
136
121
|
if offset:
|
|
137
122
|
params["offset"] = offset
|
|
123
|
+
|
|
138
124
|
res = self.get(
|
|
139
125
|
f"{self.account.hq}/partner/advisories/{partner.name}",
|
|
140
|
-
headers=self.account.headers,
|
|
141
126
|
params=params,
|
|
142
127
|
timeout=30,
|
|
143
128
|
)
|
|
@@ -147,8 +132,6 @@ class PartnerController(HttpController):
|
|
|
147
132
|
def partner_groups(self, partner: Control, instance_id: str):
|
|
148
133
|
"""Get a list of partner groups"""
|
|
149
134
|
res = self.get(
|
|
150
|
-
f"{self.account.hq}/partner/groups/{partner.name}/{instance_id}",
|
|
151
|
-
headers=self.account.headers,
|
|
152
|
-
timeout=30,
|
|
135
|
+
f"{self.account.hq}/partner/groups/{partner.name}/{instance_id}", timeout=30
|
|
153
136
|
)
|
|
154
137
|
return res.json()
|
|
@@ -8,7 +8,5 @@ class ProbeController(HttpController):
|
|
|
8
8
|
|
|
9
9
|
def download(self, name: str, dos: str):
|
|
10
10
|
"""Download a probe executable"""
|
|
11
|
-
res = self.get(
|
|
12
|
-
f"{self.account.hq}/download/{name}", headers=dict(dos=dos), timeout=10
|
|
13
|
-
)
|
|
11
|
+
res = self.get(f"{self.account.hq}/download/{name}", headers=dict(dos=dos))
|
|
14
12
|
return res.text
|