protegrity-ai-developer-python 1.2.1__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.
Files changed (53) hide show
  1. appython/__init__.py +12 -0
  2. appython/protector.py +554 -0
  3. appython/service/auth_provider.py +273 -0
  4. appython/service/auth_token_provider.py +45 -0
  5. appython/service/config.py +209 -0
  6. appython/service/payload_builder.py +141 -0
  7. appython/service/request_handler.py +115 -0
  8. appython/service/response_handler.py +78 -0
  9. appython/stats/__init__.py +3 -0
  10. appython/stats/collector.py +90 -0
  11. appython/stats/writer.py +185 -0
  12. appython/utils/codec_helper.py +86 -0
  13. appython/utils/constants.py +246 -0
  14. appython/utils/exceptions.py +141 -0
  15. appython/utils/input_preprocessor.py +325 -0
  16. appython/utils/output_postprocessor.py +99 -0
  17. protegrity_ai_developer_python-1.2.1.dist-info/METADATA +428 -0
  18. protegrity_ai_developer_python-1.2.1.dist-info/RECORD +53 -0
  19. protegrity_ai_developer_python-1.2.1.dist-info/WHEEL +5 -0
  20. protegrity_ai_developer_python-1.2.1.dist-info/entry_points.txt +2 -0
  21. protegrity_ai_developer_python-1.2.1.dist-info/licenses/LICENSE +21 -0
  22. protegrity_ai_developer_python-1.2.1.dist-info/top_level.txt +3 -0
  23. protegrity_developer_python/__init__.py +4 -0
  24. protegrity_developer_python/scan.py +37 -0
  25. protegrity_developer_python/securefind.py +83 -0
  26. protegrity_developer_python/utils/ccn_processing.py +59 -0
  27. protegrity_developer_python/utils/config.py +60 -0
  28. protegrity_developer_python/utils/constants.py +123 -0
  29. protegrity_developer_python/utils/discover.py +49 -0
  30. protegrity_developer_python/utils/logger.py +23 -0
  31. protegrity_developer_python/utils/pii_processing.py +291 -0
  32. protegrity_developer_python/utils/protector.py +23 -0
  33. protegrity_developer_python/utils/semantic_guardrails.py +240 -0
  34. protegrity_developer_python/utils/transform.py +66 -0
  35. pty_migrate/__init__.py +1 -0
  36. pty_migrate/check_cmd.py +871 -0
  37. pty_migrate/cli.py +93 -0
  38. pty_migrate/config.py +127 -0
  39. pty_migrate/create_policy_cmd.py +795 -0
  40. pty_migrate/payloads/__init__.py +51 -0
  41. pty_migrate/payloads/alphabets.json +42 -0
  42. pty_migrate/payloads/dataelements.json +342 -0
  43. pty_migrate/payloads/datastores.json +7 -0
  44. pty_migrate/payloads/deploy_policy_ta.json +1 -0
  45. pty_migrate/payloads/masks.json +18 -0
  46. pty_migrate/payloads/members.json +62 -0
  47. pty_migrate/payloads/policies.json +13 -0
  48. pty_migrate/payloads/roles.json +32 -0
  49. pty_migrate/payloads/rules.json +1639 -0
  50. pty_migrate/payloads/sources.json +10 -0
  51. pty_migrate/payloads/trusted_apps.json +8 -0
  52. pty_migrate/ppc_client.py +371 -0
  53. pty_migrate/stats_cmd.py +87 -0
@@ -0,0 +1,51 @@
1
+ """Loader for bundled DE policy payload files."""
2
+
3
+ import json
4
+ from pathlib import Path
5
+
6
+ _PAYLOAD_DIR = Path(__file__).parent
7
+
8
+
9
+ def load_payload(name):
10
+ """Load a payload JSON file by resource name.
11
+
12
+ Args:
13
+ name: Resource name (e.g., 'dataelements', 'roles', 'rules').
14
+
15
+ Returns:
16
+ Parsed JSON (list or dict).
17
+ """
18
+ # Map resource names to filenames
19
+ filename_map = {
20
+ "datastores": "datastores.json",
21
+ "sources": "sources.json",
22
+ "roles": "roles.json",
23
+ "alphabets": "alphabets.json",
24
+ "masks": "masks.json",
25
+ "dataelements": "dataelements.json",
26
+ "applications": "trusted_apps.json",
27
+ "policies": "policies.json",
28
+ "rules": "rules.json",
29
+ "deploy": "deploy_policy_ta.json",
30
+ "members": "members.json",
31
+ }
32
+ filename = filename_map.get(name)
33
+ if not filename:
34
+ raise ValueError(f"Unknown payload resource: {name}")
35
+
36
+ path = _PAYLOAD_DIR / filename
37
+ with open(path, "r", encoding="utf-8") as f:
38
+ return json.load(f)
39
+
40
+
41
+ def load_all_payloads():
42
+ """Load all payload files into a dict keyed by resource name.
43
+
44
+ Returns:
45
+ dict: {resource_name: payload_data}
46
+ """
47
+ resources = [
48
+ "datastores", "sources", "roles", "alphabets", "masks",
49
+ "dataelements", "applications", "policies", "rules", "deploy", "members",
50
+ ]
51
+ return {name: load_payload(name) for name in resources}
@@ -0,0 +1,42 @@
1
+ [
2
+ {
3
+ "label": "latin_german_numeric",
4
+ "codePoints": ["00E4", "00F6", "00FC", "00C4", "00D6", "00DC", "00DF"],
5
+ "ranges": [
6
+ { "from": "0041", "to": "005A" },
7
+ { "from": "0061", "to": "007A" },
8
+ { "from": "0100", "to": "017F" },
9
+ { "from": "0180", "to": "024F" },
10
+ { "from": "0030", "to": "0039" }
11
+ ]
12
+ },
13
+ {
14
+ "label": "latin_french_numeric",
15
+ "ranges": [
16
+ { "from": "0041", "to": "005A" },
17
+ { "from": "0061", "to": "007A" },
18
+ { "from": "00C0", "to": "00FF" },
19
+ { "from": "0100", "to": "017F" },
20
+ { "from": "0030", "to": "0039" }
21
+ ]
22
+ },
23
+ {
24
+ "label": "latin_german",
25
+ "codePoints": ["00E4", "00F6", "00FC", "00C4", "00D6", "00DC", "00DF"],
26
+ "ranges": [
27
+ { "from": "0041", "to": "005A" },
28
+ { "from": "0061", "to": "007A" },
29
+ { "from": "0100", "to": "017F" },
30
+ { "from": "0180", "to": "024F" }
31
+ ]
32
+ },
33
+ {
34
+ "label": "latin_french",
35
+ "ranges": [
36
+ { "from": "0041", "to": "005A" },
37
+ { "from": "0061", "to": "007A" },
38
+ { "from": "00C0", "to": "00FF" },
39
+ { "from": "0100", "to": "017F" }
40
+ ]
41
+ }
42
+ ]
@@ -0,0 +1,342 @@
1
+ [
2
+ {
3
+ "name": "name",
4
+ "description": "Protect or unprotect name of a person",
5
+ "alphabeticToken": {
6
+ "tokenizer": "SLT_2_3",
7
+ "fromLeft": 0,
8
+ "fromRight": 0,
9
+ "lengthPreserving": true
10
+ }
11
+ },
12
+ {
13
+ "name": "name_de",
14
+ "description": "Protect or unprotect name of a person in German language",
15
+ "unicodeGen2Token": {
16
+ "tokenizer": "SLT_X_1",
17
+ "alphabetUid": "3",
18
+ "fromLeft": 0,
19
+ "fromRight": 0,
20
+ "lengthPreserving": true
21
+ }
22
+ },
23
+ {
24
+ "name": "name_fr",
25
+ "description": "Protect or unprotect name of a person in French language",
26
+ "unicodeGen2Token": {
27
+ "tokenizer": "SLT_X_1",
28
+ "alphabetUid": "4",
29
+ "fromLeft": 0,
30
+ "fromRight": 0,
31
+ "lengthPreserving": true
32
+ }
33
+ },
34
+ {
35
+ "name": "address",
36
+ "description": "Protect or unprotect an address",
37
+ "alphaNumericToken": {
38
+ "tokenizer": "SLT_2_3",
39
+ "fromLeft": 0,
40
+ "fromRight": 0,
41
+ "lengthPreserving": true
42
+ }
43
+ },
44
+ {
45
+ "name": "address_de",
46
+ "description": "Protect or unprotect an address in German language",
47
+ "unicodeGen2Token": {
48
+ "tokenizer": "SLT_X_1",
49
+ "alphabetUid": "1",
50
+ "fromLeft": 0,
51
+ "fromRight": 0,
52
+ "lengthPreserving": true
53
+ }
54
+ },
55
+ {
56
+ "name": "address_fr",
57
+ "description": "Protect or unprotect an address in French language",
58
+ "unicodeGen2Token": {
59
+ "tokenizer": "SLT_X_1",
60
+ "alphabetUid": "2",
61
+ "fromLeft": 0,
62
+ "fromRight": 0,
63
+ "lengthPreserving": true
64
+ }
65
+ },
66
+ {
67
+ "name": "city",
68
+ "description": "Protect or unprotect a town or city",
69
+ "alphabeticToken": {
70
+ "tokenizer": "SLT_2_3",
71
+ "fromLeft": 0,
72
+ "fromRight": 0,
73
+ "lengthPreserving": true
74
+ }
75
+ },
76
+ {
77
+ "name": "city_de",
78
+ "description": "Protect or unprotect a town or city name in German language",
79
+ "unicodeGen2Token": {
80
+ "tokenizer": "SLT_X_1",
81
+ "alphabetUid": "3",
82
+ "fromLeft": 0,
83
+ "fromRight": 0,
84
+ "lengthPreserving": true
85
+ }
86
+ },
87
+ {
88
+ "name": "city_fr",
89
+ "description": "Protect or unprotect a town or city name in French language",
90
+ "unicodeGen2Token": {
91
+ "tokenizer": "SLT_X_1",
92
+ "alphabetUid": "4",
93
+ "fromLeft": 0,
94
+ "fromRight": 0,
95
+ "lengthPreserving": true
96
+ }
97
+ },
98
+ {
99
+ "name": "postcode",
100
+ "description": "Protect or unprotect a postal code with digits and chatacters",
101
+ "alphaNumericToken": {
102
+ "tokenizer": "SLT_2_3",
103
+ "fromLeft": 0,
104
+ "fromRight": 0,
105
+ "lengthPreserving": true,
106
+ "preservePosition": true,
107
+ "preserveCase": true
108
+ }
109
+ },
110
+ {
111
+ "name": "zipcode",
112
+ "description": "Protect or unprotect a postal code with digits only",
113
+ "numericToken": {
114
+ "tokenizer": "SLT_2_6",
115
+ "fromLeft": 0,
116
+ "fromRight": 0,
117
+ "lengthPreserving": true
118
+ }
119
+ },
120
+ {
121
+ "name": "phone",
122
+ "description": "Protect or unprotect a phone number",
123
+ "numericToken": {
124
+ "tokenizer": "SLT_2_6",
125
+ "fromLeft": 0,
126
+ "fromRight": 0,
127
+ "lengthPreserving": true
128
+ }
129
+ },
130
+ {
131
+ "name": "email",
132
+ "description": "Protect or unprotect an email",
133
+ "emailToken": {
134
+ "tokenizer": "SLT_2_3",
135
+ "lengthPreserving": true
136
+ }
137
+ },
138
+ {
139
+ "name": "datetime",
140
+ "description": "Protect or unprotect all components of a datetime string date, month, year and time",
141
+ "dateTimeToken": {
142
+ "tokenizer": "SLT_8_DATETIME"
143
+ }
144
+ },
145
+ {
146
+ "name": "datetime_yc",
147
+ "description": "Protect or unprotect a datetime string. Year will be in clear.",
148
+ "dateTimeToken": {
149
+ "tokenizer": "SLT_8_DATETIME",
150
+ "dateInClear": "YEAR"
151
+ }
152
+ },
153
+ {
154
+ "name": "int",
155
+ "description": "Protect or unprotect a 4-byte integer string",
156
+ "integerToken": {
157
+ "tokenizer": "SLT_1_3"
158
+ }
159
+ },
160
+ {
161
+ "name": "nin",
162
+ "description": "Protect or unprotect a National Insurance Number UK",
163
+ "alphaNumericToken": {
164
+ "tokenizer": "SLT_2_3",
165
+ "fromLeft": 0,
166
+ "fromRight": 0,
167
+ "lengthPreserving": true,
168
+ "preservePosition": true,
169
+ "preserveCase": true
170
+ }
171
+ },
172
+ {
173
+ "name": "ssn",
174
+ "description": "Protect or unprotect a Social Security Number US",
175
+ "numericToken": {
176
+ "tokenizer": "SLT_2_6",
177
+ "fromLeft": 0,
178
+ "fromRight": 0,
179
+ "lengthPreserving": true
180
+ }
181
+ },
182
+ {
183
+ "name": "ccn",
184
+ "description": "Protect or unprotect a Credit Card Number",
185
+ "creditCardToken": {
186
+ "tokenizer": "SLT_2_6",
187
+ "fromLeft": 0,
188
+ "fromRight": 0
189
+ }
190
+ },
191
+ {
192
+ "name": "ccn_bin",
193
+ "description": "Protect or unprotect a Credit Card Number. Leaves 8-digit BIN in the clear.",
194
+ "creditCardToken": {
195
+ "tokenizer": "SLT_2_6",
196
+ "fromLeft": 8,
197
+ "fromRight": 0
198
+ }
199
+ },
200
+ {
201
+ "name": "passport",
202
+ "description": "Protect or unprotect a passport number",
203
+ "alphaNumericToken": {
204
+ "tokenizer": "SLT_2_3",
205
+ "fromLeft": 0,
206
+ "fromRight": 0,
207
+ "lengthPreserving": true,
208
+ "preservePosition": true,
209
+ "preserveCase": true
210
+ }
211
+ },
212
+ {
213
+ "name": "iban",
214
+ "description": "Protect or unprotect an Internation Banking Account Number",
215
+ "alphaNumericToken": {
216
+ "tokenizer": "SLT_2_3",
217
+ "fromLeft": 0,
218
+ "fromRight": 0,
219
+ "lengthPreserving": true,
220
+ "preservePosition": true,
221
+ "preserveCase": true
222
+ }
223
+ },
224
+ {
225
+ "name": "iban_cc",
226
+ "description": "Protect or unprotect an Internation Banking Account Number. Leaves letters in the clear.",
227
+ "numericToken": {
228
+ "tokenizer": "SLT_2_6",
229
+ "fromLeft": 0,
230
+ "fromRight": 0,
231
+ "lengthPreserving": true
232
+ }
233
+ },
234
+ {
235
+ "name": "string",
236
+ "description": "Protect or unprotect a string",
237
+ "alphaNumericToken": {
238
+ "tokenizer": "SLT_2_3",
239
+ "fromLeft": 0,
240
+ "fromRight": 0,
241
+ "lengthPreserving": true
242
+ }
243
+ },
244
+ {
245
+ "name": "number",
246
+ "description": "Protect or unprotect a number",
247
+ "numericToken": {
248
+ "tokenizer": "SLT_2_6",
249
+ "fromLeft": 0,
250
+ "fromRight": 0,
251
+ "lengthPreserving": true
252
+ }
253
+ },
254
+ {
255
+ "name": "text",
256
+ "description": "Protect or unprotect text using encryption",
257
+ "aes256CbcEnc": {}
258
+ },
259
+ {
260
+ "name": "fpe_numeric",
261
+ "description": "FPE for numeric data",
262
+ "numericFpe": {
263
+ "fromLeft": 0,
264
+ "fromRight": 0,
265
+ "allowShort": "NOWITHERROR",
266
+ "minLength": 2,
267
+ "tweakMode": "EXT_INPUT"
268
+ }
269
+ },
270
+ {
271
+ "name": "fpe_alpha",
272
+ "description": "FPE using Alpha as plaintext alphabet",
273
+ "alphabeticFpe": {
274
+ "fromLeft": 0,
275
+ "fromRight": 0,
276
+ "allowShort": "NOWITHERROR",
277
+ "minLength": 2,
278
+ "tweakMode": "EXT_INPUT"
279
+ }
280
+ },
281
+ {
282
+ "name": "fpe_alphanumeric",
283
+ "description": "FPE using Alphanumeric as plaintext alphabet",
284
+ "alphaNumericFpe": {
285
+ "fromLeft": 0,
286
+ "fromRight": 0,
287
+ "allowShort": "NOWITHERROR",
288
+ "minLength": 2,
289
+ "tweakMode": "EXT_INPUT"
290
+ }
291
+ },
292
+ {
293
+ "name": "fpe_latin1_alpha",
294
+ "description": "FPE using Basic Latin and Latin-1 Supplement Alpha",
295
+ "unicodeBasicLatinAlphabeticFpe": {
296
+ "fromLeft": 0,
297
+ "fromRight": 0,
298
+ "allowShort": "NOWITHERROR",
299
+ "minLength": 2,
300
+ "tweakMode": "EXT_INPUT"
301
+ }
302
+ },
303
+ {
304
+ "name": "fpe_latin1_alphanumeric",
305
+ "description": "FPE using Basic Latin and Latin-1 Supplement Alphanumeric",
306
+ "unicodeBasicLatinAlphaNumericFpe": {
307
+ "fromLeft": 0,
308
+ "fromRight": 0,
309
+ "allowShort": "NOWITHERROR",
310
+ "minLength": 2,
311
+ "tweakMode": "EXT_INPUT"
312
+ }
313
+ },
314
+ {
315
+ "name": "mask",
316
+ "description": "Mask all the characters",
317
+ "noEnc": {
318
+ "maskUid": "1"
319
+ }
320
+ },
321
+ {
322
+ "name": "no_encryption",
323
+ "description": "No encryption data element",
324
+ "noEnc": {}
325
+ },
326
+ {
327
+ "name": "short",
328
+ "description": "Protect or unprotect a 2-byte integer string",
329
+ "integerToken": {
330
+ "tokenizer": "SLT_1_3",
331
+ "integerSize": "SHORT"
332
+ }
333
+ },
334
+ {
335
+ "name": "long",
336
+ "description": "Protect or unprotect an 8-byte integer string",
337
+ "integerToken": {
338
+ "tokenizer": "SLT_1_3",
339
+ "integerSize": "LONG"
340
+ }
341
+ }
342
+ ]
@@ -0,0 +1,7 @@
1
+ [
2
+ {
3
+ "name": "DevEdition",
4
+ "description": "Datastore for Protegrity Developer Edition.",
5
+ "default": true
6
+ }
7
+ ]
@@ -0,0 +1 @@
1
+ [{ "policies": ["1"], "applications": ["1"] }]
@@ -0,0 +1,18 @@
1
+ [
2
+ {
3
+ "name": "mask",
4
+ "description": "mask character",
5
+ "fromLeft": 0,
6
+ "fromRight": 0,
7
+ "masked": false,
8
+ "character": "*"
9
+ },
10
+ {
11
+ "name": "mask_ccn",
12
+ "description": "Mask CCN data",
13
+ "fromLeft": 4,
14
+ "fromRight": 4,
15
+ "masked": false,
16
+ "character": "*"
17
+ }
18
+ ]
@@ -0,0 +1,62 @@
1
+ {
2
+ "roles/1/members": [
3
+ {
4
+ "name": "superuser",
5
+ "source": "1",
6
+ "type": "USER"
7
+ }
8
+ ],
9
+ "roles/2/members": [
10
+ {
11
+ "name": "admin",
12
+ "source": "1",
13
+ "type": "USER"
14
+ },
15
+ {
16
+ "name": "devops",
17
+ "source": "1",
18
+ "type": "USER"
19
+ },
20
+ {
21
+ "name": "jay.banerjee",
22
+ "source": "1",
23
+ "type": "USER"
24
+ }
25
+ ],
26
+ "roles/3/members": [
27
+ {
28
+ "name": "finance",
29
+ "source": "1",
30
+ "type": "USER"
31
+ },
32
+ {
33
+ "name": "robin.goodwill",
34
+ "source": "1",
35
+ "type": "USER"
36
+ }
37
+ ],
38
+ "roles/4/members": [
39
+ {
40
+ "name": "marketing",
41
+ "source": "1",
42
+ "type": "USER"
43
+ },
44
+ {
45
+ "name": "merlin.ishida",
46
+ "source": "1",
47
+ "type": "USER"
48
+ }
49
+ ],
50
+ "roles/5/members": [
51
+ {
52
+ "name": "hr",
53
+ "source": "1",
54
+ "type": "USER"
55
+ },
56
+ {
57
+ "name": "paloma.torres",
58
+ "source": "1",
59
+ "type": "USER"
60
+ }
61
+ ]
62
+ }
@@ -0,0 +1,13 @@
1
+ [
2
+ {
3
+ "name": "DevEditionPolicy",
4
+ "description": "Policy for Protegrity Developer Edition.",
5
+ "template": {
6
+ "access": {
7
+ "protect": false,
8
+ "reProtect": false,
9
+ "unProtect": false
10
+ }
11
+ }
12
+ }
13
+ ]
@@ -0,0 +1,32 @@
1
+ [
2
+ {
3
+ "name": "Superuser",
4
+ "description": "The role can perform any protect and unprotect operation. The role has been made available for testing only. We strongly advise against creating superuser roles in your environments.",
5
+ "mode": "MANUAL",
6
+ "allowAll": false
7
+ },
8
+ {
9
+ "name": "Admin",
10
+ "description": "The role can protect all data but cannot unprotect. Upon an unprotection attempt, protected values will be displayed.",
11
+ "mode": "MANUAL",
12
+ "allowAll": false
13
+ },
14
+ {
15
+ "name": "Finance",
16
+ "description": "The role can unprotect all PII and PCI data. The role cannot protect any data. When attempting to unprotect data without authorization, null value will be displayed.",
17
+ "mode": "MANUAL",
18
+ "allowAll": false
19
+ },
20
+ {
21
+ "name": "Marketing",
22
+ "description": "The role can unprotect some PII data that is required for analytical research and campaign outreach. When attempting to unprotect data without authorization, null value will be displayed. The role cannot protect any data.",
23
+ "mode": "MANUAL",
24
+ "allowAll": false
25
+ },
26
+ {
27
+ "name": "HR",
28
+ "description": "The role can unprotect all PII data but cannot view any PCI data. When attempting to unprotect data without authorization, null value will be displayed. The role cannot protect any data.",
29
+ "mode": "MANUAL",
30
+ "allowAll": false
31
+ }
32
+ ]