pangea-sdk 5.0.0__py3-none-any.whl → 5.2.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/utils.py CHANGED
@@ -5,7 +5,7 @@ import copy
5
5
  import datetime
6
6
  import io
7
7
  import json
8
- from hashlib import new, sha1, sha256, sha512
8
+ from hashlib import md5, new, sha1, sha256, sha512
9
9
 
10
10
  from google_crc32c import Checksum as CRC32C
11
11
  from pydantic import BaseModel
@@ -66,33 +66,97 @@ def canonicalize(data: dict) -> str:
66
66
  return str(data)
67
67
 
68
68
 
69
- def hash_sha256(data: str) -> str:
70
- # Return sha256 hash in hex format
71
- return sha256(data.encode("ascii")).hexdigest()
69
+ def hash_sha256(input: str | io.BufferedReader) -> str:
70
+ # Return SHA256 hash in hex format
71
+ hash = sha256()
72
+ if isinstance(input, io.BufferedReader):
73
+ input.seek(0) # restart reading
74
+ while True:
75
+ chunk = input.read(1024 * 1024)
76
+ if not chunk:
77
+ break
78
+ hash.update(chunk)
72
79
 
80
+ input.seek(0) # restart reading
81
+ else:
82
+ hash.update(input.encode("utf-8"))
73
83
 
74
- def hash_256_filepath(filepath: str) -> str:
75
- data = open(filepath, "rb")
76
- hash = sha256(data.read()).hexdigest()
77
- data.close()
78
- return hash
84
+ return hash.hexdigest()
85
+
86
+
87
+ def hash_sha1(input: str | io.BufferedReader) -> str:
88
+ # Return SHA1 hash in hex format
89
+ hash = sha1()
90
+ if isinstance(input, io.BufferedReader):
91
+ input.seek(0) # restart reading
92
+ while True:
93
+ chunk = input.read(1024 * 1024)
94
+ if not chunk:
95
+ break
96
+ hash.update(chunk)
79
97
 
98
+ input.seek(0) # restart reading
99
+ else:
100
+ hash.update(input.encode("utf-8"))
101
+
102
+ return hash.hexdigest()
80
103
 
81
- def hash_sha1(data: str) -> str:
82
- # Return sha1 hash in hex format
83
- return sha1(data.encode("ascii")).hexdigest()
84
104
 
105
+ def hash_sha512(input: str | io.BufferedReader) -> str:
106
+ # Return SHA512 hash in hex format
107
+ hash = sha512()
108
+ if isinstance(input, io.BufferedReader):
109
+ input.seek(0) # restart reading
110
+ while True:
111
+ chunk = input.read(1024 * 1024)
112
+ if not chunk:
113
+ break
114
+ hash.update(chunk)
115
+
116
+ input.seek(0) # restart reading
117
+ else:
118
+ hash.update(input.encode("utf-8"))
85
119
 
86
- def hash_sha512(data: str) -> str:
87
- # Return sha512 hash in hex format
88
- return sha512(data.encode("ascii")).hexdigest()
120
+ return hash.hexdigest()
89
121
 
90
122
 
91
- def hash_ntlm(data: str):
92
- # Calculate the NTLM hash
123
+ def hash_ntlm(data: str) -> str:
124
+ # Return NTLM hash in hex format
93
125
  return new("md4", data.encode("utf-16le")).hexdigest()
94
126
 
95
127
 
128
+ def hash_md5(input: str | io.BufferedReader) -> str:
129
+ # Return MD5 hash in hex format
130
+ hash = md5()
131
+ if isinstance(input, io.BufferedReader):
132
+ input.seek(0) # restart reading
133
+
134
+ while True:
135
+ chunk = input.read(1024 * 1024)
136
+ if not chunk:
137
+ break
138
+ hash.update(chunk)
139
+
140
+ input.seek(0) # restart reading
141
+ else:
142
+ hash.update(input.encode("utf-8"))
143
+
144
+ return hash.hexdigest()
145
+
146
+
147
+ def get_crc32c(data: str) -> str:
148
+ crc = CRC32C()
149
+ crc.update(data)
150
+ return crc.hexdigest().decode("utf-8")
151
+
152
+
153
+ def hash_256_filepath(filepath: str) -> str:
154
+ data = open(filepath, "rb")
155
+ hash = sha256(data.read()).hexdigest()
156
+ data.close()
157
+ return hash
158
+
159
+
96
160
  def get_prefix(hash: str, len: int = 5):
97
161
  return hash[0:len]
98
162
 
@@ -122,3 +186,10 @@ def get_file_upload_params(file: io.BufferedReader) -> FileUploadParams:
122
186
 
123
187
  file.seek(0) # restart reading
124
188
  return FileUploadParams(crc_hex=crc.hexdigest().decode("utf-8"), sha256_hex=sha.hexdigest(), size=size)
189
+
190
+
191
+ def get_file_size(file: io.BufferedReader) -> int:
192
+ file.seek(0, io.SEEK_END)
193
+ size = file.tell()
194
+ file.seek(0) # restart reading
195
+ return size
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pangea-sdk
3
- Version: 5.0.0
3
+ Version: 5.2.0
4
4
  Summary: Pangea API SDK
5
5
  Home-page: https://pangea.cloud/docs/sdk/python/
6
6
  License: MIT
@@ -17,11 +17,11 @@ Classifier: Programming Language :: Python :: 3.12
17
17
  Classifier: Programming Language :: Python :: 3.13
18
18
  Classifier: Topic :: Software Development
19
19
  Classifier: Topic :: Software Development :: Libraries
20
- Requires-Dist: aiohttp (>=3.10.10,<4.0.0)
21
- Requires-Dist: cryptography (>=43.0.1,<44.0.0)
22
- Requires-Dist: deprecated (>=1.2.14,<2.0.0)
20
+ Requires-Dist: aiohttp (>=3.11.10,<4.0.0)
21
+ Requires-Dist: cryptography (>=43.0.3,<44.0.0)
22
+ Requires-Dist: deprecated (>=1.2.15,<2.0.0)
23
23
  Requires-Dist: google-crc32c (>=1.5.0,<2.0.0)
24
- Requires-Dist: pydantic (>=2.9.2,<3.0.0)
24
+ Requires-Dist: pydantic (>=2.10.3,<3.0.0)
25
25
  Requires-Dist: python-dateutil (>=2.9.0,<3.0.0)
26
26
  Requires-Dist: requests (>=2.31.0,<3.0.0)
27
27
  Requires-Dist: requests-toolbelt (>=1.0.0,<2.0.0)
@@ -64,20 +64,21 @@ $ poetry add pangea-sdk
64
64
  #### Beta releases
65
65
 
66
66
  Pre-release versions may be available with the `b` (beta) denotation in the
67
- version number. These releases serve to preview beta services and APIs. Per
68
- Semantic Versioning, they are considered unstable and do not carry the same
69
- compatibility guarantees as stable releases. [Beta changelog](https://github.com/pangeacyber/pangea-python/blob/beta/CHANGELOG.md).
67
+ version number. These releases serve to preview Beta and Early Access services
68
+ and APIs. Per Semantic Versioning, they are considered unstable and do not carry
69
+ the same compatibility guarantees as stable releases.
70
+ [Beta changelog](https://github.com/pangeacyber/pangea-python/blob/beta/CHANGELOG.md).
70
71
 
71
72
  Via pip:
72
73
 
73
74
  ```bash
74
- $ pip3 install pangea-sdk==3.8.0b2
75
+ $ pip3 install pangea-sdk==5.2.0b1
75
76
  ```
76
77
 
77
78
  Via poetry:
78
79
 
79
80
  ```bash
80
- $ poetry add pangea-sdk==3.8.0b2
81
+ $ poetry add pangea-sdk==5.2.0b1
81
82
  ```
82
83
 
83
84
  ## Usage
@@ -1,44 +1,47 @@
1
- pangea/__init__.py,sha256=Zdds_5hmg83isP-j_8g2vwcc4OKEfAo1e-7_8TV087Y,246
1
+ pangea/__init__.py,sha256=9eKOhXARZe6eGTwrLyOBGfDQV02cZF1aQ4GVGjL1yyc,246
2
2
  pangea/asyncio/__init__.py,sha256=kjEMkqMQ521LlMSu5jn3_WgweyArwVZ2C-s3x7mR6Pk,45
3
3
  pangea/asyncio/file_uploader.py,sha256=wI7epib7Rc5jtZw4eJ1L1SlmutDG6CPv59C8N2UPhtY,1436
4
- pangea/asyncio/request.py,sha256=gsYH-pXZ6HRgOQeA4SwahCqqWnPN5j3yAPx8Vl-Vdys,17333
5
- pangea/asyncio/services/__init__.py,sha256=hMeTMnksGimg-fS_XMpRgh02a7BNcLYCt56tnChYeC4,356
6
- pangea/asyncio/services/audit.py,sha256=bZ7gdkVWkzqLqUVc1Wnf3oDAaCLg97-zTWhY8UdX0_Y,26549
4
+ pangea/asyncio/request.py,sha256=BREsLY8_MCxGSplHbdKFZTzr4TX5ya0-BsXLffZhsco,17849
5
+ pangea/asyncio/services/__init__.py,sha256=3IkiTqY_RtFndI7aoDTrb1yLv8xos_cKhmGS1TULcmw,386
6
+ pangea/asyncio/services/audit.py,sha256=rPaCx4cMzj-g9WFMRIysFCJAz6Btp6YrhcKe_exky8k,26283
7
7
  pangea/asyncio/services/authn.py,sha256=rPeLJweL8mYH_t4ebcQn4n_Wglr3kClKNnCXNCimZU4,46622
8
- pangea/asyncio/services/authz.py,sha256=HgW9R8DeW19wS7fpgq0NWOx41wZWcn6NYS4NMbi8p1A,9482
9
- pangea/asyncio/services/base.py,sha256=4FtKtlq74NmE9myrgIt9HMA6JDnP4mPZ6krafWr286o,2663
8
+ pangea/asyncio/services/authz.py,sha256=B_0_nhDMJcjNpjpCx3Vi2LDRhlmfV9325GKbUZ8reos,10025
9
+ pangea/asyncio/services/base.py,sha256=vRFVcO_uEAGJte3OUUBLD43RoiiFB1vC7SPyN6yEMoA,3158
10
10
  pangea/asyncio/services/embargo.py,sha256=ctzj3kip6xos-Eu3JuOskrCGYC8T3JlsgAopZHiPSXM,3068
11
11
  pangea/asyncio/services/file_scan.py,sha256=PLG1O-PL4Yk9uY9D6NbMrZ5LHg70Z311s7bFe46UMZA,7108
12
- pangea/asyncio/services/intel.py,sha256=cCm3VwWxUzEUCNhuPCeejJvr4uOeLXuYDbDwTzNG6Aw,38121
12
+ pangea/asyncio/services/intel.py,sha256=Iwz_DleAPtmd1taekT4W8lVo65uHjIvA4TQ7WUQGrRk,38306
13
13
  pangea/asyncio/services/redact.py,sha256=jRNtXr_DZ_cY7guhut-eZmOEhy2uN_VCXrjGH6bkh74,7265
14
- pangea/asyncio/services/sanitize.py,sha256=bf98J-s-P51oSKqNBgR0wj5mlHOCBwpjWz7k0NdXCKQ,7899
14
+ pangea/asyncio/services/sanitize.py,sha256=4pRWBH595kFUXBkmu8euyk6H7F1M_-xXB2Qxnz6St6c,8627
15
+ pangea/asyncio/services/share.py,sha256=YPJm_Gc4tfcx2cX6P_vLWIsHOR6M3RYy9LdU2UzEZbk,26791
15
16
  pangea/asyncio/services/vault.py,sha256=VqrJGSEdq6MlZRI6cJpkthhIsqLClSQdgVxwYCbIwEk,77079
16
17
  pangea/audit_logger.py,sha256=gRkCfUUT5LDNaycwxkhZUySgY47jDfn1ZeKOul4XCQI,3842
17
18
  pangea/config.py,sha256=mQUu8GX_6weIuv3vjNdG5plppXskXYASmxMWtFQh-hc,1662
18
19
  pangea/crypto/rsa.py,sha256=mwSiNy571KAGr3F6oEM0CXWkl9D023ch8ldbZZeLj_4,4747
19
- pangea/deep_verify.py,sha256=mocaGbC6XLbMTVWxTpMv4oJtXGPWpT-SbFqT3obpiZs,8443
20
+ pangea/deep_verify.py,sha256=ZGraaL7TCxwRBIDqjBFR0clKlhAC-Yce6kD-1LClhG8,8616
20
21
  pangea/deprecated.py,sha256=IjFYEVvY1E0ld0SMkEYC1o62MAleX3nnT1If2dFVbHo,608
21
- pangea/dump_audit.py,sha256=1Je8D2fXwU4PWcZ-ZD4icfO3DNFvWqJkwsac4qFEhOo,7025
22
+ pangea/dump_audit.py,sha256=IevqaUUh7GDepdIW7slSxeZbkPrWIVbcX3sr4DgpJXI,7090
22
23
  pangea/exceptions.py,sha256=OBtzUECpNa6vNp8ySkHC-tm4QjFRCOAHBkMHqzAlOu8,5656
23
24
  pangea/file_uploader.py,sha256=4RQ44xt-faApC61nn2PlwHT7XYrJ4GeQA8Ug4tySEAg,1227
24
25
  pangea/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- pangea/request.py,sha256=So4sCa59ejlqpdhrGJ8Qj6JLmd2U8-YMrOnngCZykOs,24318
26
- pangea/response.py,sha256=rjQuTAHLSAB0m2uAsdbt11xUVL5cCGT4uTRzQhUz9hE,7321
27
- pangea/services/__init__.py,sha256=YPXqGGUlAm2oHQNArhDVfr6Y1Gq2o4nhwx_dpdKe74c,309
28
- pangea/services/audit/audit.py,sha256=IFv7jANA8S2SypQVS47x94_Cr5Z9zSsL9Dp9eXw9RHk,39593
26
+ pangea/request.py,sha256=zxFvqbeGYtxN29nS8SPPZKlcGCqdUtenxaq84pQ4cxs,24807
27
+ pangea/response.py,sha256=lPAcYsF9Xg166CiyhCofVmQA-W4jevh0MQXxUa8Re68,7737
28
+ pangea/services/__init__.py,sha256=-QsZxRzRq_V1x1lmS_mu4310MNm0DkM4r6g6rfVGnOc,340
29
+ pangea/services/audit/audit.py,sha256=7-c9l7jyGtpG7SqRUMpqsAzcUDhMZ5izgPalxHXsUvM,39320
29
30
  pangea/services/audit/exceptions.py,sha256=bhVuYe4ammacOVxwg98CChxvwZf5FKgR2DcgqILOcwc,471
30
31
  pangea/services/audit/models.py,sha256=1h1B9eSYQMYG3f8WNi1UcDX2-impRrET_ErjJYUnj7M,14678
31
32
  pangea/services/audit/signing.py,sha256=5A4hvPtpfP2kMz8bsiiKUACriXbh5dv9gb_rbqiUtuI,5583
32
33
  pangea/services/audit/util.py,sha256=Zq1qvfeplYfhCP_ud5YMvntSB0UvnCdsuYbOzZkHbjg,7620
33
34
  pangea/services/authn/authn.py,sha256=cZKl2Ixc6HwHnkRecpSaAGTQUgaZUtxfLa0T3S03HMs,45478
34
35
  pangea/services/authn/models.py,sha256=HH5su6jx3O9AwVGzASXZ99-eIWjgXEP5LhIVdewM13s,22394
35
- pangea/services/authz.py,sha256=HfDnovAokzAHvnjYdOCwceM-1sCmzODnjNEbQBUSfo8,12222
36
- pangea/services/base.py,sha256=lwhHoe5Juy28Ir3Mfj2lHdM58gxZRaxa2SRFi4_DBRw,3453
36
+ pangea/services/authz.py,sha256=bB0ZEUuXLT7Xjs5kZef1hZK6Du6VUusHe5aekNaxamw,12746
37
+ pangea/services/base.py,sha256=43pWQcR9CeT4sGzgctF3Sy4M_h7DaUzkuZD2Z7CcDUU,3845
37
38
  pangea/services/embargo.py,sha256=9Wfku4td5ORaIENKmnGmS5jxJJIRfWp6Q51L36Jsy0I,3897
38
39
  pangea/services/file_scan.py,sha256=QiO80uKqB_BnAOiYQKznXfxpa5j40qqETE3-zBRT_QE,7813
39
- pangea/services/intel.py,sha256=CziBhC5K6O_kBXpD8zgJLpDtLHzBRgATGW4gHHFJT48,52039
40
- pangea/services/redact.py,sha256=ZYXkzEoriLJyCqaj5dqmgsC56mIz4T3pPToZ7TcNfhg,11465
41
- pangea/services/sanitize.py,sha256=XP5D4CcbCZfzgU567X6H5eFBWwZuYSsHdvsdrQAZekY,12767
40
+ pangea/services/intel.py,sha256=flVdK4WhllPutCkWh7H-MuBxMMz0f4Bl-fz2f-hPuWM,52679
41
+ pangea/services/redact.py,sha256=nst-mfxI7ewkDSSVVoY9cznMgb7EY9TGCjD6ZpPGvY4,12128
42
+ pangea/services/sanitize.py,sha256=D_R_XIe9FvRCX40b8b_3gouhAGduDdxI9bT2w-kiVHU,13444
43
+ pangea/services/share/file_format.py,sha256=1svO1ee_aenA9zoO_AaU-Rk5Ulp7kcPOc_KwNoluyQE,2797
44
+ pangea/services/share/share.py,sha256=8N4zXQJjkVDf2iR62pz6xpmxlbXRPNfHgYfOuEdNaZ8,46333
42
45
  pangea/services/vault/models/asymmetric.py,sha256=vspijmEvHm5WXri_fjOWfQc4maYyZfhDkLuaTM8-PZo,4991
43
46
  pangea/services/vault/models/common.py,sha256=PSZRFqHTUtEMJJGwywEFM2AU3aV8S-sbcoo3LLQ6uTc,17981
44
47
  pangea/services/vault/models/keys.py,sha256=duAuTiOby_D7MloRvN4gNj0P-b-jx9sdtplAWFxsShw,2786
@@ -46,8 +49,8 @@ pangea/services/vault/models/secret.py,sha256=ItGdkulM-SEySfcm4a5yGxMvo_omjC7kCh
46
49
  pangea/services/vault/models/symmetric.py,sha256=t8xCM1wGGKDBpOqTggFueO4-4-2IFmyxqcs7_PDr7U0,2562
47
50
  pangea/services/vault/vault.py,sha256=ow-Zm7PYzfWIfUcA4UNnpeL2DHfZM4C7inRDmNR3zQU,76196
48
51
  pangea/tools.py,sha256=2-Y4SAHWFv6Ocj42J_bWrVy27M5G3wi7a8LJn0dabHc,6427
49
- pangea/utils.py,sha256=TmrlLjnyfQyXoLjhAWp1AGtGW1uMQ57fPgJZ5LhvTJk,3199
52
+ pangea/utils.py,sha256=dZ6MwFVEWXUgXvvDg-k6JnvVfsgslvtaBd7ez7afrqk,4983
50
53
  pangea/verify_audit.py,sha256=nSP17OzoSPdvezRExwfcf45H8ZPZnxZu-CbEp3qFJO0,17354
51
- pangea_sdk-5.0.0.dist-info/METADATA,sha256=OprGX1fUL_TfybyBl6SHQhr0Pze0Mzeuo_8TGt5qzys,7495
52
- pangea_sdk-5.0.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
53
- pangea_sdk-5.0.0.dist-info/RECORD,,
54
+ pangea_sdk-5.2.0.dist-info/METADATA,sha256=0_T3gGYHKgvjYYIsf9UgTtm5B5tWAqLx8DtPqm4ny0E,7513
55
+ pangea_sdk-5.2.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
56
+ pangea_sdk-5.2.0.dist-info/RECORD,,