pangea-sdk 3.8.0b1__py3-none-any.whl → 3.8.0b2__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 +1 -1
- pangea/asyncio/services/__init__.py +1 -0
- pangea/asyncio/services/sanitize.py +185 -0
- pangea/asyncio/services/share.py +26 -13
- pangea/services/__init__.py +1 -0
- pangea/services/file_scan.py +0 -1
- pangea/services/sanitize.py +275 -0
- pangea/services/share/share.py +26 -13
- {pangea_sdk-3.8.0b1.dist-info → pangea_sdk-3.8.0b2.dist-info}/METADATA +1 -1
- {pangea_sdk-3.8.0b1.dist-info → pangea_sdk-3.8.0b2.dist-info}/RECORD +11 -9
- {pangea_sdk-3.8.0b1.dist-info → pangea_sdk-3.8.0b2.dist-info}/WHEEL +0 -0
pangea/__init__.py
CHANGED
@@ -0,0 +1,185 @@
|
|
1
|
+
# Copyright 2022 Pangea Cyber Corporation
|
2
|
+
# Author: Pangea Cyber Corporation
|
3
|
+
import io
|
4
|
+
from typing import List, Optional, Tuple
|
5
|
+
|
6
|
+
import pangea.services.sanitize as m
|
7
|
+
from pangea.asyncio.services.base import ServiceBaseAsync
|
8
|
+
from pangea.response import PangeaResponse, TransferMethod
|
9
|
+
from pangea.utils import FileUploadParams, get_file_upload_params
|
10
|
+
|
11
|
+
|
12
|
+
class SanitizeAsync(ServiceBaseAsync):
|
13
|
+
"""Sanitize service client.
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
import os
|
17
|
+
|
18
|
+
# Pangea SDK
|
19
|
+
from pangea.config import PangeaConfig
|
20
|
+
from pangea.asyncio.services import Sanitize
|
21
|
+
|
22
|
+
PANGEA_SANITIZE_TOKEN = os.getenv("PANGEA_SANITIZE_TOKEN")
|
23
|
+
config = PangeaConfig(domain="pangea.cloud")
|
24
|
+
|
25
|
+
sanitize = Sanitize(token=PANGEA_SANITIZE_TOKEN, config=config)
|
26
|
+
"""
|
27
|
+
|
28
|
+
service_name = "sanitize"
|
29
|
+
|
30
|
+
async def sanitize(
|
31
|
+
self,
|
32
|
+
transfer_method: TransferMethod = TransferMethod.POST_URL,
|
33
|
+
file_path: Optional[str] = None,
|
34
|
+
file: Optional[io.BufferedReader] = None,
|
35
|
+
source_url: Optional[str] = None,
|
36
|
+
share_id: Optional[str] = None,
|
37
|
+
file_scan: Optional[m.SanitizeFile] = None,
|
38
|
+
content: Optional[m.SanitizeContent] = None,
|
39
|
+
share_output: Optional[m.SanitizeShareOutput] = None,
|
40
|
+
size: Optional[int] = None,
|
41
|
+
crc32c: Optional[str] = None,
|
42
|
+
sha256: Optional[str] = None,
|
43
|
+
uploaded_file_name: Optional[str] = None,
|
44
|
+
sync_call: bool = True,
|
45
|
+
) -> PangeaResponse[m.SanitizeResult]:
|
46
|
+
"""
|
47
|
+
Sanitize
|
48
|
+
|
49
|
+
Apply file sanitization actions according to specified rules.
|
50
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
51
|
+
|
52
|
+
OperationId: sanitize_post_v1beta_sanitize
|
53
|
+
|
54
|
+
Args:
|
55
|
+
transfer_method: The transfer method used to upload the file data.
|
56
|
+
file_path: Path to file to sanitize.
|
57
|
+
file: File to sanitize.
|
58
|
+
source_url: A URL where the file to be sanitized can be downloaded.
|
59
|
+
share_id: A Pangea Secure Share ID where the file to be sanitized is stored.
|
60
|
+
file_scan: Options for File Scan.
|
61
|
+
content: Options for how the file should be sanitized.
|
62
|
+
share_output: Integration with Secure Share.
|
63
|
+
size: The size (in bytes) of the file. If the upload doesn't match, the call will fail.
|
64
|
+
crc32c: The CRC32C hash of the file data, which will be verified by the server if provided.
|
65
|
+
sha256: The hexadecimal-encoded SHA256 hash of the file data, which will be verified by the server if provided.
|
66
|
+
uploaded_file_name: Name of the user-uploaded file, required for `TransferMethod.PUT_URL` and `TransferMethod.POST_URL`.
|
67
|
+
sync_call: Whether or not to poll on HTTP/202.
|
68
|
+
|
69
|
+
Raises:
|
70
|
+
PangeaAPIException: If an API error happens.
|
71
|
+
|
72
|
+
Returns:
|
73
|
+
The sanitized file and information on the sanitization that was
|
74
|
+
performed.
|
75
|
+
|
76
|
+
Examples:
|
77
|
+
with open("/path/to/file.pdf", "rb") as f:
|
78
|
+
response = await sanitize.sanitize(
|
79
|
+
file=f,
|
80
|
+
transfer_method=TransferMethod.POST_URL,
|
81
|
+
uploaded_file_name="uploaded_file",
|
82
|
+
)
|
83
|
+
"""
|
84
|
+
|
85
|
+
if file or file_path:
|
86
|
+
if file_path:
|
87
|
+
file = open(file_path, "rb")
|
88
|
+
if transfer_method == TransferMethod.POST_URL and (sha256 is None or crc32c is None or size is None):
|
89
|
+
params = get_file_upload_params(file) # type: ignore[arg-type]
|
90
|
+
crc32c = params.crc_hex if crc32c is None else crc32c
|
91
|
+
sha256 = params.sha256_hex if sha256 is None else sha256
|
92
|
+
size = params.size if size is None else size
|
93
|
+
else:
|
94
|
+
crc32c, sha256, size = None, None, None
|
95
|
+
files: List[Tuple] = [("upload", ("filename", file, "application/octet-stream"))]
|
96
|
+
else:
|
97
|
+
raise ValueError("Need to set file_path or file arguments")
|
98
|
+
|
99
|
+
input = m.SanitizeRequest(
|
100
|
+
transfer_method=transfer_method,
|
101
|
+
source_url=source_url,
|
102
|
+
share_id=share_id,
|
103
|
+
file=file_scan,
|
104
|
+
content=content,
|
105
|
+
share_output=share_output,
|
106
|
+
crc32c=crc32c,
|
107
|
+
sha256=sha256,
|
108
|
+
size=size,
|
109
|
+
uploaded_file_name=uploaded_file_name,
|
110
|
+
)
|
111
|
+
data = input.dict(exclude_none=True)
|
112
|
+
response = await self.request.post(
|
113
|
+
"v1beta/sanitize", m.SanitizeResult, data=data, files=files, poll_result=sync_call
|
114
|
+
)
|
115
|
+
if file_path and file is not None:
|
116
|
+
file.close()
|
117
|
+
return response
|
118
|
+
|
119
|
+
async def request_upload_url(
|
120
|
+
self,
|
121
|
+
transfer_method: TransferMethod = TransferMethod.PUT_URL,
|
122
|
+
params: Optional[FileUploadParams] = None,
|
123
|
+
file_scan: Optional[m.SanitizeFile] = None,
|
124
|
+
content: Optional[m.SanitizeContent] = None,
|
125
|
+
share_output: Optional[m.SanitizeShareOutput] = None,
|
126
|
+
size: Optional[int] = None,
|
127
|
+
crc32c: Optional[str] = None,
|
128
|
+
sha256: Optional[str] = None,
|
129
|
+
uploaded_file_name: Optional[str] = None,
|
130
|
+
) -> PangeaResponse[m.SanitizeResult]:
|
131
|
+
"""
|
132
|
+
Sanitize via presigned URL
|
133
|
+
|
134
|
+
Apply file sanitization actions according to specified rules via a
|
135
|
+
[presigned URL](https://pangea.cloud/docs/api/presigned-urls).
|
136
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
137
|
+
|
138
|
+
OperationId: sanitize_post_v1beta_sanitize 2
|
139
|
+
|
140
|
+
Args:
|
141
|
+
transfer_method: The transfer method used to upload the file data.
|
142
|
+
params: File upload parameters.
|
143
|
+
file_scan: Options for File Scan.
|
144
|
+
content: Options for how the file should be sanitized.
|
145
|
+
share_output: Integration with Secure Share.
|
146
|
+
size: The size (in bytes) of the file. If the upload doesn't match, the call will fail.
|
147
|
+
crc32c: The CRC32C hash of the file data, which will be verified by the server if provided.
|
148
|
+
sha256: The hexadecimal-encoded SHA256 hash of the file data, which will be verified by the server if provided.
|
149
|
+
uploaded_file_name: Name of the user-uploaded file, required for `TransferMethod.PUT_URL` and `TransferMethod.POST_URL`.
|
150
|
+
|
151
|
+
Raises:
|
152
|
+
PangeaAPIException: If an API error happens.
|
153
|
+
|
154
|
+
Returns:
|
155
|
+
A presigned URL.
|
156
|
+
|
157
|
+
Examples:
|
158
|
+
presignedUrl = await sanitize.request_upload_url(
|
159
|
+
transfer_method=TransferMethod.PUT_URL,
|
160
|
+
uploaded_file_name="uploaded_file",
|
161
|
+
)
|
162
|
+
|
163
|
+
# Upload file to `presignedUrl.accepted_result.put_url`.
|
164
|
+
|
165
|
+
# Poll for Sanitize's result.
|
166
|
+
response: PangeaResponse[SanitizeResult] = await sanitize.poll_result(response=presignedUrl)
|
167
|
+
"""
|
168
|
+
|
169
|
+
input = m.SanitizeRequest(
|
170
|
+
transfer_method=transfer_method,
|
171
|
+
file=file_scan,
|
172
|
+
content=content,
|
173
|
+
share_output=share_output,
|
174
|
+
crc32c=crc32c,
|
175
|
+
sha256=sha256,
|
176
|
+
size=size,
|
177
|
+
uploaded_file_name=uploaded_file_name,
|
178
|
+
)
|
179
|
+
if params is not None and (transfer_method == TransferMethod.POST_URL):
|
180
|
+
input.crc32c = params.crc_hex
|
181
|
+
input.sha256 = params.sha256_hex
|
182
|
+
input.size = params.size
|
183
|
+
|
184
|
+
data = input.dict(exclude_none=True)
|
185
|
+
return await self.request.request_presigned_url("v1beta/sanitize", m.SanitizeResult, data=data)
|
pangea/asyncio/services/share.py
CHANGED
@@ -22,7 +22,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
22
22
|
Delete
|
23
23
|
|
24
24
|
Delete object by ID or path. If both are supplied, the path must match
|
25
|
-
that of the object represented by the ID.
|
25
|
+
that of the object represented by the ID.
|
26
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
26
27
|
|
27
28
|
OperationId: share_post_v1beta_delete
|
28
29
|
|
@@ -52,7 +53,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
52
53
|
"""
|
53
54
|
Create a folder
|
54
55
|
|
55
|
-
Create a folder, either by name or path and parent_id.
|
56
|
+
Create a folder, either by name or path and parent_id.
|
57
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
56
58
|
|
57
59
|
OperationId: share_post_v1beta_folder_create
|
58
60
|
|
@@ -88,7 +90,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
88
90
|
Get an object
|
89
91
|
|
90
92
|
Get object. If both ID and Path are supplied, the call will fail if the
|
91
|
-
target object doesn't match both properties.
|
93
|
+
target object doesn't match both properties.
|
94
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
92
95
|
|
93
96
|
OperationId: share_post_v1beta_get
|
94
97
|
|
@@ -123,7 +126,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
123
126
|
"""
|
124
127
|
Get archive
|
125
128
|
|
126
|
-
Get an archive file of multiple objects.
|
129
|
+
Get an archive file of multiple objects.
|
130
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
127
131
|
|
128
132
|
OperationId: share_post_v1beta_get_archive
|
129
133
|
|
@@ -162,7 +166,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
162
166
|
"""
|
163
167
|
List
|
164
168
|
|
165
|
-
List or filter/search records.
|
169
|
+
List or filter/search records.
|
170
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
166
171
|
|
167
172
|
OperationId: share_post_v1beta_list
|
168
173
|
|
@@ -204,7 +209,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
204
209
|
"""
|
205
210
|
Upload a file
|
206
211
|
|
207
|
-
Upload a file.
|
212
|
+
Upload a file.
|
213
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
208
214
|
|
209
215
|
OperationId: share_post_v1beta_put
|
210
216
|
|
@@ -289,7 +295,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
289
295
|
"""
|
290
296
|
Request upload URL
|
291
297
|
|
292
|
-
Request an upload URL.
|
298
|
+
Request an upload URL.
|
299
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
293
300
|
|
294
301
|
OperationId: share_post_v1beta_put 2
|
295
302
|
|
@@ -364,7 +371,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
364
371
|
"""
|
365
372
|
Update a file
|
366
373
|
|
367
|
-
Update a file.
|
374
|
+
Update a file.
|
375
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
368
376
|
|
369
377
|
OperationId: share_post_v1beta_update
|
370
378
|
|
@@ -412,7 +420,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
412
420
|
"""
|
413
421
|
Create share links
|
414
422
|
|
415
|
-
Create a share link.
|
423
|
+
Create a share link.
|
424
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
416
425
|
|
417
426
|
OperationId: share_post_v1beta_share_link_create
|
418
427
|
|
@@ -448,7 +457,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
448
457
|
"""
|
449
458
|
Get share link
|
450
459
|
|
451
|
-
Get a share link.
|
460
|
+
Get a share link.
|
461
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
452
462
|
|
453
463
|
OperationId: share_post_v1beta_share_link_get
|
454
464
|
|
@@ -480,7 +490,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
480
490
|
"""
|
481
491
|
List share links
|
482
492
|
|
483
|
-
Look up share links by filter options.
|
493
|
+
Look up share links by filter options.
|
494
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
484
495
|
|
485
496
|
OperationId: share_post_v1beta_share_link_list
|
486
497
|
|
@@ -507,7 +518,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
507
518
|
"""
|
508
519
|
Delete share links
|
509
520
|
|
510
|
-
Delete share links.
|
521
|
+
Delete share links.
|
522
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
511
523
|
|
512
524
|
OperationId: share_post_v1beta_share_link_delete
|
513
525
|
|
@@ -537,7 +549,8 @@ class ShareAsync(ServiceBaseAsync):
|
|
537
549
|
Send a secure share-link notification to a set of email addresses. The
|
538
550
|
notification email will contain an Open button that the recipient can
|
539
551
|
use to follow the secured share-link to authenticate and then access the
|
540
|
-
shared content.
|
552
|
+
shared content.
|
553
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
541
554
|
|
542
555
|
OperationId: share_post_v1beta_share_link_send
|
543
556
|
|
pangea/services/__init__.py
CHANGED
pangea/services/file_scan.py
CHANGED
@@ -0,0 +1,275 @@
|
|
1
|
+
# Copyright 2022 Pangea Cyber Corporation
|
2
|
+
# Author: Pangea Cyber Corporation
|
3
|
+
import io
|
4
|
+
from typing import Dict, List, Optional, Tuple
|
5
|
+
|
6
|
+
from pangea.response import APIRequestModel, PangeaResponse, PangeaResponseResult, TransferMethod
|
7
|
+
from pangea.services.base import ServiceBase
|
8
|
+
from pangea.utils import FileUploadParams, get_file_upload_params
|
9
|
+
|
10
|
+
|
11
|
+
class SanitizeFile(APIRequestModel):
|
12
|
+
scan_provider: Optional[str] = None
|
13
|
+
"""Provider to use for File Scan."""
|
14
|
+
|
15
|
+
cdr_provider: Optional[str] = None
|
16
|
+
"""Provider to use for CDR."""
|
17
|
+
|
18
|
+
|
19
|
+
class SanitizeContent(APIRequestModel):
|
20
|
+
url_intel: Optional[bool] = None
|
21
|
+
"""Perform URL Intel lookup."""
|
22
|
+
|
23
|
+
url_intel_provider: Optional[str] = None
|
24
|
+
"""Provider to use for URL Intel."""
|
25
|
+
|
26
|
+
domain_intel: Optional[bool] = None
|
27
|
+
"""Perform Domain Intel lookup."""
|
28
|
+
|
29
|
+
domain_intel_provider: Optional[str] = None
|
30
|
+
"""Provider to use for Domain Intel lookup."""
|
31
|
+
|
32
|
+
defang: Optional[bool] = None
|
33
|
+
"""Defang external links."""
|
34
|
+
|
35
|
+
defang_threshold: Optional[int] = None
|
36
|
+
"""Defang risk threshold."""
|
37
|
+
|
38
|
+
redact: Optional[bool] = None
|
39
|
+
"""Redact sensitive content."""
|
40
|
+
|
41
|
+
remove_attachments: Optional[bool] = None
|
42
|
+
"""Remove file attachments (PDF only)."""
|
43
|
+
|
44
|
+
remove_interactive: Optional[bool] = None
|
45
|
+
"""Remove interactive content (PDF only)."""
|
46
|
+
|
47
|
+
|
48
|
+
class SanitizeShareOutput(APIRequestModel):
|
49
|
+
enabled: Optional[bool] = None
|
50
|
+
"""Store Sanitized files to Pangea Secure Share."""
|
51
|
+
|
52
|
+
output_folder: Optional[str] = None
|
53
|
+
"""
|
54
|
+
Store Sanitized files to this Secure Share folder (will be auto-created if
|
55
|
+
it does not exist)
|
56
|
+
"""
|
57
|
+
|
58
|
+
|
59
|
+
class SanitizeRequest(APIRequestModel):
|
60
|
+
transfer_method: TransferMethod = TransferMethod.POST_URL
|
61
|
+
source_url: Optional[str] = None
|
62
|
+
share_id: Optional[str] = None
|
63
|
+
file: Optional[SanitizeFile] = None
|
64
|
+
content: Optional[SanitizeContent] = None
|
65
|
+
share_output: Optional[SanitizeShareOutput] = None
|
66
|
+
size: Optional[int] = None
|
67
|
+
crc32c: Optional[str] = None
|
68
|
+
sha256: Optional[str] = None
|
69
|
+
uploaded_file_name: Optional[str] = None
|
70
|
+
|
71
|
+
|
72
|
+
class DefangData(PangeaResponseResult):
|
73
|
+
external_urls_count: Optional[int] = None
|
74
|
+
external_domains_count: Optional[int] = None
|
75
|
+
defanged_count: Optional[int] = None
|
76
|
+
url_intel_summary: Optional[str] = None
|
77
|
+
domain_intel_summary: Optional[str] = None
|
78
|
+
|
79
|
+
|
80
|
+
class RedactData(PangeaResponseResult):
|
81
|
+
redaction_count: Optional[int] = None
|
82
|
+
summary_counts: Dict = {}
|
83
|
+
|
84
|
+
|
85
|
+
class CDR(PangeaResponseResult):
|
86
|
+
file_attachments_removed: Optional[int] = None
|
87
|
+
interactive_contents_removed: Optional[int] = None
|
88
|
+
|
89
|
+
|
90
|
+
class SanitizeData(PangeaResponseResult):
|
91
|
+
defang: Optional[DefangData] = None
|
92
|
+
redact: Optional[RedactData] = None
|
93
|
+
malicious_file: Optional[bool] = None
|
94
|
+
cdr: Optional[CDR] = None
|
95
|
+
|
96
|
+
|
97
|
+
class SanitizeResult(PangeaResponseResult):
|
98
|
+
dest_url: Optional[str] = None
|
99
|
+
dest_share_id: Optional[str] = None
|
100
|
+
data: SanitizeData
|
101
|
+
parameters: Dict = {}
|
102
|
+
|
103
|
+
|
104
|
+
class Sanitize(ServiceBase):
|
105
|
+
"""Sanitize service client.
|
106
|
+
|
107
|
+
Examples:
|
108
|
+
import os
|
109
|
+
|
110
|
+
# Pangea SDK
|
111
|
+
from pangea.config import PangeaConfig
|
112
|
+
from pangea.services import Sanitize
|
113
|
+
|
114
|
+
PANGEA_SANITIZE_TOKEN = os.getenv("PANGEA_SANITIZE_TOKEN")
|
115
|
+
config = PangeaConfig(domain="pangea.cloud")
|
116
|
+
|
117
|
+
sanitize = Sanitize(token=PANGEA_SANITIZE_TOKEN, config=config)
|
118
|
+
"""
|
119
|
+
|
120
|
+
service_name = "sanitize"
|
121
|
+
|
122
|
+
def sanitize(
|
123
|
+
self,
|
124
|
+
transfer_method: TransferMethod = TransferMethod.POST_URL,
|
125
|
+
file_path: Optional[str] = None,
|
126
|
+
file: Optional[io.BufferedReader] = None,
|
127
|
+
source_url: Optional[str] = None,
|
128
|
+
share_id: Optional[str] = None,
|
129
|
+
file_scan: Optional[SanitizeFile] = None,
|
130
|
+
content: Optional[SanitizeContent] = None,
|
131
|
+
share_output: Optional[SanitizeShareOutput] = None,
|
132
|
+
size: Optional[int] = None,
|
133
|
+
crc32c: Optional[str] = None,
|
134
|
+
sha256: Optional[str] = None,
|
135
|
+
uploaded_file_name: Optional[str] = None,
|
136
|
+
sync_call: bool = True,
|
137
|
+
) -> PangeaResponse[SanitizeResult]:
|
138
|
+
"""
|
139
|
+
Sanitize
|
140
|
+
|
141
|
+
Apply file sanitization actions according to specified rules.
|
142
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
143
|
+
|
144
|
+
OperationId: sanitize_post_v1beta_sanitize
|
145
|
+
|
146
|
+
Args:
|
147
|
+
transfer_method: The transfer method used to upload the file data.
|
148
|
+
file_path: Path to file to sanitize.
|
149
|
+
file: File to sanitize.
|
150
|
+
source_url: A URL where the file to be sanitized can be downloaded.
|
151
|
+
share_id: A Pangea Secure Share ID where the file to be sanitized is stored.
|
152
|
+
file_scan: Options for File Scan.
|
153
|
+
content: Options for how the file should be sanitized.
|
154
|
+
share_output: Integration with Secure Share.
|
155
|
+
size: The size (in bytes) of the file. If the upload doesn't match, the call will fail.
|
156
|
+
crc32c: The CRC32C hash of the file data, which will be verified by the server if provided.
|
157
|
+
sha256: The hexadecimal-encoded SHA256 hash of the file data, which will be verified by the server if provided.
|
158
|
+
uploaded_file_name: Name of the user-uploaded file, required for `TransferMethod.PUT_URL` and `TransferMethod.POST_URL`.
|
159
|
+
sync_call: Whether or not to poll on HTTP/202.
|
160
|
+
|
161
|
+
Raises:
|
162
|
+
PangeaAPIException: If an API error happens.
|
163
|
+
|
164
|
+
Returns:
|
165
|
+
The sanitized file and information on the sanitization that was
|
166
|
+
performed.
|
167
|
+
|
168
|
+
Examples:
|
169
|
+
with open("/path/to/file.pdf", "rb") as f:
|
170
|
+
response = sanitize.sanitize(
|
171
|
+
file=f,
|
172
|
+
transfer_method=TransferMethod.POST_URL,
|
173
|
+
uploaded_file_name="uploaded_file",
|
174
|
+
)
|
175
|
+
"""
|
176
|
+
|
177
|
+
if file or file_path:
|
178
|
+
if file_path:
|
179
|
+
file = open(file_path, "rb")
|
180
|
+
if transfer_method == TransferMethod.POST_URL and (sha256 is None or crc32c is None or size is None):
|
181
|
+
params = get_file_upload_params(file) # type: ignore[arg-type]
|
182
|
+
crc32c = params.crc_hex if crc32c is None else crc32c
|
183
|
+
sha256 = params.sha256_hex if sha256 is None else sha256
|
184
|
+
size = params.size if size is None else size
|
185
|
+
else:
|
186
|
+
crc32c, sha256, size = None, None, None
|
187
|
+
files: List[Tuple] = [("upload", ("filename", file, "application/octet-stream"))]
|
188
|
+
else:
|
189
|
+
raise ValueError("Need to set file_path or file arguments")
|
190
|
+
|
191
|
+
input = SanitizeRequest(
|
192
|
+
transfer_method=transfer_method,
|
193
|
+
source_url=source_url,
|
194
|
+
share_id=share_id,
|
195
|
+
file=file_scan,
|
196
|
+
content=content,
|
197
|
+
share_output=share_output,
|
198
|
+
crc32c=crc32c,
|
199
|
+
sha256=sha256,
|
200
|
+
size=size,
|
201
|
+
uploaded_file_name=uploaded_file_name,
|
202
|
+
)
|
203
|
+
data = input.dict(exclude_none=True)
|
204
|
+
response = self.request.post("v1beta/sanitize", SanitizeResult, data=data, files=files, poll_result=sync_call)
|
205
|
+
if file_path and file is not None:
|
206
|
+
file.close()
|
207
|
+
return response
|
208
|
+
|
209
|
+
def request_upload_url(
|
210
|
+
self,
|
211
|
+
transfer_method: TransferMethod = TransferMethod.PUT_URL,
|
212
|
+
params: Optional[FileUploadParams] = None,
|
213
|
+
file_scan: Optional[SanitizeFile] = None,
|
214
|
+
content: Optional[SanitizeContent] = None,
|
215
|
+
share_output: Optional[SanitizeShareOutput] = None,
|
216
|
+
size: Optional[int] = None,
|
217
|
+
crc32c: Optional[str] = None,
|
218
|
+
sha256: Optional[str] = None,
|
219
|
+
uploaded_file_name: Optional[str] = None,
|
220
|
+
) -> PangeaResponse[SanitizeResult]:
|
221
|
+
"""
|
222
|
+
Sanitize via presigned URL
|
223
|
+
|
224
|
+
Apply file sanitization actions according to specified rules via a
|
225
|
+
[presigned URL](https://pangea.cloud/docs/api/presigned-urls).
|
226
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
227
|
+
|
228
|
+
OperationId: sanitize_post_v1beta_sanitize 2
|
229
|
+
|
230
|
+
Args:
|
231
|
+
transfer_method: The transfer method used to upload the file data.
|
232
|
+
params: File upload parameters.
|
233
|
+
file_scan: Options for File Scan.
|
234
|
+
content: Options for how the file should be sanitized.
|
235
|
+
share_output: Integration with Secure Share.
|
236
|
+
size: The size (in bytes) of the file. If the upload doesn't match, the call will fail.
|
237
|
+
crc32c: The CRC32C hash of the file data, which will be verified by the server if provided.
|
238
|
+
sha256: The hexadecimal-encoded SHA256 hash of the file data, which will be verified by the server if provided.
|
239
|
+
uploaded_file_name: Name of the user-uploaded file, required for `TransferMethod.PUT_URL` and `TransferMethod.POST_URL`.
|
240
|
+
|
241
|
+
Raises:
|
242
|
+
PangeaAPIException: If an API error happens.
|
243
|
+
|
244
|
+
Returns:
|
245
|
+
A presigned URL.
|
246
|
+
|
247
|
+
Examples:
|
248
|
+
presignedUrl = sanitize.request_upload_url(
|
249
|
+
transfer_method=TransferMethod.PUT_URL,
|
250
|
+
uploaded_file_name="uploaded_file",
|
251
|
+
)
|
252
|
+
|
253
|
+
# Upload file to `presignedUrl.accepted_result.put_url`.
|
254
|
+
|
255
|
+
# Poll for Sanitize's result.
|
256
|
+
response: PangeaResponse[SanitizeResult] = sanitize.poll_result(response=presignedUrl)
|
257
|
+
"""
|
258
|
+
|
259
|
+
input = SanitizeRequest(
|
260
|
+
transfer_method=transfer_method,
|
261
|
+
file=file_scan,
|
262
|
+
content=content,
|
263
|
+
share_output=share_output,
|
264
|
+
crc32c=crc32c,
|
265
|
+
sha256=sha256,
|
266
|
+
size=size,
|
267
|
+
uploaded_file_name=uploaded_file_name,
|
268
|
+
)
|
269
|
+
if params is not None and (transfer_method == TransferMethod.POST_URL):
|
270
|
+
input.crc32c = params.crc_hex
|
271
|
+
input.sha256 = params.sha256_hex
|
272
|
+
input.size = params.size
|
273
|
+
|
274
|
+
data = input.dict(exclude_none=True)
|
275
|
+
return self.request.request_presigned_url("v1beta/sanitize", SanitizeResult, data=data)
|
pangea/services/share/share.py
CHANGED
@@ -348,7 +348,8 @@ class Share(ServiceBase):
|
|
348
348
|
Delete
|
349
349
|
|
350
350
|
Delete object by ID or path. If both are supplied, the path must match
|
351
|
-
that of the object represented by the ID.
|
351
|
+
that of the object represented by the ID.
|
352
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
352
353
|
|
353
354
|
OperationId: share_post_v1beta_delete
|
354
355
|
|
@@ -377,7 +378,8 @@ class Share(ServiceBase):
|
|
377
378
|
"""
|
378
379
|
Create a folder
|
379
380
|
|
380
|
-
Create a folder, either by name or path and parent_id.
|
381
|
+
Create a folder, either by name or path and parent_id.
|
382
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
381
383
|
|
382
384
|
OperationId: share_post_v1beta_folder_create
|
383
385
|
|
@@ -412,7 +414,8 @@ class Share(ServiceBase):
|
|
412
414
|
Get an object
|
413
415
|
|
414
416
|
Get object. If both ID and Path are supplied, the call will fail if the
|
415
|
-
target object doesn't match both properties.
|
417
|
+
target object doesn't match both properties.
|
418
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
416
419
|
|
417
420
|
OperationId: share_post_v1beta_get
|
418
421
|
|
@@ -446,7 +449,8 @@ class Share(ServiceBase):
|
|
446
449
|
"""
|
447
450
|
Get archive
|
448
451
|
|
449
|
-
Get an archive file of multiple objects.
|
452
|
+
Get an archive file of multiple objects.
|
453
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
450
454
|
|
451
455
|
OperationId: share_post_v1beta_get_archive
|
452
456
|
|
@@ -484,7 +488,8 @@ class Share(ServiceBase):
|
|
484
488
|
"""
|
485
489
|
List
|
486
490
|
|
487
|
-
List or filter/search records.
|
491
|
+
List or filter/search records.
|
492
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
488
493
|
|
489
494
|
OperationId: share_post_v1beta_list
|
490
495
|
|
@@ -525,7 +530,8 @@ class Share(ServiceBase):
|
|
525
530
|
"""
|
526
531
|
Upload a file
|
527
532
|
|
528
|
-
Upload a file.
|
533
|
+
Upload a file.
|
534
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
529
535
|
|
530
536
|
OperationId: share_post_v1beta_put
|
531
537
|
|
@@ -609,7 +615,8 @@ class Share(ServiceBase):
|
|
609
615
|
"""
|
610
616
|
Request upload URL
|
611
617
|
|
612
|
-
Request an upload URL.
|
618
|
+
Request an upload URL.
|
619
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
613
620
|
|
614
621
|
OperationId: share_post_v1beta_put 2
|
615
622
|
|
@@ -683,7 +690,8 @@ class Share(ServiceBase):
|
|
683
690
|
"""
|
684
691
|
Update a file
|
685
692
|
|
686
|
-
Update a file.
|
693
|
+
Update a file.
|
694
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
687
695
|
|
688
696
|
OperationId: share_post_v1beta_update
|
689
697
|
|
@@ -730,7 +738,8 @@ class Share(ServiceBase):
|
|
730
738
|
"""
|
731
739
|
Create share links
|
732
740
|
|
733
|
-
Create a share link.
|
741
|
+
Create a share link.
|
742
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
734
743
|
|
735
744
|
OperationId: share_post_v1beta_share_link_create
|
736
745
|
|
@@ -763,7 +772,8 @@ class Share(ServiceBase):
|
|
763
772
|
"""
|
764
773
|
Get share link
|
765
774
|
|
766
|
-
Get a share link.
|
775
|
+
Get a share link.
|
776
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
767
777
|
|
768
778
|
OperationId: share_post_v1beta_share_link_get
|
769
779
|
|
@@ -792,7 +802,8 @@ class Share(ServiceBase):
|
|
792
802
|
"""
|
793
803
|
List share links
|
794
804
|
|
795
|
-
Look up share links by filter options.
|
805
|
+
Look up share links by filter options.
|
806
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
796
807
|
|
797
808
|
OperationId: share_post_v1beta_share_link_list
|
798
809
|
|
@@ -816,7 +827,8 @@ class Share(ServiceBase):
|
|
816
827
|
"""
|
817
828
|
Delete share links
|
818
829
|
|
819
|
-
Delete share links.
|
830
|
+
Delete share links.
|
831
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
820
832
|
|
821
833
|
OperationId: share_post_v1beta_share_link_delete
|
822
834
|
|
@@ -843,7 +855,8 @@ class Share(ServiceBase):
|
|
843
855
|
Send a secure share-link notification to a set of email addresses. The
|
844
856
|
notification email will contain an Open button that the recipient can
|
845
857
|
use to follow the secured share-link to authenticate and then access the
|
846
|
-
shared content.
|
858
|
+
shared content.
|
859
|
+
[**Beta API**](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
847
860
|
|
848
861
|
OperationId: share_post_v1beta_share_link_send
|
849
862
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
pangea/__init__.py,sha256=
|
1
|
+
pangea/__init__.py,sha256=frHRs4xf9u9kfWJlrcNwltqXeWYjDCjJ3uDZaT12Fx0,251
|
2
2
|
pangea/asyncio/__init__.py,sha256=kjEMkqMQ521LlMSu5jn3_WgweyArwVZ2C-s3x7mR6Pk,45
|
3
3
|
pangea/asyncio/file_uploader.py,sha256=nIBDNvZPwl-iA95OdwgEPeqUizvaBVsOc66Wkfux_6A,1462
|
4
4
|
pangea/asyncio/request.py,sha256=ceFLWZ9MONt40PETarh1DSSDhA2rrDGgLrVz7u4xduQ,17272
|
5
|
-
pangea/asyncio/services/__init__.py,sha256=
|
5
|
+
pangea/asyncio/services/__init__.py,sha256=XZyaFnvcA9fmYuKXXZi3ksjad6fssUa-8zqszW7ZZaY,356
|
6
6
|
pangea/asyncio/services/audit.py,sha256=FJzSQSRhzQ0MNuhvMvziGyfGhcFb_HHeJ11NkPS_DBU,19594
|
7
7
|
pangea/asyncio/services/authn.py,sha256=njuhg0SMLkke4Bmqe0C75BybjnmsC1ruAv6ariNbFwY,43812
|
8
8
|
pangea/asyncio/services/base.py,sha256=4FtKtlq74NmE9myrgIt9HMA6JDnP4mPZ6krafWr286o,2663
|
@@ -10,7 +10,8 @@ pangea/asyncio/services/embargo.py,sha256=8WguyWZUaGVwGpNzic5h8QzLueirA9WpBBik4m
|
|
10
10
|
pangea/asyncio/services/file_scan.py,sha256=WIKYjUNCIx6jF0vQ-KnsKYBcZh53Q5rmccTlsTPP_rY,6301
|
11
11
|
pangea/asyncio/services/intel.py,sha256=SSOBkD1vE0laQ2qWIDi5tHuYphQ8gFM_ikxr6VyoEp4,37665
|
12
12
|
pangea/asyncio/services/redact.py,sha256=Crs8fpPG3gMgxR5uRT22qaS85yorUzec-PY1lYK4FzI,5174
|
13
|
-
pangea/asyncio/services/
|
13
|
+
pangea/asyncio/services/sanitize.py,sha256=FaT2Zp9vMSs61poyMFPxduO4DwIdVl2pOl0BZnlsi34,7528
|
14
|
+
pangea/asyncio/services/share.py,sha256=qB2yBS_66iSgBFsYMTrNcrTWu-UfRDZFQ3Os8KjmFVo,24447
|
14
15
|
pangea/asyncio/services/vault.py,sha256=i8LGfZT5MQ_PFcOSA-zM3aRqlwkGHOu1WJ8U0VJaekc,47360
|
15
16
|
pangea/audit_logger.py,sha256=gRkCfUUT5LDNaycwxkhZUySgY47jDfn1ZeKOul4XCQI,3842
|
16
17
|
pangea/config.py,sha256=mQUu8GX_6weIuv3vjNdG5plppXskXYASmxMWtFQh-hc,1662
|
@@ -22,7 +23,7 @@ pangea/file_uploader.py,sha256=4RQ44xt-faApC61nn2PlwHT7XYrJ4GeQA8Ug4tySEAg,1227
|
|
22
23
|
pangea/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
24
|
pangea/request.py,sha256=eJBojjqVkIweNgf-MeHU9JqmuRXAZ-jFx2Rk25vKgIA,24346
|
24
25
|
pangea/response.py,sha256=wKHFCZBkv27PvMG5Z5pa4FYqzmMl_Pp8e_nfmNeed3k,7042
|
25
|
-
pangea/services/__init__.py,sha256=
|
26
|
+
pangea/services/__init__.py,sha256=F6mTQ0oU2g21GUIJeNBFXWuye8SWxl2Z5FFEv6fyWsc,315
|
26
27
|
pangea/services/audit/audit.py,sha256=NFpAz_a8JoI89HqGsBTqJgjSbTP0yflNQYY6McU6rek,32834
|
27
28
|
pangea/services/audit/exceptions.py,sha256=bhVuYe4ammacOVxwg98CChxvwZf5FKgR2DcgqILOcwc,471
|
28
29
|
pangea/services/audit/models.py,sha256=zKx-CozUSv0dem4sWxqUs_By0CcQQtNUFtXYg6IAwtI,12644
|
@@ -32,11 +33,12 @@ pangea/services/authn/authn.py,sha256=pjx8CybKhkf0Q9jNpcYUwAPL0KYr1ULg-mhdb0TbQb
|
|
32
33
|
pangea/services/authn/models.py,sha256=FZ5kRBZQ-Pr2YD3jFZ4HvJI22ObbXaBb6HStjcN7-D0,18104
|
33
34
|
pangea/services/base.py,sha256=60FuZkACFGDDQFZfx9vzspPTtZU0pFqNKM_ViatXejc,3012
|
34
35
|
pangea/services/embargo.py,sha256=WFqBreGU1FPgOSabIIkWCrXBvquYN958Un7h9P1aHSI,3885
|
35
|
-
pangea/services/file_scan.py,sha256=
|
36
|
+
pangea/services/file_scan.py,sha256=loceEPhHTG4fKxUXk0Qut-ztGm4N-FaSMl2QBy2x20U,6923
|
36
37
|
pangea/services/intel.py,sha256=r-MRWuyo5wPNi69M2PGb3G2TlA4e77ZR2RlSVSmT8as,51637
|
37
38
|
pangea/services/redact.py,sha256=9LSVDyQsL_RBWioMXVq6-6Hf7Tr2bqBZo3ydbDw92Bg,7772
|
39
|
+
pangea/services/sanitize.py,sha256=8Y0Wnmt3qHCc3jCIa2dryDagmAPKduJNGygsW1Fb-H4,10044
|
38
40
|
pangea/services/share/file_format.py,sha256=1svO1ee_aenA9zoO_AaU-Rk5Ulp7kcPOc_KwNoluyQE,2797
|
39
|
-
pangea/services/share/share.py,sha256=
|
41
|
+
pangea/services/share/share.py,sha256=WOqthaDSx1GAbjqJ2y-7kHXIl0-jFLWK2HQ7qjfOHio,32185
|
40
42
|
pangea/services/vault/models/asymmetric.py,sha256=ac2Exc66elXxO-HxBqtvLPQWNI7y_00kb6SVqBPKecA,1450
|
41
43
|
pangea/services/vault/models/common.py,sha256=Ks6reIlWx3PU1lD0UlorcAlZV8U9T3j711iOsb6qp3o,11120
|
42
44
|
pangea/services/vault/models/secret.py,sha256=cLgEj-_BeGkB4-pmSeTkWVyasFbaJwcEltIEcOyf1U8,481
|
@@ -45,6 +47,6 @@ pangea/services/vault/vault.py,sha256=5islfGG4QLXHaZDwv7dEIPxpmpV8swFIYwCMz6-iBw
|
|
45
47
|
pangea/tools.py,sha256=sa2pSz-L8tB6GcZg6lghsmm8w0qMQAIkzqcv7dilU6Q,6429
|
46
48
|
pangea/utils.py,sha256=LTWkm7AZO95PITY1w7zbt6N3jWK1OPgzwy69FOKljCY,5289
|
47
49
|
pangea/verify_audit.py,sha256=QthhKzFlIQwoEyjBLojcX4uHGaN3EEGomx-IC5e3L0E,10756
|
48
|
-
pangea_sdk-3.8.
|
49
|
-
pangea_sdk-3.8.
|
50
|
-
pangea_sdk-3.8.
|
50
|
+
pangea_sdk-3.8.0b2.dist-info/METADATA,sha256=7D25G-WgyaP5HQUc88Vo9To2sx66y8sl41YpoVr1Yn8,7079
|
51
|
+
pangea_sdk-3.8.0b2.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
52
|
+
pangea_sdk-3.8.0b2.dist-info/RECORD,,
|
File without changes
|