pangea-sdk 4.3.0__tar.gz → 5.0.0__tar.gz

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 (59) hide show
  1. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/PKG-INFO +5 -5
  2. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/README.md +1 -1
  3. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/__init__.py +1 -1
  4. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/request.py +21 -14
  5. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/authz.py +2 -2
  6. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/intel.py +3 -0
  7. pangea_sdk-5.0.0/pangea/asyncio/services/vault.py +2240 -0
  8. pangea_sdk-5.0.0/pangea/crypto/rsa.py +135 -0
  9. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/request.py +41 -37
  10. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/audit/signing.py +5 -4
  11. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/authz.py +2 -2
  12. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/intel.py +5 -0
  13. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/sanitize.py +33 -2
  14. pangea_sdk-5.0.0/pangea/services/vault/models/asymmetric.py +169 -0
  15. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/vault/models/common.py +293 -171
  16. pangea_sdk-5.0.0/pangea/services/vault/models/keys.py +94 -0
  17. pangea_sdk-5.0.0/pangea/services/vault/models/secret.py +48 -0
  18. pangea_sdk-5.0.0/pangea/services/vault/models/symmetric.py +109 -0
  19. pangea_sdk-5.0.0/pangea/services/vault/vault.py +2237 -0
  20. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/tools.py +6 -7
  21. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/utils.py +3 -1
  22. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/verify_audit.py +4 -4
  23. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pyproject.toml +4 -4
  24. pangea_sdk-4.3.0/pangea/asyncio/services/vault.py +0 -1456
  25. pangea_sdk-4.3.0/pangea/crypto/rsa.py +0 -47
  26. pangea_sdk-4.3.0/pangea/services/vault/models/asymmetric.py +0 -69
  27. pangea_sdk-4.3.0/pangea/services/vault/models/secret.py +0 -24
  28. pangea_sdk-4.3.0/pangea/services/vault/models/symmetric.py +0 -67
  29. pangea_sdk-4.3.0/pangea/services/vault/vault.py +0 -1468
  30. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/__init__.py +0 -0
  31. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/file_uploader.py +0 -0
  32. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/__init__.py +0 -0
  33. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/audit.py +0 -0
  34. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/authn.py +0 -0
  35. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/base.py +0 -0
  36. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/embargo.py +0 -0
  37. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/file_scan.py +0 -0
  38. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/redact.py +0 -0
  39. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/sanitize.py +0 -0
  40. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/audit_logger.py +0 -0
  41. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/config.py +0 -0
  42. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/deep_verify.py +0 -0
  43. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/deprecated.py +0 -0
  44. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/dump_audit.py +0 -0
  45. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/exceptions.py +0 -0
  46. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/file_uploader.py +0 -0
  47. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/py.typed +0 -0
  48. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/response.py +0 -0
  49. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/__init__.py +0 -0
  50. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/audit/audit.py +0 -0
  51. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/audit/exceptions.py +0 -0
  52. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/audit/models.py +0 -0
  53. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/audit/util.py +0 -0
  54. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/authn/authn.py +0 -0
  55. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/authn/models.py +0 -0
  56. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/base.py +0 -0
  57. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/embargo.py +0 -0
  58. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/file_scan.py +0 -0
  59. {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/redact.py +0 -0
@@ -1,23 +1,23 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pangea-sdk
3
- Version: 4.3.0
3
+ Version: 5.0.0
4
4
  Summary: Pangea API SDK
5
5
  Home-page: https://pangea.cloud/docs/sdk/python/
6
6
  License: MIT
7
7
  Keywords: Pangea,SDK,Audit
8
8
  Author: Glenn Gallien
9
9
  Author-email: glenn.gallien@pangea.cloud
10
- Requires-Python: >=3.8.0,<4.0.0
10
+ Requires-Python: >=3.9.0,<4.0.0
11
11
  Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.8
14
13
  Classifier: Programming Language :: Python :: 3.9
15
14
  Classifier: Programming Language :: Python :: 3.10
16
15
  Classifier: Programming Language :: Python :: 3.11
17
16
  Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
18
  Classifier: Topic :: Software Development
19
19
  Classifier: Topic :: Software Development :: Libraries
20
- Requires-Dist: aiohttp (>=3.10.3,<4.0.0)
20
+ Requires-Dist: aiohttp (>=3.10.10,<4.0.0)
21
21
  Requires-Dist: cryptography (>=43.0.1,<44.0.0)
22
22
  Requires-Dist: deprecated (>=1.2.14,<2.0.0)
23
23
  Requires-Dist: google-crc32c (>=1.5.0,<2.0.0)
@@ -40,7 +40,7 @@ Description-Content-Type: text/markdown
40
40
 
41
41
  # Pangea Python SDK
42
42
 
43
- A Python SDK for integrating with Pangea services. Supports Python v3.8 and
43
+ A Python SDK for integrating with Pangea services. Supports Python v3.9 and
44
44
  above.
45
45
 
46
46
  ## Installation
@@ -9,7 +9,7 @@
9
9
 
10
10
  # Pangea Python SDK
11
11
 
12
- A Python SDK for integrating with Pangea services. Supports Python v3.8 and
12
+ A Python SDK for integrating with Pangea services. Supports Python v3.9 and
13
13
  above.
14
14
 
15
15
  ## Installation
@@ -1,4 +1,4 @@
1
- __version__ = "4.3.0"
1
+ __version__ = "5.0.0"
2
2
 
3
3
  from pangea.asyncio.request import PangeaRequestAsync
4
4
  from pangea.config import PangeaConfig
@@ -1,14 +1,16 @@
1
1
  # Copyright 2022 Pangea Cyber Corporation
2
2
  # Author: Pangea Cyber Corporation
3
+ from __future__ import annotations
3
4
 
4
5
  import asyncio
5
6
  import json
6
7
  import time
7
- from typing import Dict, List, Optional, Sequence, Tuple, Type, Union
8
+ from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union
8
9
 
9
10
  import aiohttp
10
11
  from aiohttp import FormData
11
- from typing_extensions import TypeVar
12
+ from pydantic import BaseModel
13
+ from typing_extensions import Any, TypeVar
12
14
 
13
15
  import pangea.exceptions as pe
14
16
  from pangea.request import MultipartResponse, PangeaRequestBase
@@ -31,7 +33,7 @@ class PangeaRequestAsync(PangeaRequestBase):
31
33
  self,
32
34
  endpoint: str,
33
35
  result_class: Type[TResult],
34
- data: Union[str, Dict] = {},
36
+ data: str | BaseModel | dict[str, Any] | None = None,
35
37
  files: Optional[List[Tuple]] = None,
36
38
  poll_result: bool = True,
37
39
  url: Optional[str] = None,
@@ -46,6 +48,13 @@ class PangeaRequestAsync(PangeaRequestBase):
46
48
  PangeaResponse which contains the response in its entirety and
47
49
  various properties to retrieve individual fields
48
50
  """
51
+
52
+ if isinstance(data, BaseModel):
53
+ data = data.model_dump(exclude_none=True)
54
+
55
+ if data is None:
56
+ data = {}
57
+
49
58
  if url is None:
50
59
  url = self._url(endpoint)
51
60
 
@@ -208,16 +217,16 @@ class PangeaRequestAsync(PangeaRequestBase):
208
217
  )
209
218
 
210
219
  return AttachedFile(filename=filename, file=await response.read(), content_type=content_type)
211
- else:
212
- raise pe.DownloadFileError(f"Failed to download file. Status: {response.status}", await response.text())
220
+ raise pe.DownloadFileError(f"Failed to download file. Status: {response.status}", await response.text())
213
221
 
214
- async def _get_pangea_json(self, reader: aiohttp.MultipartReader) -> Optional[Dict]:
222
+ async def _get_pangea_json(self, reader: aiohttp.multipart.MultipartResponseWrapper) -> Optional[Dict[str, Any]]:
215
223
  # Iterate through parts
216
224
  async for part in reader:
217
- return await part.json()
225
+ if isinstance(part, aiohttp.BodyPartReader):
226
+ return await part.json()
218
227
  return None
219
228
 
220
- async def _get_attached_files(self, reader: aiohttp.MultipartReader) -> List[AttachedFile]:
229
+ async def _get_attached_files(self, reader: aiohttp.multipart.MultipartResponseWrapper) -> List[AttachedFile]:
221
230
  files = []
222
231
  i = 0
223
232
 
@@ -228,7 +237,7 @@ class PangeaRequestAsync(PangeaRequestBase):
228
237
  if name is None:
229
238
  name = f"default_file_name_{i}"
230
239
  i += 1
231
- files.append(AttachedFile(name, await part.read(), content_type))
240
+ files.append(AttachedFile(name, await part.read(), content_type)) # type: ignore[union-attr]
232
241
 
233
242
  return files
234
243
 
@@ -236,13 +245,12 @@ class PangeaRequestAsync(PangeaRequestBase):
236
245
  # Parse the multipart response
237
246
  multipart_reader = aiohttp.MultipartReader.from_response(resp)
238
247
 
239
- pangea_json = await self._get_pangea_json(multipart_reader) # type: ignore[arg-type]
248
+ pangea_json = await self._get_pangea_json(multipart_reader)
240
249
  self.logger.debug(
241
250
  json.dumps({"service": self.service, "action": "multipart response", "response": pangea_json})
242
251
  )
243
252
 
244
- multipart_reader = multipart_reader.__aiter__()
245
- attached_files = await self._get_attached_files(multipart_reader) # type: ignore[arg-type]
253
+ attached_files = await self._get_attached_files(multipart_reader)
246
254
  return MultipartResponse(pangea_json, attached_files) # type: ignore[arg-type]
247
255
 
248
256
  async def _http_post(
@@ -368,8 +376,7 @@ class PangeaRequestAsync(PangeaRequestBase):
368
376
 
369
377
  if loop_resp.accepted_result is not None and not loop_resp.accepted_result.has_upload_url:
370
378
  return loop_resp
371
- else:
372
- raise loop_exc
379
+ raise loop_exc
373
380
 
374
381
  async def _handle_queued_result(self, response: PangeaResponse) -> PangeaResponse:
375
382
  if self._queued_retry_enabled and response.http_status == 202:
@@ -198,7 +198,7 @@ class AuthZAsync(ServiceBaseAsync):
198
198
  async def list_resources(
199
199
  self, type: str, action: str, subject: Subject, attributes: Optional[Dict[str, Any]] = None
200
200
  ) -> PangeaResponse[ListResourcesResult]:
201
- """List resources. (Beta)
201
+ """List resources.
202
202
 
203
203
  Given a type, action, and subject, list all the resources in the
204
204
  type that the subject has access to the action with.
@@ -233,7 +233,7 @@ class AuthZAsync(ServiceBaseAsync):
233
233
  async def list_subjects(
234
234
  self, resource: Resource, action: str, attributes: Optional[Dict[str, Any]] = None
235
235
  ) -> PangeaResponse[ListSubjectsResult]:
236
- """List subjects. (Beta)
236
+ """List subjects.
237
237
 
238
238
  Given a resource and an action, return the list of subjects who have
239
239
  access to the action for the given resource.
@@ -846,6 +846,7 @@ class UserIntelAsync(ServiceBaseAsync):
846
846
  usernames: Optional[List[str]] = None,
847
847
  ips: Optional[List[str]] = None,
848
848
  phone_numbers: Optional[List[str]] = None,
849
+ domains: Optional[List[str]] = None,
849
850
  start: Optional[str] = None,
850
851
  end: Optional[str] = None,
851
852
  verbose: Optional[bool] = None,
@@ -864,6 +865,7 @@ class UserIntelAsync(ServiceBaseAsync):
864
865
  usernames (List[str]): An username's list to search for
865
866
  ips (List[str]): An ip's list to search for
866
867
  phone_numbers (List[str]): A phone number's list to search for. minLength: 7, maxLength: 15.
868
+ domains (List[str]): Search for user under these domains.
867
869
  start (str): Earliest date for search
868
870
  end (str): Latest date for search
869
871
  verbose (bool, optional): Echo the API parameters in the response
@@ -886,6 +888,7 @@ class UserIntelAsync(ServiceBaseAsync):
886
888
  phone_numbers=phone_numbers,
887
889
  usernames=usernames,
888
890
  ips=ips,
891
+ domains=domains,
889
892
  provider=provider,
890
893
  start=start,
891
894
  end=end,