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/authz.py
CHANGED
@@ -3,13 +3,15 @@
|
|
3
3
|
|
4
4
|
from __future__ import annotations
|
5
5
|
|
6
|
+
from collections.abc import Mapping, Sequence
|
6
7
|
from typing import Any
|
7
8
|
|
8
9
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
9
10
|
from pangea.config import PangeaConfig
|
10
11
|
from pangea.response import PangeaResponse
|
11
12
|
from pangea.services.authz import (
|
12
|
-
|
13
|
+
BulkCheckRequestItem,
|
14
|
+
BulkCheckResult,
|
13
15
|
CheckResult,
|
14
16
|
ItemOrder,
|
15
17
|
ListResourcesRequest,
|
@@ -19,7 +21,6 @@ from pangea.services.authz import (
|
|
19
21
|
Resource,
|
20
22
|
Subject,
|
21
23
|
Tuple,
|
22
|
-
TupleCreateRequest,
|
23
24
|
TupleCreateResult,
|
24
25
|
TupleDeleteRequest,
|
25
26
|
TupleDeleteResult,
|
@@ -73,7 +74,7 @@ class AuthZAsync(ServiceBaseAsync):
|
|
73
74
|
|
74
75
|
super().__init__(token, config, logger_name, config_id=config_id)
|
75
76
|
|
76
|
-
async def tuple_create(self, tuples:
|
77
|
+
async def tuple_create(self, tuples: Sequence[Tuple]) -> PangeaResponse[TupleCreateResult]:
|
77
78
|
"""Create tuples.
|
78
79
|
|
79
80
|
Create tuples in the AuthZ Service. The request will fail if there is no schema
|
@@ -88,7 +89,7 @@ class AuthZAsync(ServiceBaseAsync):
|
|
88
89
|
Returns:
|
89
90
|
Pangea Response with empty result.
|
90
91
|
Available response fields can be found in our
|
91
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/create).
|
92
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/create-post).
|
92
93
|
|
93
94
|
Examples:
|
94
95
|
await authz.tuple_create(
|
@@ -102,10 +103,7 @@ class AuthZAsync(ServiceBaseAsync):
|
|
102
103
|
)
|
103
104
|
"""
|
104
105
|
|
105
|
-
|
106
|
-
return await self.request.post(
|
107
|
-
"v1/tuple/create", TupleCreateResult, data=input_data.model_dump(exclude_none=True)
|
108
|
-
)
|
106
|
+
return await self.request.post("v1/tuple/create", TupleCreateResult, data={"tuples": tuples})
|
109
107
|
|
110
108
|
async def tuple_list(
|
111
109
|
self,
|
@@ -134,7 +132,7 @@ class AuthZAsync(ServiceBaseAsync):
|
|
134
132
|
Returns:
|
135
133
|
Pangea Response with a list of tuples and the last token.
|
136
134
|
Available response fields can be found in our
|
137
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/list).
|
135
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/list-post).
|
138
136
|
|
139
137
|
Examples:
|
140
138
|
await authz.tuple_list(TupleListFilter(subject_type="user", subject_id="user_1"))
|
@@ -158,7 +156,7 @@ class AuthZAsync(ServiceBaseAsync):
|
|
158
156
|
Returns:
|
159
157
|
Pangea Response with empty result.
|
160
158
|
Available response fields can be found in our
|
161
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/delete).
|
159
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/delete-post).
|
162
160
|
|
163
161
|
Examples:
|
164
162
|
await authz.tuple_delete(
|
@@ -190,8 +188,8 @@ class AuthZAsync(ServiceBaseAsync):
|
|
190
188
|
Check if a subject has permission to perform an action on the resource.
|
191
189
|
|
192
190
|
Args:
|
193
|
-
resource
|
194
|
-
action
|
191
|
+
resource: The resource to check.
|
192
|
+
action: The action to check.
|
195
193
|
subject: The subject to check.
|
196
194
|
debug: Setting this value to True will provide a detailed analysis of the check.
|
197
195
|
attributes: Additional attributes for the check.
|
@@ -202,7 +200,7 @@ class AuthZAsync(ServiceBaseAsync):
|
|
202
200
|
Returns:
|
203
201
|
Pangea Response with the result of the check.
|
204
202
|
Available response fields can be found in our
|
205
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/check).
|
203
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/check-post).
|
206
204
|
|
207
205
|
Examples:
|
208
206
|
await authz.check(
|
@@ -213,8 +211,44 @@ class AuthZAsync(ServiceBaseAsync):
|
|
213
211
|
)
|
214
212
|
"""
|
215
213
|
|
216
|
-
|
217
|
-
|
214
|
+
return await self.request.post(
|
215
|
+
"v1/check",
|
216
|
+
CheckResult,
|
217
|
+
data={"resource": resource, "action": action, "subject": subject, "debug": debug, "attributes": attributes},
|
218
|
+
)
|
219
|
+
|
220
|
+
async def bulk_check(
|
221
|
+
self,
|
222
|
+
checks: Sequence[BulkCheckRequestItem],
|
223
|
+
*,
|
224
|
+
debug: bool | None = None,
|
225
|
+
attributes: Mapping[str, Any] | None = None,
|
226
|
+
) -> PangeaResponse[BulkCheckResult]:
|
227
|
+
"""Perform a bulk check request
|
228
|
+
|
229
|
+
Perform multiple checks in a single request to see if a subjects have
|
230
|
+
permission to do actions on the resources.
|
231
|
+
|
232
|
+
Args:
|
233
|
+
checks: Check requests to perform.
|
234
|
+
debug: In the event of an allowed check, return a path that granted access.
|
235
|
+
attributes: A JSON object of attribute data.
|
236
|
+
|
237
|
+
Examples:
|
238
|
+
await authz.bulk_check(
|
239
|
+
checks=[
|
240
|
+
BulkCheckRequestItem(
|
241
|
+
resource=Resource(type="file", id="file_1"),
|
242
|
+
action="read",
|
243
|
+
subject=Subject(type="user", id="user_1", action="read"),
|
244
|
+
)
|
245
|
+
]
|
246
|
+
)
|
247
|
+
"""
|
248
|
+
|
249
|
+
return await self.request.post(
|
250
|
+
"v1/check/bulk", BulkCheckResult, data={"checks": checks, "debug": debug, "attributes": attributes}
|
251
|
+
)
|
218
252
|
|
219
253
|
async def list_resources(
|
220
254
|
self, type: str, action: str, subject: Subject, attributes: dict[str, Any] | None = None
|
@@ -236,7 +270,7 @@ class AuthZAsync(ServiceBaseAsync):
|
|
236
270
|
Returns:
|
237
271
|
Pangea Response with a list of resource IDs.
|
238
272
|
Available response fields can be found in our
|
239
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-resources).
|
273
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-resources-post).
|
240
274
|
|
241
275
|
Examples:
|
242
276
|
await authz.list_resources(
|
@@ -270,7 +304,7 @@ class AuthZAsync(ServiceBaseAsync):
|
|
270
304
|
Returns:
|
271
305
|
Pangea Response with a list of subjects.
|
272
306
|
Available response fields can be found in our
|
273
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-subjects).
|
307
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-subjects-post).
|
274
308
|
|
275
309
|
Examples:
|
276
310
|
await authz.list_subjects(
|
pangea/asyncio/services/base.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 io
|
4
10
|
import logging
|
5
11
|
from typing import Dict, List, Optional, Tuple
|
@@ -16,7 +22,7 @@ class FileScanAsync(ServiceBaseAsync):
|
|
16
22
|
"""FileScan service client.
|
17
23
|
|
18
24
|
Provides methods to interact with Pangea FileScan Service:
|
19
|
-
https://pangea.cloud/docs/api/
|
25
|
+
https://pangea.cloud/docs/api/file-scan
|
20
26
|
|
21
27
|
The following information is needed:
|
22
28
|
PANGEA_TOKEN - service token which can be found on the Pangea User
|
@@ -98,7 +104,7 @@ class FileScanAsync(ServiceBaseAsync):
|
|
98
104
|
files: Optional[List[Tuple]] = None
|
99
105
|
if file or file_path:
|
100
106
|
if file_path:
|
101
|
-
file = open(file_path, "rb")
|
107
|
+
file = open(file_path, "rb") # noqa: SIM115
|
102
108
|
if transfer_method == TransferMethod.POST_URL:
|
103
109
|
params = get_file_upload_params(file) # type: ignore[arg-type]
|
104
110
|
crc = params.crc_hex
|
pangea/asyncio/services/intel.py
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Modernize.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
from __future__ import annotations
|
7
|
+
|
3
8
|
import hashlib
|
4
|
-
from typing import List, Optional
|
9
|
+
from typing import List, Literal, Optional
|
5
10
|
|
6
11
|
import pangea.services.intel as m
|
7
12
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
@@ -73,11 +78,11 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
73
78
|
|
74
79
|
async def hash_reputation_bulk(
|
75
80
|
self,
|
76
|
-
hashes:
|
77
|
-
hash_type:
|
78
|
-
provider:
|
79
|
-
verbose:
|
80
|
-
raw:
|
81
|
+
hashes: list[str],
|
82
|
+
hash_type: Literal["sha256", "sha", "md5"],
|
83
|
+
provider: Literal["reversinglabs", "crowdstrike"] | None = None,
|
84
|
+
verbose: bool | None = None,
|
85
|
+
raw: bool | None = None,
|
81
86
|
) -> PangeaResponse[m.FileReputationBulkResult]:
|
82
87
|
"""
|
83
88
|
Reputation check
|
@@ -85,11 +90,11 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
85
90
|
Retrieve hash-based file reputation from a provider, including an optional detailed report.
|
86
91
|
|
87
92
|
Args:
|
88
|
-
hashes
|
89
|
-
hash_type
|
90
|
-
provider
|
91
|
-
verbose
|
92
|
-
raw
|
93
|
+
hashes: The hash of each file to be looked up
|
94
|
+
hash_type: One of "sha256", "sha", "md5"
|
95
|
+
provider: Use reputation data from these providers: "reversinglabs" or "crowdstrike"
|
96
|
+
verbose: Echo the API parameters in the response
|
97
|
+
raw: Include raw data from this provider
|
93
98
|
|
94
99
|
Raises:
|
95
100
|
PangeaAPIException: If an API Error happens
|
@@ -97,12 +102,8 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
97
102
|
Returns:
|
98
103
|
A PangeaResponse where the sanctioned source(s) are in the
|
99
104
|
response.result field. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/file-intel).
|
100
|
-
|
101
|
-
Examples:
|
102
|
-
FIXME:
|
103
|
-
|
104
105
|
"""
|
105
|
-
input = m.FileReputationBulkRequest(
|
106
|
+
input = m.FileReputationBulkRequest(
|
106
107
|
hashes=hashes, hash_type=hash_type, verbose=verbose, raw=raw, provider=provider
|
107
108
|
)
|
108
109
|
return await self.request.post(
|
@@ -144,8 +145,8 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
144
145
|
)
|
145
146
|
"""
|
146
147
|
|
147
|
-
|
148
|
-
|
148
|
+
with open(filepath, "rb") as data:
|
149
|
+
hash = hashlib.sha256(data.read()).hexdigest()
|
149
150
|
|
150
151
|
input = m.FileReputationRequest(hash=hash, hash_type="sha256", verbose=verbose, raw=raw, provider=provider)
|
151
152
|
return await self.request.post(
|
@@ -154,8 +155,8 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
154
155
|
|
155
156
|
async def filepath_reputation_bulk(
|
156
157
|
self,
|
157
|
-
filepaths:
|
158
|
-
provider:
|
158
|
+
filepaths: list[str],
|
159
|
+
provider: Literal["reversinglabs", "crowdstrike"] | None = None,
|
159
160
|
verbose: Optional[bool] = None,
|
160
161
|
raw: Optional[bool] = None,
|
161
162
|
) -> PangeaResponse[m.FileReputationBulkResult]:
|
@@ -168,10 +169,10 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
168
169
|
OperationId: file_intel_post_v1_reputation
|
169
170
|
|
170
171
|
Args:
|
171
|
-
filepaths
|
172
|
-
provider
|
173
|
-
verbose
|
174
|
-
raw
|
172
|
+
filepaths: The path list to the files to be looked up
|
173
|
+
provider: Use reputation data from these providers: "reversinglabs" or "crowdstrike"
|
174
|
+
verbose: Echo the API parameters in the response
|
175
|
+
raw: Include raw data from this provider
|
175
176
|
|
176
177
|
Raises:
|
177
178
|
PangeaAPIException: If an API Error happens
|
@@ -179,9 +180,6 @@ class FileIntelAsync(ServiceBaseAsync):
|
|
179
180
|
Returns:
|
180
181
|
A PangeaResponse where the sanctioned source(s) are in the
|
181
182
|
response.result field. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/file-intel).
|
182
|
-
|
183
|
-
Examples:
|
184
|
-
FIXME:
|
185
183
|
"""
|
186
184
|
hashes = []
|
187
185
|
for filepath in filepaths:
|
@@ -317,7 +315,7 @@ class DomainIntelAsync(ServiceBaseAsync):
|
|
317
315
|
provider="whoisxml",
|
318
316
|
)
|
319
317
|
"""
|
320
|
-
input = m.DomainWhoIsRequest(domain=domain, verbose=verbose, provider=provider, raw=raw)
|
318
|
+
input = m.DomainWhoIsRequest(domain=domain, verbose=verbose, provider=provider, raw=raw)
|
321
319
|
return await self.request.post("v1/whois", m.DomainWhoIsResult, data=input.model_dump(exclude_none=True))
|
322
320
|
|
323
321
|
|
@@ -1,16 +1,17 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
-
from __future__ import annotations
|
4
3
|
|
5
|
-
|
6
|
-
|
4
|
+
# TODO: Modernize.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
7
|
+
from __future__ import annotations
|
7
8
|
|
8
|
-
from
|
9
|
+
from typing import Dict, List, Optional, Union
|
9
10
|
|
10
11
|
import pangea.services.redact as m
|
11
12
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
12
13
|
from pangea.config import PangeaConfig
|
13
|
-
from pangea.response import PangeaResponse
|
14
|
+
from pangea.response import PangeaResponse
|
14
15
|
|
15
16
|
|
16
17
|
class RedactAsync(ServiceBaseAsync):
|
@@ -67,7 +68,7 @@ class RedactAsync(ServiceBaseAsync):
|
|
67
68
|
rules: Optional[List[str]] = None,
|
68
69
|
rulesets: Optional[List[str]] = None,
|
69
70
|
return_result: Optional[bool] = None,
|
70
|
-
redaction_method_overrides:
|
71
|
+
redaction_method_overrides: Optional[m.RedactionMethodOverrides] = None,
|
71
72
|
llm_request: Optional[bool] = None,
|
72
73
|
vault_parameters: Optional[m.VaultParameters] = None,
|
73
74
|
) -> PangeaResponse[m.RedactResult]:
|
@@ -95,7 +96,7 @@ class RedactAsync(ServiceBaseAsync):
|
|
95
96
|
Returns:
|
96
97
|
Pangea Response with redacted text in the response.result property,
|
97
98
|
available response fields can be found in our
|
98
|
-
[API Documentation](https://pangea.cloud/docs/api/redact#redact).
|
99
|
+
[API Documentation](https://pangea.cloud/docs/api/redact#redact-post).
|
99
100
|
|
100
101
|
Examples:
|
101
102
|
response = redact.redact(text="Jenny Jenny... 555-867-5309")
|
@@ -122,7 +123,7 @@ class RedactAsync(ServiceBaseAsync):
|
|
122
123
|
rules: Optional[List[str]] = None,
|
123
124
|
rulesets: Optional[List[str]] = None,
|
124
125
|
return_result: Optional[bool] = None,
|
125
|
-
redaction_method_overrides:
|
126
|
+
redaction_method_overrides: Optional[m.RedactionMethodOverrides] = None,
|
126
127
|
llm_request: bool | None = None,
|
127
128
|
vault_parameters: m.VaultParameters | None = None,
|
128
129
|
) -> PangeaResponse[m.StructuredResult]:
|
@@ -154,7 +155,7 @@ class RedactAsync(ServiceBaseAsync):
|
|
154
155
|
Returns:
|
155
156
|
Pangea Response with redacted data in the response.result field,
|
156
157
|
available response fields can be found in our
|
157
|
-
[API Documentation](https://pangea.cloud/docs/api/redact#redact-structured)
|
158
|
+
[API Documentation](https://pangea.cloud/docs/api/redact#redact-structured-post)
|
158
159
|
|
159
160
|
Examples:
|
160
161
|
data = {
|
@@ -199,265 +200,7 @@ class RedactAsync(ServiceBaseAsync):
|
|
199
200
|
Returns:
|
200
201
|
Pangea Response with redacted data in the response.result field,
|
201
202
|
available response fields can be found in our
|
202
|
-
[API Documentation](https://pangea.cloud/docs/api/redact#unredact)
|
203
|
+
[API Documentation](https://pangea.cloud/docs/api/redact#unredact-post)
|
203
204
|
"""
|
204
205
|
input = m.UnredactRequest(redacted_data=redacted_data, fpe_context=fpe_context)
|
205
206
|
return await self.request.post("v1/unredact", m.UnredactResult, data=input.model_dump(exclude_none=True))
|
206
|
-
|
207
|
-
async def get_service_config(self, config_id: str) -> PangeaResponse[m.ServiceConfigResult]:
|
208
|
-
"""
|
209
|
-
Get a service config.
|
210
|
-
|
211
|
-
|
212
|
-
OperationId: redact_post_v1beta_config
|
213
|
-
"""
|
214
|
-
response = await self.request.post("v1beta/config", PangeaResponseResult, data={"id": config_id})
|
215
|
-
response.result = TypeAdapter(m.ServiceConfigResult).validate_python(response.json["result"])
|
216
|
-
return cast(PangeaResponse[m.ServiceConfigResult], response)
|
217
|
-
|
218
|
-
@overload
|
219
|
-
async def create_service_config(
|
220
|
-
self,
|
221
|
-
name: str,
|
222
|
-
*,
|
223
|
-
version: Literal["1.0.0"],
|
224
|
-
enabled_rules: Sequence[str] | None = None,
|
225
|
-
redactions: Mapping[str, m.Redaction] | None = None,
|
226
|
-
vault_service_config_id: str | None = None,
|
227
|
-
salt_vault_secret_id: str | None = None,
|
228
|
-
rules: Mapping[str, m.RuleV1] | None = None,
|
229
|
-
rulesets: Mapping[str, m.RulesetV1] | None = None,
|
230
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
231
|
-
) -> PangeaResponse[m.ServiceConfigResult]:
|
232
|
-
"""
|
233
|
-
Create a v1.0.0 service config.
|
234
|
-
|
235
|
-
OperationId: redact_post_v1beta_config_create
|
236
|
-
|
237
|
-
Args:
|
238
|
-
vault_service_config_id: Service config used to create the secret
|
239
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
240
|
-
"""
|
241
|
-
|
242
|
-
@overload
|
243
|
-
async def create_service_config(
|
244
|
-
self,
|
245
|
-
name: str,
|
246
|
-
*,
|
247
|
-
version: Literal["2.0.0"] | None = None,
|
248
|
-
enabled_rules: Sequence[str] | None = None,
|
249
|
-
enforce_enabled_rules: bool | None = None,
|
250
|
-
redactions: Mapping[str, m.Redaction] | None = None,
|
251
|
-
vault_service_config_id: str | None = None,
|
252
|
-
salt_vault_secret_id: str | None = None,
|
253
|
-
fpe_vault_secret_id: str | None = None,
|
254
|
-
rules: Mapping[str, m.RuleV2] | None = None,
|
255
|
-
rulesets: Mapping[str, m.RulesetV2] | None = None,
|
256
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
257
|
-
) -> PangeaResponse[m.ServiceConfigResult]:
|
258
|
-
"""
|
259
|
-
Create a v2.0.0 service config.
|
260
|
-
|
261
|
-
OperationId: redact_post_v1beta_config_create
|
262
|
-
|
263
|
-
Args:
|
264
|
-
enforce_enabled_rules: Always run service config enabled rules across all redact calls regardless of flags?
|
265
|
-
vault_service_config_id: Service config used to create the secret
|
266
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
267
|
-
fpe_vault_secret_id: The ID of the key used by FF3 Encryption algorithms for FPE.
|
268
|
-
"""
|
269
|
-
|
270
|
-
async def create_service_config(
|
271
|
-
self,
|
272
|
-
name: str,
|
273
|
-
*,
|
274
|
-
version: Literal["1.0.0", "2.0.0"] | None = None,
|
275
|
-
enabled_rules: Sequence[str] | None = None,
|
276
|
-
enforce_enabled_rules: bool | None = None,
|
277
|
-
fpe_vault_secret_id: str | None = None,
|
278
|
-
redactions: Mapping[str, m.Redaction] | None = None,
|
279
|
-
rules: Mapping[str, m.RuleV1 | m.RuleV2] | None = None,
|
280
|
-
rulesets: Mapping[str, m.RulesetV1 | m.RulesetV2] | None = None,
|
281
|
-
salt_vault_secret_id: str | None = None,
|
282
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
283
|
-
vault_service_config_id: str | None = None,
|
284
|
-
) -> PangeaResponse[m.ServiceConfigResult]:
|
285
|
-
"""
|
286
|
-
Create a service config.
|
287
|
-
|
288
|
-
OperationId: redact_post_v1beta_config_create
|
289
|
-
|
290
|
-
Args:
|
291
|
-
enforce_enabled_rules: Always run service config enabled rules across all redact calls regardless of flags?
|
292
|
-
fpe_vault_secret_id: The ID of the key used by FF3 Encryption algorithms for FPE.
|
293
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
294
|
-
vault_service_config_id: Service config used to create the secret
|
295
|
-
"""
|
296
|
-
|
297
|
-
response = await self.request.post(
|
298
|
-
"v1beta/config/create",
|
299
|
-
PangeaResponseResult,
|
300
|
-
data={
|
301
|
-
"name": name,
|
302
|
-
"version": version,
|
303
|
-
"enabled_rules": enabled_rules,
|
304
|
-
"enforce_enabled_rules": enforce_enabled_rules,
|
305
|
-
"fpe_vault_secret_id": fpe_vault_secret_id,
|
306
|
-
"redactions": redactions,
|
307
|
-
"rules": rules,
|
308
|
-
"rulesets": rulesets,
|
309
|
-
"salt_vault_secret_id": salt_vault_secret_id,
|
310
|
-
"supported_languages": supported_languages,
|
311
|
-
"vault_service_config_id": vault_service_config_id,
|
312
|
-
},
|
313
|
-
)
|
314
|
-
response.result = TypeAdapter(m.ServiceConfigResult).validate_python(response.json["result"])
|
315
|
-
return cast(PangeaResponse[m.ServiceConfigResult], response)
|
316
|
-
|
317
|
-
@overload
|
318
|
-
async def update_service_config(
|
319
|
-
self,
|
320
|
-
config_id: str,
|
321
|
-
*,
|
322
|
-
version: Literal["1.0.0"],
|
323
|
-
name: str,
|
324
|
-
updated_at: str,
|
325
|
-
enabled_rules: Sequence[str] | None = None,
|
326
|
-
redactions: Mapping[str, m.Redaction] | None = None,
|
327
|
-
vault_service_config_id: str | None = None,
|
328
|
-
salt_vault_secret_id: str | None = None,
|
329
|
-
rules: Mapping[str, m.RuleV1] | None = None,
|
330
|
-
rulesets: Mapping[str, m.RulesetV1] | None = None,
|
331
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
332
|
-
) -> PangeaResponse[m.ServiceConfigResult]:
|
333
|
-
"""
|
334
|
-
Update a v1.0.0 service config.
|
335
|
-
|
336
|
-
OperationId: redact_post_v1beta_config_update
|
337
|
-
|
338
|
-
Args:
|
339
|
-
vault_service_config_id: Service config used to create the secret
|
340
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
341
|
-
"""
|
342
|
-
|
343
|
-
@overload
|
344
|
-
async def update_service_config(
|
345
|
-
self,
|
346
|
-
config_id: str,
|
347
|
-
*,
|
348
|
-
version: Literal["2.0.0"] | None = None,
|
349
|
-
name: str,
|
350
|
-
updated_at: str,
|
351
|
-
enabled_rules: Sequence[str] | None = None,
|
352
|
-
enforce_enabled_rules: bool | None = None,
|
353
|
-
redactions: Mapping[str, m.Redaction] | None = None,
|
354
|
-
vault_service_config_id: str | None = None,
|
355
|
-
salt_vault_secret_id: str | None = None,
|
356
|
-
fpe_vault_secret_id: str | None = None,
|
357
|
-
rules: Mapping[str, m.RuleV2] | None = None,
|
358
|
-
rulesets: Mapping[str, m.RulesetV2] | None = None,
|
359
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
360
|
-
) -> PangeaResponse[m.ServiceConfigResult]:
|
361
|
-
"""
|
362
|
-
Update a v2.0.0 service config.
|
363
|
-
|
364
|
-
OperationId: redact_post_v1beta_config_update
|
365
|
-
|
366
|
-
Args:
|
367
|
-
enforce_enabled_rules: Always run service config enabled rules across all redact calls regardless of flags?
|
368
|
-
vault_service_config_id: Service config used to create the secret
|
369
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
370
|
-
fpe_vault_secret_id: The ID of the key used by FF3 Encryption algorithms for FPE.
|
371
|
-
"""
|
372
|
-
|
373
|
-
async def update_service_config(
|
374
|
-
self,
|
375
|
-
config_id: str,
|
376
|
-
*,
|
377
|
-
version: Literal["1.0.0", "2.0.0"] | None = None,
|
378
|
-
name: str,
|
379
|
-
updated_at: str,
|
380
|
-
enabled_rules: Sequence[str] | None = None,
|
381
|
-
enforce_enabled_rules: bool | None = None,
|
382
|
-
fpe_vault_secret_id: str | None = None,
|
383
|
-
redactions: Mapping[str, m.Redaction] | None = None,
|
384
|
-
rules: Mapping[str, m.RuleV1 | m.RuleV2] | None = None,
|
385
|
-
rulesets: Mapping[str, m.RulesetV1 | m.RulesetV2] | None = None,
|
386
|
-
salt_vault_secret_id: str | None = None,
|
387
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
388
|
-
vault_service_config_id: str | None = None,
|
389
|
-
) -> PangeaResponse[m.ServiceConfigResult]:
|
390
|
-
"""
|
391
|
-
Update a service config.
|
392
|
-
|
393
|
-
OperationId: redact_post_v1beta_config_update
|
394
|
-
|
395
|
-
Args:
|
396
|
-
enforce_enabled_rules: Always run service config enabled rules across all redact calls regardless of flags?
|
397
|
-
fpe_vault_secret_id: The ID of the key used by FF3 Encryption algorithms for FPE.
|
398
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
399
|
-
vault_service_config_id: Service config used to create the secret
|
400
|
-
"""
|
401
|
-
|
402
|
-
response = await self.request.post(
|
403
|
-
"v1beta/config/update",
|
404
|
-
PangeaResponseResult,
|
405
|
-
data={
|
406
|
-
"id": config_id,
|
407
|
-
"updated_at": updated_at,
|
408
|
-
"name": name,
|
409
|
-
"version": version,
|
410
|
-
"enabled_rules": enabled_rules,
|
411
|
-
"enforce_enabled_rules": enforce_enabled_rules,
|
412
|
-
"fpe_vault_secret_id": fpe_vault_secret_id,
|
413
|
-
"redactions": redactions,
|
414
|
-
"rules": rules,
|
415
|
-
"rulesets": rulesets,
|
416
|
-
"salt_vault_secret_id": salt_vault_secret_id,
|
417
|
-
"supported_languages": supported_languages,
|
418
|
-
"vault_service_config_id": vault_service_config_id,
|
419
|
-
},
|
420
|
-
)
|
421
|
-
response.result = TypeAdapter(m.ServiceConfigResult).validate_python(response.json["result"])
|
422
|
-
return cast(PangeaResponse[m.ServiceConfigResult], response)
|
423
|
-
|
424
|
-
async def delete_service_config(self, config_id: str) -> PangeaResponse[m.ServiceConfigResult]:
|
425
|
-
"""
|
426
|
-
Delete a service config.
|
427
|
-
|
428
|
-
OperationId: redact_post_v1beta_config_delete
|
429
|
-
|
430
|
-
Args:
|
431
|
-
config_id: An ID for a service config
|
432
|
-
"""
|
433
|
-
|
434
|
-
response = await self.request.post("v1beta/config/delete", PangeaResponseResult, data={"id": config_id})
|
435
|
-
response.result = TypeAdapter(m.ServiceConfigResult).validate_python(response.json["result"])
|
436
|
-
return cast(PangeaResponse[m.ServiceConfigResult], response)
|
437
|
-
|
438
|
-
async def list_service_configs(
|
439
|
-
self,
|
440
|
-
*,
|
441
|
-
filter: m.ServiceConfigFilter | None = None,
|
442
|
-
last: str | None = None,
|
443
|
-
order: Literal["asc", "desc"] | None = None,
|
444
|
-
order_by: Literal["id", "created_at", "updated_at"] | None = None,
|
445
|
-
size: int | None = None,
|
446
|
-
) -> PangeaResponse[m.ServiceConfigListResult]:
|
447
|
-
"""
|
448
|
-
List service configs.
|
449
|
-
|
450
|
-
OperationId: redact_post_v1beta_config_list
|
451
|
-
|
452
|
-
Args:
|
453
|
-
last: Reflected value from a previous response to obtain the next page of results.
|
454
|
-
order: Order results asc(ending) or desc(ending).
|
455
|
-
order_by: Which field to order results by.
|
456
|
-
size: Maximum results to include in the response.
|
457
|
-
"""
|
458
|
-
|
459
|
-
return await self.request.post(
|
460
|
-
"v1beta/config/list",
|
461
|
-
m.ServiceConfigListResult,
|
462
|
-
data={"filter": filter, "last": last, "order": order, "order_by": order_by, "size": size},
|
463
|
-
)
|
@@ -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 io
|
@@ -116,7 +120,7 @@ class SanitizeAsync(ServiceBaseAsync):
|
|
116
120
|
files: Optional[List[Tuple]] = None
|
117
121
|
if file or file_path:
|
118
122
|
if file_path:
|
119
|
-
file = open(file_path, "rb")
|
123
|
+
file = open(file_path, "rb") # noqa: SIM115
|
120
124
|
if transfer_method == TransferMethod.POST_URL and (sha256 is None or crc32c is None or size is None):
|
121
125
|
params = get_file_upload_params(file) # type: ignore[arg-type]
|
122
126
|
crc32c = params.crc_hex if crc32c is None else crc32c
|
pangea/asyncio/services/share.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 io
|
@@ -194,7 +198,7 @@ class ShareAsync(ServiceBaseAsync):
|
|
194
198
|
|
195
199
|
async def get_archive(
|
196
200
|
self,
|
197
|
-
ids:
|
201
|
+
ids: list[str],
|
198
202
|
format: Optional[m.ArchiveFormat] = None,
|
199
203
|
transfer_method: Optional[TransferMethod] = None,
|
200
204
|
bucket_id: Optional[str] = None,
|