pangea-sdk 6.2.0b1__py3-none-any.whl → 6.2.0b2__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.
- pangea/__init__.py +9 -1
- pangea/asyncio/__init__.py +1 -0
- pangea/asyncio/file_uploader.py +4 -2
- pangea/asyncio/request.py +51 -21
- pangea/asyncio/services/__init__.py +2 -0
- pangea/asyncio/services/ai_guard.py +91 -2
- pangea/asyncio/services/audit.py +14 -8
- pangea/asyncio/services/authn.py +33 -23
- pangea/asyncio/services/authz.py +6 -6
- pangea/asyncio/services/base.py +4 -0
- pangea/asyncio/services/file_scan.py +8 -2
- pangea/asyncio/services/intel.py +6 -2
- pangea/asyncio/services/prompt_guard.py +112 -2
- pangea/asyncio/services/redact.py +7 -3
- pangea/asyncio/services/sanitize.py +5 -1
- pangea/asyncio/services/share.py +5 -1
- pangea/asyncio/services/vault.py +19 -15
- pangea/audit_logger.py +3 -1
- pangea/deep_verify.py +13 -13
- pangea/deprecated.py +1 -1
- pangea/dump_audit.py +2 -3
- pangea/exceptions.py +8 -5
- pangea/file_uploader.py +4 -0
- pangea/request.py +58 -41
- pangea/response.py +15 -12
- pangea/services/__init__.py +2 -0
- pangea/services/ai_guard.py +497 -16
- pangea/services/audit/audit.py +15 -13
- pangea/services/audit/models.py +4 -0
- pangea/services/audit/signing.py +1 -1
- pangea/services/audit/util.py +10 -10
- pangea/services/authn/authn.py +33 -23
- pangea/services/authn/models.py +3 -0
- pangea/services/authz.py +10 -6
- pangea/services/base.py +5 -1
- pangea/services/embargo.py +6 -0
- pangea/services/file_scan.py +8 -2
- pangea/services/intel.py +4 -0
- pangea/services/management.py +8 -8
- pangea/services/prompt_guard.py +193 -2
- pangea/services/redact.py +7 -3
- pangea/services/sanitize.py +5 -1
- pangea/services/share/share.py +13 -7
- pangea/services/vault/models/asymmetric.py +4 -0
- pangea/services/vault/models/common.py +4 -0
- pangea/services/vault/models/symmetric.py +4 -0
- pangea/services/vault/vault.py +17 -19
- pangea/tools.py +13 -9
- pangea/utils.py +3 -5
- pangea/verify_audit.py +23 -27
- {pangea_sdk-6.2.0b1.dist-info → pangea_sdk-6.2.0b2.dist-info}/METADATA +6 -6
- pangea_sdk-6.2.0b2.dist-info/RECORD +62 -0
- {pangea_sdk-6.2.0b1.dist-info → pangea_sdk-6.2.0b2.dist-info}/WHEEL +1 -1
- pangea_sdk-6.2.0b1.dist-info/RECORD +0 -62
pangea/services/audit/signing.py
CHANGED
@@ -81,7 +81,7 @@ class Signer:
|
|
81
81
|
with open(self.private_key_file, "rb") as file:
|
82
82
|
file_bytes = file.read()
|
83
83
|
except FileNotFoundError:
|
84
|
-
raise Exception(f"Error: Failed opening private key file {self.private_key_file}")
|
84
|
+
raise Exception(f"Error: Failed opening private key file {self.private_key_file}") from None
|
85
85
|
|
86
86
|
privkey = self._decode_private_key(file_bytes)
|
87
87
|
for cls, signer in signers.items():
|
pangea/services/audit/util.py
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Modernize.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
3
9
|
import base64
|
4
10
|
import json
|
5
11
|
import logging
|
@@ -155,9 +161,9 @@ def verify_membership_proof(node_hash: Hash, root_hash: Hash, proof: MembershipP
|
|
155
161
|
def normalize_log(data: dict) -> dict:
|
156
162
|
ans = {}
|
157
163
|
for key in data:
|
158
|
-
if
|
164
|
+
if isinstance(data[key], datetime):
|
159
165
|
ans[key] = format_datetime(data[key])
|
160
|
-
elif
|
166
|
+
elif isinstance(data[key], dict):
|
161
167
|
ans[key] = normalize_log(data[key]) # type: ignore[assignment]
|
162
168
|
else:
|
163
169
|
ans[key] = data[key]
|
@@ -223,9 +229,7 @@ def get_arweave_published_roots(tree_name: str, tree_sizes: Collection[int]) ->
|
|
223
229
|
}
|
224
230
|
}
|
225
231
|
}
|
226
|
-
""".replace(
|
227
|
-
"{tree_sizes}", ", ".join(f'"{tree_size}"' for tree_size in tree_sizes)
|
228
|
-
).replace(
|
232
|
+
""".replace("{tree_sizes}", ", ".join(f'"{tree_size}"' for tree_size in tree_sizes)).replace(
|
229
233
|
"{tree_name}", tree_name
|
230
234
|
)
|
231
235
|
|
@@ -273,8 +277,4 @@ def verify_consistency_proof(new_root: Hash, prev_root: Hash, proof: Consistency
|
|
273
277
|
return False
|
274
278
|
|
275
279
|
logger.debug("Verifying the proofs for the new root")
|
276
|
-
for item in proof
|
277
|
-
if not verify_membership_proof(item.node_hash, new_root, item.proof):
|
278
|
-
return False
|
279
|
-
|
280
|
-
return True
|
280
|
+
return all(verify_membership_proof(item.node_hash, new_root, item.proof) for item in proof)
|
pangea/services/authn/authn.py
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Modernize.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
3
7
|
from __future__ import annotations
|
4
8
|
|
5
9
|
from typing import Dict, List, Literal, Optional, Union
|
@@ -128,7 +132,7 @@ class AuthN(ServiceBase):
|
|
128
132
|
Returns:
|
129
133
|
A PangeaResponse with a list of sessions in the response.result field.
|
130
134
|
Available response fields can be found in our
|
131
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/session/list).
|
135
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/session/list-post).
|
132
136
|
|
133
137
|
Examples:
|
134
138
|
response = authn.session.list()
|
@@ -192,7 +196,7 @@ class AuthN(ServiceBase):
|
|
192
196
|
Returns:
|
193
197
|
A PangeaResponse with credentials for a login session in the response.result field.
|
194
198
|
Available response fields can be found in our
|
195
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/client/userinfo).
|
199
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/client/userinfo-post).
|
196
200
|
|
197
201
|
Examples:
|
198
202
|
response = authn.client.userinfo(
|
@@ -217,7 +221,7 @@ class AuthN(ServiceBase):
|
|
217
221
|
Returns:
|
218
222
|
A PangeaResponse with jwt verification keys in the response.result field.
|
219
223
|
Available response fields can be found in our
|
220
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/jwt#/v2/client/jwks).
|
224
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/jwt#/v2/client/jwks-post).
|
221
225
|
|
222
226
|
Examples:
|
223
227
|
response = authn.client.jwks()
|
@@ -290,7 +294,7 @@ class AuthN(ServiceBase):
|
|
290
294
|
Returns:
|
291
295
|
A PangeaResponse with a list of sessions in the response.result field.
|
292
296
|
Available response fields can be found in our
|
293
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/client/session/list).
|
297
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/client/session/list-post).
|
294
298
|
|
295
299
|
Examples:
|
296
300
|
response = authn.client.session.list(
|
@@ -349,7 +353,7 @@ class AuthN(ServiceBase):
|
|
349
353
|
Returns:
|
350
354
|
A PangeaResponse with credentials for a login session in the response.result field.
|
351
355
|
Available response fields can be found in our
|
352
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/client/session/refresh).
|
356
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/session#/v2/client/session/refresh-post).
|
353
357
|
|
354
358
|
Examples:
|
355
359
|
response = authn.client.session.refresh(
|
@@ -447,7 +451,7 @@ class AuthN(ServiceBase):
|
|
447
451
|
Returns:
|
448
452
|
A PangeaResponse with a token and its information in the response.result field.
|
449
453
|
Available response fields can be found in our
|
450
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/client/token/check).
|
454
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/client/token/check-post).
|
451
455
|
|
452
456
|
Examples:
|
453
457
|
response = authn.client.token_endpoints.check(
|
@@ -496,7 +500,7 @@ class AuthN(ServiceBase):
|
|
496
500
|
Returns:
|
497
501
|
A PangeaResponse with a user and its information in the response.result field.
|
498
502
|
Available response fields can be found in our
|
499
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/create).
|
503
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/create-post).
|
500
504
|
|
501
505
|
Examples:
|
502
506
|
response = authn.user.create(
|
@@ -561,7 +565,7 @@ class AuthN(ServiceBase):
|
|
561
565
|
Returns:
|
562
566
|
A PangeaResponse with a pending user invitation in the response.result field.
|
563
567
|
Available response fields can be found in our
|
564
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/invite#/v2/user/invite).
|
568
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/invite#/v2/user/invite-post).
|
565
569
|
|
566
570
|
Examples:
|
567
571
|
response = authn.user.invite(
|
@@ -606,7 +610,7 @@ class AuthN(ServiceBase):
|
|
606
610
|
Returns:
|
607
611
|
A PangeaResponse with a user and its information in the response.result field.
|
608
612
|
Available response fields can be found in our
|
609
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/update).
|
613
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/update-post).
|
610
614
|
|
611
615
|
Examples:
|
612
616
|
response = authn.user.update(
|
@@ -649,7 +653,7 @@ class AuthN(ServiceBase):
|
|
649
653
|
Returns:
|
650
654
|
A PangeaResponse with a list of users in the response.result field.
|
651
655
|
Available response fields can be found in our
|
652
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/list).
|
656
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/list-post).
|
653
657
|
|
654
658
|
Examples:
|
655
659
|
response = authn.user.list()
|
@@ -703,7 +707,7 @@ class AuthN(ServiceBase):
|
|
703
707
|
Returns:
|
704
708
|
A PangeaResponse with a list of pending user invitations in the response.result field.
|
705
709
|
Available response fields can be found in our
|
706
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/invite#/v2/user/invite/list).
|
710
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/invite#/v2/user/invite/list-post).
|
707
711
|
Examples:
|
708
712
|
response = authn.user.invites.list()
|
709
713
|
"""
|
@@ -807,7 +811,7 @@ class AuthN(ServiceBase):
|
|
807
811
|
Returns:
|
808
812
|
A PangeaResponse with a list of authenticators in the response.result field.
|
809
813
|
Available response fields can be found in our
|
810
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/authenticators/list).
|
814
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/authenticators/list-post).
|
811
815
|
|
812
816
|
Examples:
|
813
817
|
response = authn.user.authenticators.list(
|
@@ -850,7 +854,7 @@ class AuthN(ServiceBase):
|
|
850
854
|
Returns:
|
851
855
|
A PangeaResponse with a user and its information in the response.result field.
|
852
856
|
Available response fields can be found in our
|
853
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/profile/get).
|
857
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/profile/get-post).
|
854
858
|
|
855
859
|
Examples:
|
856
860
|
response = authn.user.profile.get(
|
@@ -886,7 +890,7 @@ class AuthN(ServiceBase):
|
|
886
890
|
Returns:
|
887
891
|
A PangeaResponse with a user and its information in the response.result field.
|
888
892
|
Available response fields can be found in our
|
889
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/profile/update).
|
893
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/user#/v2/user/profile/update-post).
|
890
894
|
|
891
895
|
Examples:
|
892
896
|
response = authn.user.profile.update(
|
@@ -980,7 +984,7 @@ class AuthN(ServiceBase):
|
|
980
984
|
Returns:
|
981
985
|
A PangeaResponse with credentials for a login session in the response.result field.
|
982
986
|
Available response fields can be found in our
|
983
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/complete).
|
987
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/complete-post).
|
984
988
|
|
985
989
|
Examples:
|
986
990
|
response = authn.flow.complete(
|
@@ -991,7 +995,10 @@ class AuthN(ServiceBase):
|
|
991
995
|
return self.request.post("v2/flow/complete", m.FlowCompleteResult, data=input.model_dump(exclude_none=True))
|
992
996
|
|
993
997
|
def restart(
|
994
|
-
self,
|
998
|
+
self,
|
999
|
+
flow_id: str,
|
1000
|
+
choice: m.FlowChoice,
|
1001
|
+
data: m.FlowRestartData = {}, # noqa: B006
|
995
1002
|
) -> PangeaResponse[m.FlowRestartResult]:
|
996
1003
|
"""
|
997
1004
|
Restart a sign-up/sign-in flow
|
@@ -1009,7 +1016,7 @@ class AuthN(ServiceBase):
|
|
1009
1016
|
A PangeaResponse with information about next steps needed
|
1010
1017
|
to complete a flow in the response.result field.
|
1011
1018
|
Available response fields can be found in our
|
1012
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/restart).
|
1019
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/restart-post).
|
1013
1020
|
|
1014
1021
|
Examples:
|
1015
1022
|
response = authn.flow.restart(
|
@@ -1046,7 +1053,7 @@ class AuthN(ServiceBase):
|
|
1046
1053
|
A PangeaResponse with information about next steps needed
|
1047
1054
|
to complete a flow in the response.result field.
|
1048
1055
|
Available response fields can be found in our
|
1049
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/start).
|
1056
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/start-post).
|
1050
1057
|
|
1051
1058
|
Examples:
|
1052
1059
|
response = authn.flow.start(
|
@@ -1062,7 +1069,10 @@ class AuthN(ServiceBase):
|
|
1062
1069
|
return self.request.post("v2/flow/start", m.FlowStartResult, data=input.model_dump(exclude_none=True))
|
1063
1070
|
|
1064
1071
|
def update(
|
1065
|
-
self,
|
1072
|
+
self,
|
1073
|
+
flow_id: str,
|
1074
|
+
choice: m.FlowChoice,
|
1075
|
+
data: m.FlowUpdateData = {}, # noqa: B006
|
1066
1076
|
) -> PangeaResponse[m.FlowUpdateResult]:
|
1067
1077
|
"""
|
1068
1078
|
Update a sign-up/sign-in flow
|
@@ -1080,7 +1090,7 @@ class AuthN(ServiceBase):
|
|
1080
1090
|
A PangeaResponse with information about next steps needed
|
1081
1091
|
to complete a flow in the response.result field.
|
1082
1092
|
Available response fields can be found in our
|
1083
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/update).
|
1093
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/flow#/v2/flow/update-post).
|
1084
1094
|
|
1085
1095
|
Examples:
|
1086
1096
|
response = authn.flow.update(
|
@@ -1125,7 +1135,7 @@ class AuthN(ServiceBase):
|
|
1125
1135
|
Returns:
|
1126
1136
|
A PangeaResponse with a EULA object in the response.result field.
|
1127
1137
|
Available response fields can be found in our
|
1128
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/create).
|
1138
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/create-post).
|
1129
1139
|
|
1130
1140
|
Examples:
|
1131
1141
|
response = authn.agreements.create(
|
@@ -1192,7 +1202,7 @@ class AuthN(ServiceBase):
|
|
1192
1202
|
Returns:
|
1193
1203
|
A PangeaResponse with a list of EULA objects in the response.result field.
|
1194
1204
|
Available response fields can be found in our
|
1195
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/list).
|
1205
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/list-post).
|
1196
1206
|
|
1197
1207
|
Examples:
|
1198
1208
|
response = authn.agreements.list()
|
@@ -1231,7 +1241,7 @@ class AuthN(ServiceBase):
|
|
1231
1241
|
Returns:
|
1232
1242
|
A PangeaResponse with the updated EULA object in the response.result field.
|
1233
1243
|
Available response fields can be found in our
|
1234
|
-
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/update).
|
1244
|
+
[API Documentation](https://pangea.cloud/docs/api/authn/agreements#/v2/agreements/update-post).
|
1235
1245
|
|
1236
1246
|
Examples:
|
1237
1247
|
response = authn.agreements.update(
|
pangea/services/authn/models.py
CHANGED
pangea/services/authz.py
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Use `list` instead of `List`.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
3
7
|
from __future__ import annotations
|
4
8
|
|
5
9
|
import enum
|
@@ -243,7 +247,7 @@ class AuthZ(ServiceBase):
|
|
243
247
|
Returns:
|
244
248
|
Pangea Response with empty result.
|
245
249
|
Available response fields can be found in our
|
246
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/create).
|
250
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/create-post).
|
247
251
|
|
248
252
|
Examples:
|
249
253
|
response = authz.tuple_create(
|
@@ -287,7 +291,7 @@ class AuthZ(ServiceBase):
|
|
287
291
|
Returns:
|
288
292
|
Pangea Response with a list of tuples and the last token.
|
289
293
|
Available response fields can be found in our
|
290
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/list).
|
294
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/list-post).
|
291
295
|
|
292
296
|
Examples:
|
293
297
|
authz.tuple_list(TupleListFilter(subject_type="user", subject_id="user_1"))
|
@@ -311,7 +315,7 @@ class AuthZ(ServiceBase):
|
|
311
315
|
Returns:
|
312
316
|
Pangea Response with empty result.
|
313
317
|
Available response fields can be found in our
|
314
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/delete).
|
318
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/delete-post).
|
315
319
|
|
316
320
|
Examples:
|
317
321
|
response = authz.tuple_delete(
|
@@ -353,7 +357,7 @@ class AuthZ(ServiceBase):
|
|
353
357
|
Returns:
|
354
358
|
Pangea Response with the result of the check.
|
355
359
|
Available response fields can be found in our
|
356
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/check).
|
360
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/check-post).
|
357
361
|
|
358
362
|
Examples:
|
359
363
|
response = authz.check(
|
@@ -387,7 +391,7 @@ class AuthZ(ServiceBase):
|
|
387
391
|
Returns:
|
388
392
|
Pangea Response with a list of resource IDs.
|
389
393
|
Available response fields can be found in our
|
390
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-resources).
|
394
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-resources-post).
|
391
395
|
|
392
396
|
Examples:
|
393
397
|
authz.list_resources(
|
@@ -422,7 +426,7 @@ class AuthZ(ServiceBase):
|
|
422
426
|
Returns:
|
423
427
|
Pangea Response with a list of subjects.
|
424
428
|
Available response fields can be found in our
|
425
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-subjects).
|
429
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-subjects-post).
|
426
430
|
|
427
431
|
Examples:
|
428
432
|
response = authz.list_subjects(
|
pangea/services/base.py
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Modernize.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
3
7
|
from __future__ import annotations
|
4
8
|
|
5
9
|
import copy
|
@@ -17,7 +21,7 @@ from pangea.response import AttachedFile, PangeaResponse, PangeaResponseResult
|
|
17
21
|
TResult = TypeVar("TResult", bound=PangeaResponseResult, default=PangeaResponseResult)
|
18
22
|
|
19
23
|
|
20
|
-
class ServiceBase
|
24
|
+
class ServiceBase:
|
21
25
|
service_name: str = "base"
|
22
26
|
|
23
27
|
def __init__(
|
pangea/services/embargo.py
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Use `list` instead of `List`.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
3
9
|
from typing import Any, Dict, List
|
4
10
|
|
5
11
|
from pangea.response import APIRequestModel, APIResponseModel, PangeaResponse, PangeaResponseResult
|
pangea/services/file_scan.py
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Use `list` instead of `List`.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
3
9
|
import io
|
4
10
|
import logging
|
5
11
|
from typing import Dict, List, Optional, Tuple
|
@@ -52,7 +58,7 @@ class FileScan(ServiceBase):
|
|
52
58
|
"""FileScan service client.
|
53
59
|
|
54
60
|
Provides methods to interact with Pangea FileScan Service:
|
55
|
-
https://pangea.cloud/docs/api/
|
61
|
+
https://pangea.cloud/docs/api/file-scan
|
56
62
|
|
57
63
|
The following information is needed:
|
58
64
|
PANGEA_TOKEN - service token which can be found on the Pangea User
|
@@ -133,7 +139,7 @@ class FileScan(ServiceBase):
|
|
133
139
|
files: Optional[List[Tuple]] = None
|
134
140
|
if file or file_path:
|
135
141
|
if file_path:
|
136
|
-
file = open(file_path, "rb")
|
142
|
+
file = open(file_path, "rb") # noqa: SIM115
|
137
143
|
if transfer_method == TransferMethod.POST_URL:
|
138
144
|
params = get_file_upload_params(file) # type: ignore[arg-type]
|
139
145
|
crc = params.crc_hex
|
pangea/services/intel.py
CHANGED
pangea/services/management.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
from collections.abc import Sequence
|
4
|
-
from typing import
|
4
|
+
from typing import Literal, Optional, Union, overload
|
5
5
|
|
6
6
|
from pydantic import Field
|
7
7
|
|
@@ -57,7 +57,7 @@ class ListProjectsFilter(APIRequestModel):
|
|
57
57
|
|
58
58
|
|
59
59
|
class ListProjectsResult(PangeaResponseResult):
|
60
|
-
results:
|
60
|
+
results: list[Project]
|
61
61
|
"""A list of projects"""
|
62
62
|
|
63
63
|
count: int
|
@@ -82,11 +82,11 @@ class AccessClientInfo(PangeaResponseResult):
|
|
82
82
|
"""A list of space separated scope"""
|
83
83
|
token_endpoint_auth_method: AccessClientTokenAuth
|
84
84
|
"""The authentication method for the token endpoint."""
|
85
|
-
redirect_uris:
|
85
|
+
redirect_uris: list[str]
|
86
86
|
"""A list of allowed redirect URIs for the client."""
|
87
|
-
grant_types:
|
87
|
+
grant_types: list[str]
|
88
88
|
"""A list of OAuth grant types that the client can use."""
|
89
|
-
response_types:
|
89
|
+
response_types: list[Optional[str]]
|
90
90
|
"""A list of OAuth response types that the client can use."""
|
91
91
|
client_token_expires_in: Optional[int] = None
|
92
92
|
"""A positive time duration in seconds or null"""
|
@@ -124,7 +124,7 @@ class AccessRole(PangeaResponseResult):
|
|
124
124
|
|
125
125
|
|
126
126
|
class AccessClientListResult(PangeaResponseResult):
|
127
|
-
clients:
|
127
|
+
clients: list[AccessClientInfo]
|
128
128
|
count: int
|
129
129
|
last: Optional[str] = None
|
130
130
|
|
@@ -163,13 +163,13 @@ class AccessClientSecretInfoWithMetadata(PangeaResponseResult):
|
|
163
163
|
|
164
164
|
|
165
165
|
class AccessClientSecretInfoListResult(PangeaResponseResult):
|
166
|
-
client_secrets:
|
166
|
+
client_secrets: list[AccessClientSecretInfoWithMetadata] = Field(alias="client-secrets")
|
167
167
|
count: int
|
168
168
|
last: Optional[str] = None
|
169
169
|
|
170
170
|
|
171
171
|
class AccessRolesListResult(PangeaResponseResult):
|
172
|
-
roles:
|
172
|
+
roles: list[AccessRole]
|
173
173
|
count: int
|
174
174
|
last: Optional[str] = None
|
175
175
|
|