pangea-sdk 6.2.0b1__py3-none-any.whl → 6.3.0__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 +70 -169
- pangea/asyncio/services/__init__.py +2 -1
- pangea/asyncio/services/ai_guard.py +9 -12
- pangea/asyncio/services/audit.py +13 -307
- pangea/asyncio/services/authn.py +40 -32
- pangea/asyncio/services/authz.py +51 -17
- pangea/asyncio/services/base.py +4 -0
- pangea/asyncio/services/file_scan.py +8 -2
- pangea/asyncio/services/intel.py +26 -28
- pangea/asyncio/services/redact.py +11 -268
- pangea/asyncio/services/sanitize.py +5 -1
- pangea/asyncio/services/share.py +5 -1
- pangea/asyncio/services/vault.py +71 -55
- 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 +80 -200
- pangea/response.py +21 -18
- pangea/services/__init__.py +2 -1
- pangea/services/ai_guard.py +35 -24
- pangea/services/audit/audit.py +17 -314
- pangea/services/audit/models.py +69 -307
- pangea/services/audit/signing.py +1 -1
- pangea/services/audit/util.py +10 -10
- pangea/services/authn/authn.py +39 -31
- pangea/services/authn/models.py +183 -148
- pangea/services/authz.py +108 -60
- pangea/services/base.py +7 -4
- pangea/services/embargo.py +6 -0
- pangea/services/file_scan.py +8 -2
- pangea/services/intel.py +36 -19
- pangea/services/redact.py +14 -476
- 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 +15 -12
- pangea/services/vault/models/keys.py +4 -9
- pangea/services/vault/models/secret.py +3 -8
- pangea/services/vault/models/symmetric.py +4 -0
- pangea/services/vault/vault.py +69 -59
- 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.3.0.dist-info}/METADATA +36 -17
- pangea_sdk-6.3.0.dist-info/RECORD +60 -0
- {pangea_sdk-6.2.0b1.dist-info → pangea_sdk-6.3.0.dist-info}/WHEEL +1 -1
- pangea/asyncio/services/management.py +0 -576
- pangea/services/management.py +0 -720
- pangea_sdk-6.2.0b1.dist-info/RECORD +0 -62
pangea/asyncio/services/vault.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 collections.abc import Mapping
|
@@ -55,7 +59,6 @@ from pangea.services.vault.models.common import (
|
|
55
59
|
JWTVerifyResult,
|
56
60
|
ListRequest,
|
57
61
|
ListResult,
|
58
|
-
Metadata,
|
59
62
|
PangeaToken,
|
60
63
|
PangeaTokenRotateRequest,
|
61
64
|
RequestManualRotationState,
|
@@ -164,7 +167,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
164
167
|
Returns:
|
165
168
|
A PangeaResponse where the id of the deleted secret or key
|
166
169
|
is returned in the response.result field.
|
167
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault
|
170
|
+
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault/v1-general#/v1/delete-post).
|
168
171
|
|
169
172
|
Raises:
|
170
173
|
PangeaAPIException: If an API Error happens
|
@@ -197,7 +200,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
197
200
|
Returns:
|
198
201
|
A PangeaResponse where the secret or key
|
199
202
|
is returned in the response.result field.
|
200
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault
|
203
|
+
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault/v1-general#/v1/get-post).
|
201
204
|
|
202
205
|
Raises:
|
203
206
|
PangeaAPIException: If an API Error happens
|
@@ -283,7 +286,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
283
286
|
Returns:
|
284
287
|
A PangeaResponse where a list of secrets or keys
|
285
288
|
is returned in the response.result field.
|
286
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault
|
289
|
+
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault/v1-general#/v1/list-post).
|
287
290
|
|
288
291
|
Raises:
|
289
292
|
PangeaAPIException: If an API Error happens
|
@@ -315,7 +318,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
315
318
|
*,
|
316
319
|
name: str | None = None,
|
317
320
|
folder: str | None = None,
|
318
|
-
metadata:
|
321
|
+
metadata: Mapping[str, str] | None = None,
|
319
322
|
tags: Tags | None = None,
|
320
323
|
disabled_at: str | None = None,
|
321
324
|
enabled: bool | None = None,
|
@@ -345,7 +348,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
345
348
|
Returns:
|
346
349
|
A PangeaResponse where the item ID is returned in the
|
347
350
|
response.result field. Available response fields can be found in our
|
348
|
-
[API documentation](https://pangea.cloud/docs/api/vault
|
351
|
+
[API documentation](https://pangea.cloud/docs/api/vault/v1-general#/v1/update-post).
|
349
352
|
|
350
353
|
Raises:
|
351
354
|
PangeaAPIException: If an API Error happens
|
@@ -391,7 +394,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
391
394
|
result_class: type[TResult] = SecretStoreResult, # type: ignore[assignment]
|
392
395
|
name: str | None = None,
|
393
396
|
folder: str | None = None,
|
394
|
-
metadata:
|
397
|
+
metadata: Mapping[str, str] | None = None,
|
395
398
|
tags: Tags | None = None,
|
396
399
|
disabled_at: datetime.datetime | None = None,
|
397
400
|
**kwargs: Any,
|
@@ -416,22 +419,22 @@ class VaultAsync(ServiceBaseAsync):
|
|
416
419
|
*,
|
417
420
|
name: str | None = None,
|
418
421
|
folder: str | None = None,
|
419
|
-
metadata:
|
422
|
+
metadata: Mapping[str, str] | None = None,
|
420
423
|
tags: Tags | None = None,
|
421
424
|
disabled_at: datetime.datetime | None = None,
|
422
425
|
) -> PangeaResponse[Secret]:
|
423
426
|
"""
|
424
427
|
Store secret
|
425
428
|
|
426
|
-
Store a secret.
|
429
|
+
Store a secret as a Vault item.
|
427
430
|
|
428
431
|
Args:
|
429
|
-
secret:
|
430
|
-
name:
|
431
|
-
folder:
|
432
|
-
metadata:
|
433
|
-
tags:
|
434
|
-
disabled_at: Timestamp indicating when the item will be disabled
|
432
|
+
secret: Secret value
|
433
|
+
name: Name of the item
|
434
|
+
folder: Folder where the item is stored
|
435
|
+
metadata: Metadata provided by the user
|
436
|
+
tags: List of user-defined tags
|
437
|
+
disabled_at: Timestamp indicating when the item will be disabled
|
435
438
|
|
436
439
|
Raises:
|
437
440
|
PangeaAPIException: If an API Error happens
|
@@ -457,25 +460,38 @@ class VaultAsync(ServiceBaseAsync):
|
|
457
460
|
*,
|
458
461
|
name: str | None = None,
|
459
462
|
folder: str | None = None,
|
460
|
-
metadata:
|
463
|
+
metadata: Mapping[str, str] | None = None,
|
461
464
|
tags: Tags | None = None,
|
462
465
|
disabled_at: datetime.datetime | None = None,
|
463
466
|
rotation_frequency: str | None = None,
|
464
|
-
rotation_state:
|
467
|
+
rotation_state: Literal["deactivated", "destroyed", "inherited"] | None = None,
|
465
468
|
rotation_grace_period: str | None = None,
|
466
469
|
) -> PangeaResponse[PangeaToken]:
|
467
470
|
"""
|
468
471
|
Store secret
|
469
472
|
|
470
|
-
Store a Pangea token.
|
473
|
+
Store a Pangea token as a Vault item.
|
471
474
|
|
472
475
|
Args:
|
473
|
-
token:
|
474
|
-
name:
|
475
|
-
folder:
|
476
|
-
metadata:
|
477
|
-
tags:
|
478
|
-
disabled_at: Timestamp indicating when the item will be disabled
|
476
|
+
token: Pangea token value
|
477
|
+
name: Name of the item
|
478
|
+
folder: Folder where the item is stored
|
479
|
+
metadata: Metadata provided by the user
|
480
|
+
tags: List of user-defined tags
|
481
|
+
disabled_at: Timestamp indicating when the item will be disabled
|
482
|
+
rotation_frequency: Time interval between item rotations, provided
|
483
|
+
as a positive number followed by a time unit: `secs`, `mins`, `hrs`,
|
484
|
+
`days`, `weeks`, `months`, or `years`. You can use abbreviations
|
485
|
+
like `1d`. Omit to inherit from the parent folder or default
|
486
|
+
settings. Set to `never` to disable rotation.
|
487
|
+
rotation_state: Target state for the previous version after
|
488
|
+
rotation. Set to `inherited` to inherit from the parent folder
|
489
|
+
or default settings.
|
490
|
+
rotation_grace_period: Grace period for the previous version,
|
491
|
+
provided as a positive number followed by a time unit: `secs`,
|
492
|
+
`mins`, `hrs`, `days`, `weeks`, `months`, or `years`. You can use
|
493
|
+
abbreviations like `1d`. Omit to inherit from the parent folder or
|
494
|
+
default settings.
|
479
495
|
|
480
496
|
Raises:
|
481
497
|
PangeaAPIException: If an API Error happens
|
@@ -506,7 +522,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
506
522
|
*,
|
507
523
|
name: str | None = None,
|
508
524
|
folder: str | None = None,
|
509
|
-
metadata:
|
525
|
+
metadata: Mapping[str, str] | None = None,
|
510
526
|
tags: Tags | None = None,
|
511
527
|
disabled_at: datetime.datetime | None = None,
|
512
528
|
rotation_frequency: str | None = None,
|
@@ -668,7 +684,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
668
684
|
algorithm: AsymmetricKeySigningAlgorithm,
|
669
685
|
name: str | None = None,
|
670
686
|
folder: str | None = None,
|
671
|
-
metadata:
|
687
|
+
metadata: Mapping[str, str] | None = None,
|
672
688
|
tags: Tags | None = None,
|
673
689
|
rotation_frequency: str | None = None,
|
674
690
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -714,7 +730,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
714
730
|
algorithm: AsymmetricKeyEncryptionAlgorithm,
|
715
731
|
name: str | None = None,
|
716
732
|
folder: str | None = None,
|
717
|
-
metadata:
|
733
|
+
metadata: Mapping[str, str] | None = None,
|
718
734
|
tags: Tags | None = None,
|
719
735
|
rotation_frequency: str | None = None,
|
720
736
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -760,7 +776,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
760
776
|
algorithm: AsymmetricKeyJwtAlgorithm,
|
761
777
|
name: str | None = None,
|
762
778
|
folder: str | None = None,
|
763
|
-
metadata:
|
779
|
+
metadata: Mapping[str, str] | None = None,
|
764
780
|
tags: Tags | None = None,
|
765
781
|
rotation_frequency: str | None = None,
|
766
782
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -806,7 +822,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
806
822
|
algorithm: AsymmetricKeyPkiAlgorithm,
|
807
823
|
name: str | None = None,
|
808
824
|
folder: str | None = None,
|
809
|
-
metadata:
|
825
|
+
metadata: Mapping[str, str] | None = None,
|
810
826
|
tags: Tags | None = None,
|
811
827
|
rotation_frequency: str | None = None,
|
812
828
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -852,7 +868,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
852
868
|
algorithm: AsymmetricKeyAlgorithm,
|
853
869
|
name: str | None = None,
|
854
870
|
folder: str | None = None,
|
855
|
-
metadata:
|
871
|
+
metadata: Mapping[str, str] | None = None,
|
856
872
|
tags: Tags | None = None,
|
857
873
|
rotation_frequency: str | None = None,
|
858
874
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -898,7 +914,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
898
914
|
algorithm: SymmetricKeyEncryptionAlgorithm,
|
899
915
|
name: str | None = None,
|
900
916
|
folder: str | None = None,
|
901
|
-
metadata:
|
917
|
+
metadata: Mapping[str, str] | None = None,
|
902
918
|
tags: Tags | None = None,
|
903
919
|
rotation_frequency: str | None = None,
|
904
920
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -944,7 +960,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
944
960
|
algorithm: SymmetricKeyJwtAlgorithm,
|
945
961
|
name: str | None = None,
|
946
962
|
folder: str | None = None,
|
947
|
-
metadata:
|
963
|
+
metadata: Mapping[str, str] | None = None,
|
948
964
|
tags: Tags | None = None,
|
949
965
|
rotation_frequency: str | None = None,
|
950
966
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -990,7 +1006,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
990
1006
|
algorithm: SymmetricKeyFpeAlgorithm,
|
991
1007
|
name: str | None = None,
|
992
1008
|
folder: str | None = None,
|
993
|
-
metadata:
|
1009
|
+
metadata: Mapping[str, str] | None = None,
|
994
1010
|
tags: Tags | None = None,
|
995
1011
|
rotation_frequency: str | None = None,
|
996
1012
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -1036,7 +1052,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1036
1052
|
algorithm: SymmetricKeyAlgorithm,
|
1037
1053
|
name: str | None = None,
|
1038
1054
|
folder: str | None = None,
|
1039
|
-
metadata:
|
1055
|
+
metadata: Mapping[str, str] | None = None,
|
1040
1056
|
tags: Tags | None = None,
|
1041
1057
|
rotation_frequency: str | None = None,
|
1042
1058
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -1081,7 +1097,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1081
1097
|
algorithm: AsymmetricKeyAlgorithm | SymmetricKeyAlgorithm,
|
1082
1098
|
name: str | None = None,
|
1083
1099
|
folder: str | None = None,
|
1084
|
-
metadata:
|
1100
|
+
metadata: Mapping[str, str] | None = None,
|
1085
1101
|
tags: Tags | None = None,
|
1086
1102
|
rotation_frequency: str | None = None,
|
1087
1103
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -1147,7 +1163,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1147
1163
|
private_key: str,
|
1148
1164
|
name: str | None = None,
|
1149
1165
|
folder: str | None = None,
|
1150
|
-
metadata:
|
1166
|
+
metadata: Mapping[str, str] | None = None,
|
1151
1167
|
tags: Tags | None = None,
|
1152
1168
|
rotation_frequency: str | None = None,
|
1153
1169
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -1197,7 +1213,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1197
1213
|
private_key: str,
|
1198
1214
|
name: str | None = None,
|
1199
1215
|
folder: str | None = None,
|
1200
|
-
metadata:
|
1216
|
+
metadata: Mapping[str, str] | None = None,
|
1201
1217
|
tags: Tags | None = None,
|
1202
1218
|
rotation_frequency: str | None = None,
|
1203
1219
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -1247,7 +1263,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1247
1263
|
private_key: str,
|
1248
1264
|
name: str | None = None,
|
1249
1265
|
folder: str | None = None,
|
1250
|
-
metadata:
|
1266
|
+
metadata: Mapping[str, str] | None = None,
|
1251
1267
|
tags: Tags | None = None,
|
1252
1268
|
rotation_frequency: str | None = None,
|
1253
1269
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -1297,7 +1313,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1297
1313
|
private_key: str,
|
1298
1314
|
name: str | None = None,
|
1299
1315
|
folder: str | None = None,
|
1300
|
-
metadata:
|
1316
|
+
metadata: Mapping[str, str] | None = None,
|
1301
1317
|
tags: Tags | None = None,
|
1302
1318
|
rotation_frequency: str | None = None,
|
1303
1319
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -1346,7 +1362,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1346
1362
|
key: str,
|
1347
1363
|
name: str | None = None,
|
1348
1364
|
folder: str | None = None,
|
1349
|
-
metadata:
|
1365
|
+
metadata: Mapping[str, str] | None = None,
|
1350
1366
|
tags: Tags | None = None,
|
1351
1367
|
rotation_frequency: str | None = None,
|
1352
1368
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -1394,7 +1410,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1394
1410
|
key: str,
|
1395
1411
|
name: str | None = None,
|
1396
1412
|
folder: str | None = None,
|
1397
|
-
metadata:
|
1413
|
+
metadata: Mapping[str, str] | None = None,
|
1398
1414
|
tags: Tags | None = None,
|
1399
1415
|
rotation_frequency: str | None = None,
|
1400
1416
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -1442,7 +1458,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1442
1458
|
key: str,
|
1443
1459
|
name: str | None = None,
|
1444
1460
|
folder: str | None = None,
|
1445
|
-
metadata:
|
1461
|
+
metadata: Mapping[str, str] | None = None,
|
1446
1462
|
tags: Tags | None = None,
|
1447
1463
|
rotation_frequency: str | None = None,
|
1448
1464
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -1499,7 +1515,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1499
1515
|
key: str | None = None,
|
1500
1516
|
name: str | None = None,
|
1501
1517
|
folder: str | None = None,
|
1502
|
-
metadata:
|
1518
|
+
metadata: Mapping[str, str] | None = None,
|
1503
1519
|
tags: Tags | None = None,
|
1504
1520
|
rotation_frequency: str | None = None,
|
1505
1521
|
rotation_state: RequestRotationState | None = RequestRotationState.INHERITED,
|
@@ -1680,7 +1696,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1680
1696
|
Returns:
|
1681
1697
|
A PangeaResponse where the encrypted message in base64 is returned
|
1682
1698
|
in the response.result field. Available response fields can be found
|
1683
|
-
in our [API documentation](https://pangea.cloud/docs/api/vault
|
1699
|
+
in our [API documentation](https://pangea.cloud/docs/api/vault/v1-keys#/v1/key/encrypt-post).
|
1684
1700
|
|
1685
1701
|
Raises:
|
1686
1702
|
PangeaAPIException: If an API Error happens
|
@@ -1716,7 +1732,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1716
1732
|
|
1717
1733
|
Returns:
|
1718
1734
|
A PangeaResponse where the decrypted message in base64 is returned
|
1719
|
-
in the response.result field. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault
|
1735
|
+
in the response.result field. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault/v1-keys#/v1/key/decrypt-post).
|
1720
1736
|
|
1721
1737
|
Raises:
|
1722
1738
|
PangeaAPIException: If an API Error happens
|
@@ -1750,7 +1766,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1750
1766
|
Returns:
|
1751
1767
|
A PangeaResponse where the signature of the message in base64 is
|
1752
1768
|
returned in the response.result field. Available response fields can
|
1753
|
-
be found in our [API documentation](https://pangea.cloud/docs/api/vault
|
1769
|
+
be found in our [API documentation](https://pangea.cloud/docs/api/vault/v1-keys#/v1/key/sign-post).
|
1754
1770
|
|
1755
1771
|
Raises:
|
1756
1772
|
PangeaAPIException: If an API Error happens
|
@@ -1788,7 +1804,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1788
1804
|
Returns:
|
1789
1805
|
A PangeaResponse where the signature is valid
|
1790
1806
|
is returned in the response.result field.
|
1791
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault
|
1807
|
+
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault/v1-keys#/v1/key/verify-post).
|
1792
1808
|
|
1793
1809
|
Examples:
|
1794
1810
|
response = await vault.verify(
|
@@ -1826,7 +1842,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1826
1842
|
Returns:
|
1827
1843
|
A PangeaResponse where the signature is valid
|
1828
1844
|
is returned in the response.result field.
|
1829
|
-
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault
|
1845
|
+
Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/vault/v1-jwt#/v1/key/verify/jwt-post).
|
1830
1846
|
|
1831
1847
|
Examples:
|
1832
1848
|
response = await vault.jwt_verify(jws="ewogICJhbGciO...")
|
@@ -1851,7 +1867,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1851
1867
|
Returns:
|
1852
1868
|
A PangeaResponse where the signed JSON Web Token (JWS) is returned
|
1853
1869
|
in the response.result field. Available response fields can be found
|
1854
|
-
in our [API documentation](https://pangea.cloud/docs/api/vault
|
1870
|
+
in our [API documentation](https://pangea.cloud/docs/api/vault/v1-jwt#/v1/key/sign/jwt-post).
|
1855
1871
|
|
1856
1872
|
Examples:
|
1857
1873
|
response = await vault.jwt_sign(
|
@@ -1881,7 +1897,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1881
1897
|
Returns:
|
1882
1898
|
A PangeaResponse where the JSON Web Key Set (JWKS) object is
|
1883
1899
|
returned in the response.result field. Available response fields can
|
1884
|
-
be found in our [API documentation](https://pangea.cloud/docs/api/vault
|
1900
|
+
be found in our [API documentation](https://pangea.cloud/docs/api/vault/v1-jwt#/v1/get/jwk-post).
|
1885
1901
|
|
1886
1902
|
Examples:
|
1887
1903
|
response = await vault.jwk_get("pvi_p6g5i3gtbvqvc3u6zugab6qs6r63tqf5")
|
@@ -1913,7 +1929,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1913
1929
|
Returns:
|
1914
1930
|
A PangeaResponse where the state change object is returned in the
|
1915
1931
|
response.result field. Available response fields can be found in our
|
1916
|
-
[API documentation](https://pangea.cloud/docs/api/vault
|
1932
|
+
[API documentation](https://pangea.cloud/docs/api/vault/v1-general#/v1/state/change-post).
|
1917
1933
|
|
1918
1934
|
Raises:
|
1919
1935
|
PangeaAPIException: If an API Error happens
|
@@ -1937,7 +1953,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
1937
1953
|
name: str,
|
1938
1954
|
folder: str,
|
1939
1955
|
*,
|
1940
|
-
metadata:
|
1956
|
+
metadata: Mapping[str, str] | None = None,
|
1941
1957
|
tags: Tags | None = None,
|
1942
1958
|
rotation_frequency: str | None = None,
|
1943
1959
|
rotation_state: RequestRotationState = RequestRotationState.INHERITED,
|
@@ -2014,7 +2030,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
2014
2030
|
Returns:
|
2015
2031
|
A `PangeaResponse` where the encrypted object is returned in the
|
2016
2032
|
`response.result` field. Available response fields can be found in
|
2017
|
-
our [API documentation](https://pangea.cloud/docs/api/vault
|
2033
|
+
our [API documentation](https://pangea.cloud/docs/api/vault/v1-keys#/v1/key/encrypt/structured-post).
|
2018
2034
|
|
2019
2035
|
Raises:
|
2020
2036
|
PangeaAPIException: If an API error happens.
|
@@ -2070,7 +2086,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
2070
2086
|
Returns:
|
2071
2087
|
A `PangeaResponse` where the decrypted object is returned in the
|
2072
2088
|
`response.result` field. Available response fields can be found in
|
2073
|
-
our [API documentation](https://pangea.cloud/docs/api/vault
|
2089
|
+
our [API documentation](https://pangea.cloud/docs/api/vault/v1-keys#/v1/key/decrypt/structured-post).
|
2074
2090
|
|
2075
2091
|
Examples:
|
2076
2092
|
data = {"field1": [1, 2, "kxcbC9E9IlgVaSCChPWUMgUC3ko=", "6FfI/LCzatLRLNAc8SuBK/TDnGxp"], "field2": "data2"}
|
@@ -2214,7 +2230,7 @@ class VaultAsync(ServiceBaseAsync):
|
|
2214
2230
|
Returns:
|
2215
2231
|
A `PangeaResponse` where the exported key is returned in the
|
2216
2232
|
`response.result` field. Available response fields can be found in
|
2217
|
-
our [API documentation](https://pangea.cloud/docs/api/vault
|
2233
|
+
our [API documentation](https://pangea.cloud/docs/api/vault/v1-general#/v1/export-post).
|
2218
2234
|
|
2219
2235
|
Raises:
|
2220
2236
|
PangeaAPIException: If an API error happens.
|
pangea/audit_logger.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
import logging
|
4
6
|
|
5
7
|
import pangea.exceptions as pe
|
@@ -20,7 +22,7 @@ class AuditLogger(logging.Logger):
|
|
20
22
|
"""
|
21
23
|
|
22
24
|
def __init__(self, *args, **kwargs):
|
23
|
-
super(
|
25
|
+
super().__init__(*args, **kwargs)
|
24
26
|
|
25
27
|
def set_auditor(self, auditor: Audit):
|
26
28
|
"""Sets the internal Pangea Audit Service client instance
|
pangea/deep_verify.py
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
3
|
|
4
|
+
from __future__ import annotations
|
5
|
+
|
4
6
|
import argparse
|
5
7
|
import io
|
6
8
|
import math
|
7
9
|
import os
|
8
10
|
import sys
|
11
|
+
from collections.abc import Iterator
|
9
12
|
from itertools import groupby
|
10
|
-
from typing import
|
13
|
+
from typing import Optional, TypedDict, Union
|
11
14
|
|
12
15
|
import pangea.services.audit.util as audit_util
|
13
16
|
from pangea.services import Audit
|
@@ -24,7 +27,7 @@ class Errors(TypedDict):
|
|
24
27
|
buffer_missing: int
|
25
28
|
|
26
29
|
|
27
|
-
root_hashes:
|
30
|
+
root_hashes: dict[int, str] = {}
|
28
31
|
|
29
32
|
|
30
33
|
def num_lines(f: io.TextIOWrapper) -> int:
|
@@ -124,10 +127,7 @@ def get_root_hash(audit: Audit, tree_size: int) -> str:
|
|
124
127
|
|
125
128
|
|
126
129
|
def print_error(msg: str, level: str = "error"):
|
127
|
-
if level == "warning"
|
128
|
-
dot = "🟡"
|
129
|
-
else:
|
130
|
-
dot = "🔴"
|
130
|
+
dot = "🟡" if level == "warning" else "🔴"
|
131
131
|
print(f"{dot} {msg:200s}")
|
132
132
|
|
133
133
|
|
@@ -148,14 +148,14 @@ def deep_verify(audit: Audit, file: io.TextIOWrapper) -> Errors:
|
|
148
148
|
}
|
149
149
|
|
150
150
|
events = file_events(root_hashes, file)
|
151
|
-
events_by_idx: Union[
|
151
|
+
events_by_idx: Union[list[Event], Iterator[Event]]
|
152
152
|
cold_indexes = SequenceFollower()
|
153
153
|
for leaf_index, events_by_idx in groupby(events, lambda event: event.get("leaf_index")):
|
154
154
|
events_by_idx = list(events_by_idx)
|
155
155
|
buffer_lines = (cnt, cnt + len(events_by_idx) - 1)
|
156
156
|
if leaf_index is None:
|
157
157
|
print_error(
|
158
|
-
f"Lines {buffer_lines[0]}-{buffer_lines[1]} ({buffer_lines[1]-buffer_lines[0]+1}): Buffer was not persisted"
|
158
|
+
f"Lines {buffer_lines[0]}-{buffer_lines[1]} ({buffer_lines[1] - buffer_lines[0] + 1}): Buffer was not persisted"
|
159
159
|
)
|
160
160
|
errors["not_persisted"] += len(events_by_idx)
|
161
161
|
cnt += len(events_by_idx)
|
@@ -164,8 +164,8 @@ def deep_verify(audit: Audit, file: io.TextIOWrapper) -> Errors:
|
|
164
164
|
cold_indexes.add(leaf_index)
|
165
165
|
|
166
166
|
cold_path_size: Optional[int] = None
|
167
|
-
hot_indexes:
|
168
|
-
for
|
167
|
+
hot_indexes: set[int] = set()
|
168
|
+
for _i, event in enumerate(events_by_idx):
|
169
169
|
cnt += 1
|
170
170
|
tree_size = get_tree_size(event)
|
171
171
|
if tree_size not in root_hashes:
|
@@ -203,11 +203,11 @@ def deep_verify(audit: Audit, file: io.TextIOWrapper) -> Errors:
|
|
203
203
|
errors["missing"] += len(hot_indexes_diff)
|
204
204
|
print(f"missing hot indexes: {hot_indexes_diff}")
|
205
205
|
print(f"hot_indexes: {hot_indexes} ")
|
206
|
-
print(
|
206
|
+
print("events:")
|
207
207
|
for e in events_by_idx:
|
208
208
|
print(e)
|
209
209
|
print_error(
|
210
|
-
f"Lines {buffer_lines[0]}-{buffer_lines[1]} ({buffer_lines[1]-buffer_lines[0]}), Buffer #{cold_idx}: {len(hot_indexes_diff)} event(s) missing"
|
210
|
+
f"Lines {buffer_lines[0]}-{buffer_lines[1]} ({buffer_lines[1] - buffer_lines[0]}), Buffer #{cold_idx}: {len(hot_indexes_diff)} event(s) missing"
|
211
211
|
)
|
212
212
|
|
213
213
|
cold_holes = cold_indexes.holes()
|
@@ -232,7 +232,7 @@ def create_parser():
|
|
232
232
|
"-f",
|
233
233
|
required=True,
|
234
234
|
type=argparse.FileType("r"),
|
235
|
-
help="Event input file. Must be a collection of
|
235
|
+
help="Event input file. Must be a collection of JSON Objects separated by newlines",
|
236
236
|
)
|
237
237
|
return parser
|
238
238
|
|
pangea/deprecated.py
CHANGED
pangea/dump_audit.py
CHANGED
@@ -7,7 +7,6 @@ import json
|
|
7
7
|
import os
|
8
8
|
import sys
|
9
9
|
from datetime import datetime
|
10
|
-
from typing import Tuple
|
11
10
|
|
12
11
|
import dateutil.parser
|
13
12
|
|
@@ -103,7 +102,7 @@ def dump_after(audit: Audit, output: io.TextIOWrapper, start: datetime, last_eve
|
|
103
102
|
|
104
103
|
def dump_page(
|
105
104
|
audit: Audit, output: io.TextIOWrapper, start: datetime, end: datetime, first: bool = False
|
106
|
-
) ->
|
105
|
+
) -> tuple[datetime, int, bool, str, int]:
|
107
106
|
PAGE_SIZE = 1000
|
108
107
|
print(start, end)
|
109
108
|
print("Dumping...")
|
@@ -175,7 +174,7 @@ def parse_args(parser: argparse.ArgumentParser):
|
|
175
174
|
raise ValueError("domain missing")
|
176
175
|
|
177
176
|
if args.output is None:
|
178
|
-
args.output = open(f"dump-{datetime.now().strftime('%Y%m%d%H%M%S')}.jsonl", "w")
|
177
|
+
args.output = open(f"dump-{datetime.now().strftime('%Y%m%d%H%M%S')}.jsonl", "w") # noqa: SIM115
|
179
178
|
|
180
179
|
args.start = make_aware_datetime(args.start)
|
181
180
|
args.end = make_aware_datetime(args.end)
|
pangea/exceptions.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
3
|
|
4
|
+
# TODO: Modernize.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
4
7
|
from typing import List, Optional
|
5
8
|
|
6
9
|
from pangea.response import AcceptedResult, ErrorField, PangeaResponse
|
@@ -44,7 +47,7 @@ class PangeaAPIException(PangeaException):
|
|
44
47
|
response: PangeaResponse
|
45
48
|
|
46
49
|
def __init__(self, message: str, response: PangeaResponse):
|
47
|
-
super(
|
50
|
+
super().__init__(message)
|
48
51
|
self.response = response
|
49
52
|
|
50
53
|
@property
|
@@ -92,7 +95,7 @@ class UnauthorizedException(PangeaAPIException):
|
|
92
95
|
|
93
96
|
def __init__(self, service_name: str, response: PangeaResponse):
|
94
97
|
message = f"User is not authorized to access service {service_name}"
|
95
|
-
super(
|
98
|
+
super().__init__(message, response)
|
96
99
|
|
97
100
|
|
98
101
|
class NotFound(PangeaAPIException):
|
@@ -100,20 +103,20 @@ class NotFound(PangeaAPIException):
|
|
100
103
|
|
101
104
|
def __init__(self, url: str, response: PangeaResponse):
|
102
105
|
message = f"Resource url:'{url}' not found"
|
103
|
-
super(
|
106
|
+
super().__init__(message, response)
|
104
107
|
|
105
108
|
|
106
109
|
class ServiceNotEnabledException(PangeaAPIException):
|
107
110
|
def __init__(self, service_name: str, response: PangeaResponse):
|
108
111
|
message = f"{service_name} is not enabled. Go to console.pangea.cloud/service/{service_name} to enable"
|
109
|
-
super(
|
112
|
+
super().__init__(message, response)
|
110
113
|
|
111
114
|
|
112
115
|
class MissingConfigID(PangeaAPIException):
|
113
116
|
"""No config ID was provided in either token scopes or explicitly"""
|
114
117
|
|
115
118
|
def __init__(self, service_name: str, response: PangeaResponse):
|
116
|
-
super(
|
119
|
+
super().__init__(
|
117
120
|
f"Token did not contain a config scope for service {service_name}. Create a new token or provide a config ID explicitly in the service base",
|
118
121
|
response,
|
119
122
|
)
|