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/services/redact.py
CHANGED
@@ -1,76 +1,18 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Use `list` instead of `List`.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
3
7
|
from __future__ import annotations
|
4
8
|
|
5
9
|
import enum
|
6
|
-
from
|
7
|
-
from typing import Dict, List, Optional, Union, cast, overload
|
8
|
-
|
9
|
-
from pydantic import Field, TypeAdapter
|
10
|
-
from typing_extensions import Annotated, Literal
|
10
|
+
from typing import Dict, List, Optional, Union
|
11
11
|
|
12
12
|
from pangea.config import PangeaConfig
|
13
13
|
from pangea.response import APIRequestModel, APIResponseModel, PangeaResponse, PangeaResponseResult
|
14
14
|
from pangea.services.base import ServiceBase
|
15
15
|
|
16
|
-
MatcherType = Literal[
|
17
|
-
"CREDIT_CARD",
|
18
|
-
"CRYPTO",
|
19
|
-
"DATE_TIME",
|
20
|
-
"EMAIL_ADDRESS",
|
21
|
-
"IBAN_CODE",
|
22
|
-
"IP_ADDRESS",
|
23
|
-
"NRP",
|
24
|
-
"LOCATION",
|
25
|
-
"PERSON",
|
26
|
-
"PHONE_NUMBER",
|
27
|
-
"MEDICAL_LICENSE",
|
28
|
-
"URL",
|
29
|
-
"US_BANK_NUMBER",
|
30
|
-
"US_DRIVER_LICENSE",
|
31
|
-
"US_ITIN",
|
32
|
-
"US_PASSPORT",
|
33
|
-
"US_SSN",
|
34
|
-
"UK_NHS",
|
35
|
-
"NIF",
|
36
|
-
"FIN/NRIC",
|
37
|
-
"AU_ABN",
|
38
|
-
"AU_ACN",
|
39
|
-
"AU_TFN",
|
40
|
-
"AU_MEDICARE",
|
41
|
-
"FIREBASE_URL",
|
42
|
-
"RSA_PRIVATE_KEY",
|
43
|
-
"SSH_DSA_PRIVATE_KEY",
|
44
|
-
"SSH_EC_PRIVATE_KEY",
|
45
|
-
"PGP_PRIVATE_KEY_BLOCK",
|
46
|
-
"AMAZON_AWS_ACCESS_KEY_ID",
|
47
|
-
"AMAZON_AWS_SECRET_ACCESS_KEY",
|
48
|
-
"AMAZON_MWS_AUTH_TOKEN",
|
49
|
-
"FACEBOOK_ACCESS_TOKEN",
|
50
|
-
"GITHUB_ACCESS_TOKEN",
|
51
|
-
"JWT_TOKEN",
|
52
|
-
"GOOGLE_API_KEY",
|
53
|
-
"GOOGLE_CLOUD_PLATFORM_API_KEY",
|
54
|
-
"GOOGLE_DRIVE_API_KEY",
|
55
|
-
"GOOGLE_CLOUD_PLATFORM_SERVICE_ACCOUNT",
|
56
|
-
"GOOGLE_GMAIL_API_KEY",
|
57
|
-
"YOUTUBE_API_KEY",
|
58
|
-
"MAILCHIMP_API_KEY",
|
59
|
-
"MAILGUN_API_KEY",
|
60
|
-
"MONEY",
|
61
|
-
"BASIC_AUTH",
|
62
|
-
"PICATIC_API_KEY",
|
63
|
-
"SLACK_TOKEN",
|
64
|
-
"SLACK_WEBHOOK",
|
65
|
-
"STRIPE_API_KEY",
|
66
|
-
"STRIPE_RESTRICTED_API_KEY",
|
67
|
-
"SQUARE_ACCESS_TOKEN",
|
68
|
-
"SQUARE_OAUTH_SECRET",
|
69
|
-
"TWILIO_API_KEY",
|
70
|
-
"PANGEA_TOKEN",
|
71
|
-
"PROFANITY",
|
72
|
-
]
|
73
|
-
|
74
16
|
|
75
17
|
class RedactFormat(str, enum.Enum):
|
76
18
|
"""Structured data format."""
|
@@ -106,10 +48,10 @@ class PartialMasking(APIRequestModel):
|
|
106
48
|
masked_from_left: Optional[int] = None
|
107
49
|
masked_from_right: Optional[int] = None
|
108
50
|
chars_to_ignore: Optional[List[str]] = None
|
109
|
-
masking_char: Optional[str] =
|
51
|
+
masking_char: Optional[List[str]] = None
|
110
52
|
|
111
53
|
|
112
|
-
class
|
54
|
+
class RedactionMethodOverrides(APIRequestModel):
|
113
55
|
redaction_type: RedactType
|
114
56
|
hash: Optional[Dict] = None
|
115
57
|
fpe_alphabet: Optional[FPEAlphabet] = None
|
@@ -117,10 +59,6 @@ class Redaction(APIRequestModel):
|
|
117
59
|
redaction_value: Optional[str] = None
|
118
60
|
|
119
61
|
|
120
|
-
class RedactionMethodOverrides(Redaction):
|
121
|
-
"""This field allows users to specify the redaction method per rule and its various parameters."""
|
122
|
-
|
123
|
-
|
124
62
|
class RedactRequest(APIRequestModel):
|
125
63
|
"""
|
126
64
|
Input class to make a redact request
|
@@ -131,7 +69,7 @@ class RedactRequest(APIRequestModel):
|
|
131
69
|
rules: Optional[List[str]] = None
|
132
70
|
rulesets: Optional[List[str]] = None
|
133
71
|
return_result: Optional[bool] = None
|
134
|
-
redaction_method_overrides: Optional[
|
72
|
+
redaction_method_overrides: Optional[RedactionMethodOverrides] = None
|
135
73
|
vault_parameters: Optional[VaultParameters] = None
|
136
74
|
llm_request: Optional[bool] = None
|
137
75
|
"""Is this redact call going to be used in an LLM request?"""
|
@@ -212,7 +150,7 @@ class StructuredRequest(APIRequestModel):
|
|
212
150
|
rules: Optional[List[str]] = None
|
213
151
|
rulesets: Optional[List[str]] = None
|
214
152
|
return_result: Optional[bool] = None
|
215
|
-
redaction_method_overrides: Optional[
|
153
|
+
redaction_method_overrides: Optional[RedactionMethodOverrides] = None
|
216
154
|
vault_parameters: Optional[VaultParameters] = None
|
217
155
|
llm_request: Optional[bool] = None
|
218
156
|
"""Is this redact call going to be used in an LLM request?"""
|
@@ -260,145 +198,6 @@ class UnredactResult(PangeaResponseResult):
|
|
260
198
|
data: RedactedData
|
261
199
|
|
262
200
|
|
263
|
-
class Matcher(APIResponseModel):
|
264
|
-
match_type: str
|
265
|
-
match_value: str
|
266
|
-
match_score: float
|
267
|
-
|
268
|
-
|
269
|
-
class RuleV1(APIResponseModel):
|
270
|
-
entity_name: str
|
271
|
-
matchers: Union[List[Matcher], MatcherType]
|
272
|
-
ruleset: str
|
273
|
-
|
274
|
-
match_threshold: Optional[float] = None
|
275
|
-
context_values: Optional[List[str]] = None
|
276
|
-
name: Optional[str] = None
|
277
|
-
description: Optional[str] = None
|
278
|
-
|
279
|
-
|
280
|
-
class RuleV2(APIResponseModel):
|
281
|
-
entity_name: str
|
282
|
-
matchers: Union[List[Matcher], MatcherType]
|
283
|
-
|
284
|
-
match_threshold: Optional[float] = None
|
285
|
-
context_values: Optional[List[str]] = None
|
286
|
-
negative_context_values: Optional[List[str]] = None
|
287
|
-
name: Optional[str] = None
|
288
|
-
description: Optional[str] = None
|
289
|
-
|
290
|
-
|
291
|
-
class RulesetV1(APIResponseModel):
|
292
|
-
name: Optional[str] = None
|
293
|
-
description: Optional[str] = None
|
294
|
-
rules: List[str]
|
295
|
-
|
296
|
-
|
297
|
-
class RulesetV2(APIResponseModel):
|
298
|
-
name: Optional[str] = None
|
299
|
-
description: Optional[str] = None
|
300
|
-
|
301
|
-
|
302
|
-
class ServiceConfigV1(PangeaResponseResult):
|
303
|
-
version: Literal["1.0.0"] = "1.0.0"
|
304
|
-
id: str
|
305
|
-
name: str
|
306
|
-
updated_at: str
|
307
|
-
enabled_rules: List[str]
|
308
|
-
|
309
|
-
redactions: Optional[Dict[str, Redaction]] = None
|
310
|
-
|
311
|
-
vault_service_config_id: Optional[str] = None
|
312
|
-
"""Service config used to create the secret"""
|
313
|
-
|
314
|
-
salt_vault_secret_id: Optional[str] = None
|
315
|
-
"""Pangea only allows hashing to be done using a salt value to prevent brute-force attacks."""
|
316
|
-
|
317
|
-
rules: Optional[Dict[str, RuleV1]] = None
|
318
|
-
rulesets: Optional[Dict[str, RulesetV1]] = None
|
319
|
-
supported_languages: Optional[List[Literal["en"]]] = None
|
320
|
-
|
321
|
-
|
322
|
-
class ServiceConfigV2(PangeaResponseResult):
|
323
|
-
version: Literal["2.0.0"] = "2.0.0"
|
324
|
-
id: str
|
325
|
-
name: str
|
326
|
-
updated_at: str
|
327
|
-
enabled_rules: List[str]
|
328
|
-
|
329
|
-
enforce_enabled_rules: Optional[bool] = None
|
330
|
-
"""Always run service config enabled rules across all redact calls regardless of flags?"""
|
331
|
-
|
332
|
-
redactions: Optional[Dict[str, Redaction]] = None
|
333
|
-
|
334
|
-
vault_service_config_id: Optional[str] = None
|
335
|
-
"""Service config used to create the secret"""
|
336
|
-
|
337
|
-
salt_vault_secret_id: Optional[str] = None
|
338
|
-
"""Pangea only allows hashing to be done using a salt value to prevent brute-force attacks."""
|
339
|
-
|
340
|
-
fpe_vault_secret_id: Optional[str] = None
|
341
|
-
"""The ID of the key used by FF3 Encryption algorithms for FPE."""
|
342
|
-
|
343
|
-
rules: Optional[Dict[str, RuleV2]] = None
|
344
|
-
rulesets: Optional[Dict[str, RulesetV2]] = None
|
345
|
-
supported_languages: Optional[List[Literal["en"]]] = None
|
346
|
-
|
347
|
-
|
348
|
-
ServiceConfigResult = Annotated[Union[ServiceConfigV1, ServiceConfigV2], Field(discriminator="version")]
|
349
|
-
|
350
|
-
|
351
|
-
class ServiceConfigFilter(APIRequestModel):
|
352
|
-
id: Optional[str] = None
|
353
|
-
"""Only records where id equals this value."""
|
354
|
-
|
355
|
-
id__contains: Optional[Sequence[str]] = None
|
356
|
-
"""Only records where id includes each substring."""
|
357
|
-
|
358
|
-
id__in: Optional[Sequence[str]] = None
|
359
|
-
"""Only records where id equals one of the provided substrings."""
|
360
|
-
|
361
|
-
created_at: Optional[str] = None
|
362
|
-
"""Only records where created_at equals this value."""
|
363
|
-
|
364
|
-
created_at__gt: Optional[str] = None
|
365
|
-
"""Only records where created_at is greater than this value."""
|
366
|
-
|
367
|
-
created_at__gte: Optional[str] = None
|
368
|
-
"""Only records where created_at is greater than or equal to this value."""
|
369
|
-
|
370
|
-
created_at__lt: Optional[str] = None
|
371
|
-
"""Only records where created_at is less than this value."""
|
372
|
-
|
373
|
-
created_at__lte: Optional[str] = None
|
374
|
-
"""Only records where created_at is less than or equal to this value."""
|
375
|
-
|
376
|
-
updated_at: Optional[str] = None
|
377
|
-
"""Only records where updated_at equals this value."""
|
378
|
-
|
379
|
-
updated_at__gt: Optional[str] = None
|
380
|
-
"""Only records where updated_at is greater than this value."""
|
381
|
-
|
382
|
-
updated_at__gte: Optional[str] = None
|
383
|
-
"""Only records where updated_at is greater than or equal to this value."""
|
384
|
-
|
385
|
-
updated_at__lt: Optional[str] = None
|
386
|
-
"""Only records where updated_at is less than this value."""
|
387
|
-
|
388
|
-
updated_at__lte: Optional[str] = None
|
389
|
-
"""Only records where updated_at is less than or equal to this value."""
|
390
|
-
|
391
|
-
|
392
|
-
class ServiceConfigListResult(PangeaResponseResult):
|
393
|
-
count: int
|
394
|
-
"""The total number of service configs matched by the list request."""
|
395
|
-
|
396
|
-
last: str
|
397
|
-
"""Used to fetch the next page of the current listing when provided in a repeated request's last parameter."""
|
398
|
-
|
399
|
-
items: Sequence[ServiceConfigResult]
|
400
|
-
|
401
|
-
|
402
201
|
class Redact(ServiceBase):
|
403
202
|
"""Redact service client.
|
404
203
|
|
@@ -453,7 +252,7 @@ class Redact(ServiceBase):
|
|
453
252
|
rules: Optional[List[str]] = None,
|
454
253
|
rulesets: Optional[List[str]] = None,
|
455
254
|
return_result: Optional[bool] = None,
|
456
|
-
redaction_method_overrides: Optional[
|
255
|
+
redaction_method_overrides: Optional[RedactionMethodOverrides] = None,
|
457
256
|
llm_request: Optional[bool] = None,
|
458
257
|
vault_parameters: Optional[VaultParameters] = None,
|
459
258
|
) -> PangeaResponse[RedactResult]:
|
@@ -481,7 +280,7 @@ class Redact(ServiceBase):
|
|
481
280
|
Returns:
|
482
281
|
Pangea Response with redacted text in the response.result property,
|
483
282
|
available response fields can be found in our
|
484
|
-
[API Documentation](https://pangea.cloud/docs/api/redact#redact).
|
283
|
+
[API Documentation](https://pangea.cloud/docs/api/redact#redact-post).
|
485
284
|
|
486
285
|
Examples:
|
487
286
|
response = redact.redact(text="Jenny Jenny... 555-867-5309")
|
@@ -508,7 +307,7 @@ class Redact(ServiceBase):
|
|
508
307
|
rules: Optional[List[str]] = None,
|
509
308
|
rulesets: Optional[List[str]] = None,
|
510
309
|
return_result: Optional[bool] = None,
|
511
|
-
redaction_method_overrides:
|
310
|
+
redaction_method_overrides: Optional[RedactionMethodOverrides] = None,
|
512
311
|
llm_request: Optional[bool] = None,
|
513
312
|
vault_parameters: Optional[VaultParameters] = None,
|
514
313
|
) -> PangeaResponse[StructuredResult]:
|
@@ -540,7 +339,7 @@ class Redact(ServiceBase):
|
|
540
339
|
Returns:
|
541
340
|
Pangea Response with redacted data in the response.result field,
|
542
341
|
available response fields can be found in our
|
543
|
-
[API Documentation](https://pangea.cloud/docs/api/redact#redact-structured)
|
342
|
+
[API Documentation](https://pangea.cloud/docs/api/redact#redact-structured-post)
|
544
343
|
|
545
344
|
Examples:
|
546
345
|
data = {
|
@@ -583,268 +382,7 @@ class Redact(ServiceBase):
|
|
583
382
|
Returns:
|
584
383
|
Pangea Response with redacted data in the response.result field,
|
585
384
|
available response fields can be found in our
|
586
|
-
[API Documentation](https://pangea.cloud/docs/api/redact#unredact)
|
385
|
+
[API Documentation](https://pangea.cloud/docs/api/redact#unredact-post)
|
587
386
|
"""
|
588
387
|
input = UnredactRequest(redacted_data=redacted_data, fpe_context=fpe_context)
|
589
388
|
return self.request.post("v1/unredact", UnredactResult, data=input.model_dump(exclude_none=True))
|
590
|
-
|
591
|
-
def get_service_config(self, config_id: str) -> PangeaResponse[ServiceConfigResult]:
|
592
|
-
"""
|
593
|
-
Get a service config.
|
594
|
-
|
595
|
-
|
596
|
-
OperationId: redact_post_v1beta_config
|
597
|
-
"""
|
598
|
-
response = self.request.post("v1beta/config", PangeaResponseResult, data={"id": config_id})
|
599
|
-
response.result = TypeAdapter(ServiceConfigResult).validate_python(response.json["result"])
|
600
|
-
return cast(PangeaResponse[ServiceConfigResult], response)
|
601
|
-
|
602
|
-
@overload
|
603
|
-
def create_service_config(
|
604
|
-
self,
|
605
|
-
name: str,
|
606
|
-
*,
|
607
|
-
version: Literal["1.0.0"],
|
608
|
-
enabled_rules: Sequence[str] | None = None,
|
609
|
-
redactions: Mapping[str, Redaction] | None = None,
|
610
|
-
vault_service_config_id: str | None = None,
|
611
|
-
salt_vault_secret_id: str | None = None,
|
612
|
-
rules: Mapping[str, RuleV1] | None = None,
|
613
|
-
rulesets: Mapping[str, RulesetV1] | None = None,
|
614
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
615
|
-
) -> PangeaResponse[ServiceConfigResult]:
|
616
|
-
"""
|
617
|
-
Create a v1.0.0 service config.
|
618
|
-
|
619
|
-
OperationId: redact_post_v1beta_config_create
|
620
|
-
|
621
|
-
Args:
|
622
|
-
vault_service_config_id: Service config used to create the secret
|
623
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
624
|
-
"""
|
625
|
-
|
626
|
-
@overload
|
627
|
-
def create_service_config(
|
628
|
-
self,
|
629
|
-
name: str,
|
630
|
-
*,
|
631
|
-
version: Literal["2.0.0"] | None = None,
|
632
|
-
enabled_rules: Sequence[str] | None = None,
|
633
|
-
enforce_enabled_rules: bool | None = None,
|
634
|
-
redactions: Mapping[str, Redaction] | None = None,
|
635
|
-
vault_service_config_id: str | None = None,
|
636
|
-
salt_vault_secret_id: str | None = None,
|
637
|
-
fpe_vault_secret_id: str | None = None,
|
638
|
-
rules: Mapping[str, RuleV2] | None = None,
|
639
|
-
rulesets: Mapping[str, RulesetV2] | None = None,
|
640
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
641
|
-
) -> PangeaResponse[ServiceConfigResult]:
|
642
|
-
"""
|
643
|
-
Create a v2.0.0 service config.
|
644
|
-
|
645
|
-
OperationId: redact_post_v1beta_config_create
|
646
|
-
|
647
|
-
Args:
|
648
|
-
enforce_enabled_rules: Always run service config enabled rules across all redact calls regardless of flags?
|
649
|
-
vault_service_config_id: Service config used to create the secret
|
650
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
651
|
-
fpe_vault_secret_id: The ID of the key used by FF3 Encryption algorithms for FPE.
|
652
|
-
"""
|
653
|
-
|
654
|
-
def create_service_config(
|
655
|
-
self,
|
656
|
-
name: str,
|
657
|
-
*,
|
658
|
-
version: Literal["1.0.0", "2.0.0"] | None = None,
|
659
|
-
enabled_rules: Sequence[str] | None = None,
|
660
|
-
enforce_enabled_rules: bool | None = None,
|
661
|
-
fpe_vault_secret_id: str | None = None,
|
662
|
-
redactions: Mapping[str, Redaction] | None = None,
|
663
|
-
rules: Mapping[str, RuleV1 | RuleV2] | None = None,
|
664
|
-
rulesets: Mapping[str, RulesetV1 | RulesetV2] | None = None,
|
665
|
-
salt_vault_secret_id: str | None = None,
|
666
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
667
|
-
vault_service_config_id: str | None = None,
|
668
|
-
) -> PangeaResponse[ServiceConfigResult]:
|
669
|
-
"""
|
670
|
-
Create a service config.
|
671
|
-
|
672
|
-
OperationId: redact_post_v1beta_config_create
|
673
|
-
|
674
|
-
Args:
|
675
|
-
enforce_enabled_rules: Always run service config enabled rules across all redact calls regardless of flags?
|
676
|
-
fpe_vault_secret_id: The ID of the key used by FF3 Encryption algorithms for FPE.
|
677
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
678
|
-
vault_service_config_id: Service config used to create the secret
|
679
|
-
"""
|
680
|
-
|
681
|
-
response = self.request.post(
|
682
|
-
"v1beta/config/create",
|
683
|
-
PangeaResponseResult,
|
684
|
-
data={
|
685
|
-
"name": name,
|
686
|
-
"version": version,
|
687
|
-
"enabled_rules": enabled_rules,
|
688
|
-
"enforce_enabled_rules": enforce_enabled_rules,
|
689
|
-
"fpe_vault_secret_id": fpe_vault_secret_id,
|
690
|
-
"redactions": redactions,
|
691
|
-
"rules": rules,
|
692
|
-
"rulesets": rulesets,
|
693
|
-
"salt_vault_secret_id": salt_vault_secret_id,
|
694
|
-
"supported_languages": supported_languages,
|
695
|
-
"vault_service_config_id": vault_service_config_id,
|
696
|
-
},
|
697
|
-
)
|
698
|
-
response.result = TypeAdapter(ServiceConfigResult).validate_python(response.json["result"])
|
699
|
-
return cast(PangeaResponse[ServiceConfigResult], response)
|
700
|
-
|
701
|
-
@overload
|
702
|
-
def update_service_config(
|
703
|
-
self,
|
704
|
-
config_id: str,
|
705
|
-
*,
|
706
|
-
version: Literal["1.0.0"],
|
707
|
-
name: str,
|
708
|
-
updated_at: str,
|
709
|
-
enabled_rules: Sequence[str] | None = None,
|
710
|
-
redactions: Mapping[str, Redaction] | None = None,
|
711
|
-
vault_service_config_id: str | None = None,
|
712
|
-
salt_vault_secret_id: str | None = None,
|
713
|
-
rules: Mapping[str, RuleV1] | None = None,
|
714
|
-
rulesets: Mapping[str, RulesetV1] | None = None,
|
715
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
716
|
-
) -> PangeaResponse[ServiceConfigResult]:
|
717
|
-
"""
|
718
|
-
Update a v1.0.0 service config.
|
719
|
-
|
720
|
-
OperationId: redact_post_v1beta_config_update
|
721
|
-
|
722
|
-
Args:
|
723
|
-
vault_service_config_id: Service config used to create the secret
|
724
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
725
|
-
"""
|
726
|
-
|
727
|
-
@overload
|
728
|
-
def update_service_config(
|
729
|
-
self,
|
730
|
-
config_id: str,
|
731
|
-
*,
|
732
|
-
version: Literal["2.0.0"] | None = None,
|
733
|
-
name: str,
|
734
|
-
updated_at: str,
|
735
|
-
enabled_rules: Sequence[str] | None = None,
|
736
|
-
enforce_enabled_rules: bool | None = None,
|
737
|
-
redactions: Mapping[str, Redaction] | None = None,
|
738
|
-
vault_service_config_id: str | None = None,
|
739
|
-
salt_vault_secret_id: str | None = None,
|
740
|
-
fpe_vault_secret_id: str | None = None,
|
741
|
-
rules: Mapping[str, RuleV2] | None = None,
|
742
|
-
rulesets: Mapping[str, RulesetV2] | None = None,
|
743
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
744
|
-
) -> PangeaResponse[ServiceConfigResult]:
|
745
|
-
"""
|
746
|
-
Update a v2.0.0 service config.
|
747
|
-
|
748
|
-
OperationId: redact_post_v1beta_config_update
|
749
|
-
|
750
|
-
Args:
|
751
|
-
enforce_enabled_rules: Always run service config enabled rules across all redact calls regardless of flags?
|
752
|
-
vault_service_config_id: Service config used to create the secret
|
753
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
754
|
-
fpe_vault_secret_id: The ID of the key used by FF3 Encryption algorithms for FPE.
|
755
|
-
"""
|
756
|
-
|
757
|
-
def update_service_config(
|
758
|
-
self,
|
759
|
-
config_id: str,
|
760
|
-
*,
|
761
|
-
version: Literal["1.0.0", "2.0.0"] | None = None,
|
762
|
-
name: str,
|
763
|
-
updated_at: str,
|
764
|
-
enabled_rules: Sequence[str] | None = None,
|
765
|
-
enforce_enabled_rules: bool | None = None,
|
766
|
-
fpe_vault_secret_id: str | None = None,
|
767
|
-
redactions: Mapping[str, Redaction] | None = None,
|
768
|
-
rules: Mapping[str, RuleV1 | RuleV2] | None = None,
|
769
|
-
rulesets: Mapping[str, RulesetV1 | RulesetV2] | None = None,
|
770
|
-
salt_vault_secret_id: str | None = None,
|
771
|
-
supported_languages: Sequence[Literal["en"]] | None = None,
|
772
|
-
vault_service_config_id: str | None = None,
|
773
|
-
) -> PangeaResponse[ServiceConfigResult]:
|
774
|
-
"""
|
775
|
-
Update a service config.
|
776
|
-
|
777
|
-
OperationId: redact_post_v1beta_config_update
|
778
|
-
|
779
|
-
Args:
|
780
|
-
enforce_enabled_rules: Always run service config enabled rules across all redact calls regardless of flags?
|
781
|
-
fpe_vault_secret_id: The ID of the key used by FF3 Encryption algorithms for FPE.
|
782
|
-
salt_vault_secret_id: Pangea only allows hashing to be done using a salt value to prevent brute-force attacks.
|
783
|
-
vault_service_config_id: Service config used to create the secret
|
784
|
-
"""
|
785
|
-
|
786
|
-
response = self.request.post(
|
787
|
-
"v1beta/config/update",
|
788
|
-
PangeaResponseResult,
|
789
|
-
data={
|
790
|
-
"id": config_id,
|
791
|
-
"updated_at": updated_at,
|
792
|
-
"name": name,
|
793
|
-
"version": version,
|
794
|
-
"enabled_rules": enabled_rules,
|
795
|
-
"enforce_enabled_rules": enforce_enabled_rules,
|
796
|
-
"fpe_vault_secret_id": fpe_vault_secret_id,
|
797
|
-
"redactions": redactions,
|
798
|
-
"rules": rules,
|
799
|
-
"rulesets": rulesets,
|
800
|
-
"salt_vault_secret_id": salt_vault_secret_id,
|
801
|
-
"supported_languages": supported_languages,
|
802
|
-
"vault_service_config_id": vault_service_config_id,
|
803
|
-
},
|
804
|
-
)
|
805
|
-
response.result = TypeAdapter(ServiceConfigResult).validate_python(response.json["result"])
|
806
|
-
return cast(PangeaResponse[ServiceConfigResult], response)
|
807
|
-
|
808
|
-
def delete_service_config(
|
809
|
-
self,
|
810
|
-
config_id: str,
|
811
|
-
) -> PangeaResponse[ServiceConfigResult]:
|
812
|
-
"""
|
813
|
-
Delete a service config.
|
814
|
-
|
815
|
-
OperationId: redact_post_v1beta_config_delete
|
816
|
-
|
817
|
-
Args:
|
818
|
-
config_id: An ID for a service config
|
819
|
-
"""
|
820
|
-
|
821
|
-
response = self.request.post("v1beta/config/delete", PangeaResponseResult, data={"id": config_id})
|
822
|
-
response.result = TypeAdapter(ServiceConfigResult).validate_python(response.json["result"])
|
823
|
-
return cast(PangeaResponse[ServiceConfigResult], response)
|
824
|
-
|
825
|
-
def list_service_configs(
|
826
|
-
self,
|
827
|
-
*,
|
828
|
-
filter: ServiceConfigFilter | None = None,
|
829
|
-
last: str | None = None,
|
830
|
-
order: Literal["asc", "desc"] | None = None,
|
831
|
-
order_by: Literal["id", "created_at", "updated_at"] | None = None,
|
832
|
-
size: int | None = None,
|
833
|
-
) -> PangeaResponse[ServiceConfigListResult]:
|
834
|
-
"""
|
835
|
-
List service configs.
|
836
|
-
|
837
|
-
OperationId: redact_post_v1beta_config_list
|
838
|
-
|
839
|
-
Args:
|
840
|
-
last: Reflected value from a previous response to obtain the next page of results.
|
841
|
-
order: Order results asc(ending) or desc(ending).
|
842
|
-
order_by: Which field to order results by.
|
843
|
-
size: Maximum results to include in the response.
|
844
|
-
"""
|
845
|
-
|
846
|
-
return self.request.post(
|
847
|
-
"v1beta/config/list",
|
848
|
-
ServiceConfigListResult,
|
849
|
-
data={"filter": filter, "last": last, "order": order, "order_by": order_by, "size": size},
|
850
|
-
)
|
pangea/services/sanitize.py
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Use `list` instead of `List`.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
3
7
|
from __future__ import annotations
|
4
8
|
|
5
9
|
import io
|
@@ -267,7 +271,7 @@ class Sanitize(ServiceBase):
|
|
267
271
|
files: Optional[List[Tuple]] = None
|
268
272
|
if file or file_path:
|
269
273
|
if file_path:
|
270
|
-
file = open(file_path, "rb")
|
274
|
+
file = open(file_path, "rb") # noqa: SIM115
|
271
275
|
if (
|
272
276
|
transfer_method == TransferMethod.POST_URL
|
273
277
|
and file
|
pangea/services/share/share.py
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Use `list` instead of `List`.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
3
7
|
from __future__ import annotations
|
4
8
|
|
5
9
|
import enum
|
6
10
|
import io
|
7
|
-
from typing import Dict, List,
|
11
|
+
from typing import Dict, List, Optional, Tuple, Union
|
12
|
+
|
13
|
+
from pydantic import RootModel
|
8
14
|
|
9
15
|
from pangea.config import PangeaConfig
|
10
16
|
from pangea.response import APIRequestModel, PangeaResponse, PangeaResponseResult, TransferMethod
|
@@ -12,8 +18,8 @@ from pangea.services.base import ServiceBase
|
|
12
18
|
from pangea.services.share.file_format import FileFormat
|
13
19
|
from pangea.utils import get_file_size, get_file_upload_params
|
14
20
|
|
15
|
-
Metadata =
|
16
|
-
Tags =
|
21
|
+
Metadata = RootModel[dict[str, str]]
|
22
|
+
Tags = RootModel[list[str]]
|
17
23
|
|
18
24
|
|
19
25
|
class ItemOrder(str, enum.Enum):
|
@@ -916,10 +922,10 @@ class Share(ServiceBase):
|
|
916
922
|
|
917
923
|
def get_archive(
|
918
924
|
self,
|
919
|
-
ids:
|
920
|
-
format:
|
921
|
-
transfer_method:
|
922
|
-
bucket_id:
|
925
|
+
ids: list[str],
|
926
|
+
format: ArchiveFormat | None = None,
|
927
|
+
transfer_method: TransferMethod | None = None,
|
928
|
+
bucket_id: str | None = None,
|
923
929
|
) -> PangeaResponse[GetArchiveResult]:
|
924
930
|
"""
|
925
931
|
Get archive
|