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.
Files changed (55) hide show
  1. pangea/__init__.py +9 -1
  2. pangea/asyncio/__init__.py +1 -0
  3. pangea/asyncio/file_uploader.py +4 -2
  4. pangea/asyncio/request.py +70 -169
  5. pangea/asyncio/services/__init__.py +2 -1
  6. pangea/asyncio/services/ai_guard.py +9 -12
  7. pangea/asyncio/services/audit.py +13 -307
  8. pangea/asyncio/services/authn.py +40 -32
  9. pangea/asyncio/services/authz.py +51 -17
  10. pangea/asyncio/services/base.py +4 -0
  11. pangea/asyncio/services/file_scan.py +8 -2
  12. pangea/asyncio/services/intel.py +26 -28
  13. pangea/asyncio/services/redact.py +11 -268
  14. pangea/asyncio/services/sanitize.py +5 -1
  15. pangea/asyncio/services/share.py +5 -1
  16. pangea/asyncio/services/vault.py +71 -55
  17. pangea/audit_logger.py +3 -1
  18. pangea/deep_verify.py +13 -13
  19. pangea/deprecated.py +1 -1
  20. pangea/dump_audit.py +2 -3
  21. pangea/exceptions.py +8 -5
  22. pangea/file_uploader.py +4 -0
  23. pangea/request.py +80 -200
  24. pangea/response.py +21 -18
  25. pangea/services/__init__.py +2 -1
  26. pangea/services/ai_guard.py +35 -24
  27. pangea/services/audit/audit.py +17 -314
  28. pangea/services/audit/models.py +69 -307
  29. pangea/services/audit/signing.py +1 -1
  30. pangea/services/audit/util.py +10 -10
  31. pangea/services/authn/authn.py +39 -31
  32. pangea/services/authn/models.py +183 -148
  33. pangea/services/authz.py +108 -60
  34. pangea/services/base.py +7 -4
  35. pangea/services/embargo.py +6 -0
  36. pangea/services/file_scan.py +8 -2
  37. pangea/services/intel.py +36 -19
  38. pangea/services/redact.py +14 -476
  39. pangea/services/sanitize.py +5 -1
  40. pangea/services/share/share.py +13 -7
  41. pangea/services/vault/models/asymmetric.py +4 -0
  42. pangea/services/vault/models/common.py +15 -12
  43. pangea/services/vault/models/keys.py +4 -9
  44. pangea/services/vault/models/secret.py +3 -8
  45. pangea/services/vault/models/symmetric.py +4 -0
  46. pangea/services/vault/vault.py +69 -59
  47. pangea/tools.py +13 -9
  48. pangea/utils.py +3 -5
  49. pangea/verify_audit.py +23 -27
  50. {pangea_sdk-6.2.0b1.dist-info → pangea_sdk-6.3.0.dist-info}/METADATA +36 -17
  51. pangea_sdk-6.3.0.dist-info/RECORD +60 -0
  52. {pangea_sdk-6.2.0b1.dist-info → pangea_sdk-6.3.0.dist-info}/WHEEL +1 -1
  53. pangea/asyncio/services/management.py +0 -576
  54. pangea/services/management.py +0 -720
  55. pangea_sdk-6.2.0b1.dist-info/RECORD +0 -62
@@ -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#delete).
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#retrieve).
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#list).
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: Metadata | None = None,
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#update).
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: Metadata | None = None,
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: Metadata | None = None,
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: The secret value.
430
- name: The name of this item.
431
- folder: The folder where this item is stored.
432
- metadata: User-provided metadata.
433
- tags: A list of user-defined 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: Metadata | None = None,
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: RotationState | None = None,
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: The Pangea token value.
474
- name: The name of this item.
475
- folder: The folder where this item is stored.
476
- metadata: User-provided metadata.
477
- tags: A list of user-defined 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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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: Metadata | None = None,
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#encrypt).
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#decrypt).
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#sign).
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#verify).
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#verify-jwt).
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#sign-a-jwt).
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#retrieve-jwk).
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#change-state).
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: Metadata | None = None,
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#encrypt-structured).
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#decrypt-structured).
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#export).
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(AuditLogger, self).__init__(*args, **kwargs)
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 Dict, Iterator, List, Optional, Set, TypedDict, Union
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: Dict[int, str] = {}
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[List[Event], Iterator[Event]]
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: Set[int] = set()
168
- for i, event in enumerate(events_by_idx):
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(f"events:")
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 " "JSON Objects separated by newlines",
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
@@ -19,7 +19,7 @@ def pangea_deprecated(*args, **kwargs):
19
19
  def wrapper(*iargs, **ikwargs):
20
20
  return deprecated(*args, **kwargs)(f)(*iargs, **ikwargs)
21
21
 
22
- setattr(wrapper, "_deprecated", kwargs)
22
+ wrapper._deprecated = kwargs
23
23
  return wrapper
24
24
 
25
25
  return decorator
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
- ) -> Tuple[datetime, int, bool, str, int]:
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(PangeaAPIException, self).__init__(message)
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(UnauthorizedException, self).__init__(message, response)
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(NotFound, self).__init__(message, response)
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(ServiceNotEnabledException, self).__init__(message, response)
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(MissingConfigID, self).__init__(
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
  )
pangea/file_uploader.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
  import io
4
8
  import logging
5
9
  from typing import Dict, Optional