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.
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/PKG-INFO +5 -5
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/README.md +1 -1
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/__init__.py +1 -1
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/request.py +21 -14
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/authz.py +2 -2
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/intel.py +3 -0
- pangea_sdk-5.0.0/pangea/asyncio/services/vault.py +2240 -0
- pangea_sdk-5.0.0/pangea/crypto/rsa.py +135 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/request.py +41 -37
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/audit/signing.py +5 -4
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/authz.py +2 -2
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/intel.py +5 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/sanitize.py +33 -2
- pangea_sdk-5.0.0/pangea/services/vault/models/asymmetric.py +169 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/vault/models/common.py +293 -171
- pangea_sdk-5.0.0/pangea/services/vault/models/keys.py +94 -0
- pangea_sdk-5.0.0/pangea/services/vault/models/secret.py +48 -0
- pangea_sdk-5.0.0/pangea/services/vault/models/symmetric.py +109 -0
- pangea_sdk-5.0.0/pangea/services/vault/vault.py +2237 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/tools.py +6 -7
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/utils.py +3 -1
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/verify_audit.py +4 -4
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pyproject.toml +4 -4
- pangea_sdk-4.3.0/pangea/asyncio/services/vault.py +0 -1456
- pangea_sdk-4.3.0/pangea/crypto/rsa.py +0 -47
- pangea_sdk-4.3.0/pangea/services/vault/models/asymmetric.py +0 -69
- pangea_sdk-4.3.0/pangea/services/vault/models/secret.py +0 -24
- pangea_sdk-4.3.0/pangea/services/vault/models/symmetric.py +0 -67
- pangea_sdk-4.3.0/pangea/services/vault/vault.py +0 -1468
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/__init__.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/file_uploader.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/__init__.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/audit.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/authn.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/base.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/embargo.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/file_scan.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/redact.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/asyncio/services/sanitize.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/audit_logger.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/config.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/deep_verify.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/deprecated.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/dump_audit.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/exceptions.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/file_uploader.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/py.typed +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/response.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/__init__.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/audit/audit.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/audit/exceptions.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/audit/models.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/audit/util.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/authn/authn.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/authn/models.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/base.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/embargo.py +0 -0
- {pangea_sdk-4.3.0 → pangea_sdk-5.0.0}/pangea/services/file_scan.py +0 -0
- {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:
|
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.
|
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.
|
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.
|
43
|
+
A Python SDK for integrating with Pangea services. Supports Python v3.9 and
|
44
44
|
above.
|
45
45
|
|
46
46
|
## Installation
|
@@ -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
|
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:
|
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
|
-
|
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.
|
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
|
-
|
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.
|
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)
|
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
|
-
|
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
|
-
|
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.
|
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.
|
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,
|