@link-foundation/sensitive-data-sanitizer 0.18.0 → 0.19.0
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.
- package/CHANGELOG.md +6 -0
- package/README.md +8 -0
- package/docs/API.md +205 -33
- package/docs/COVERAGE.md +84 -8
- package/docs/RULES.md +403 -0
- package/examples/custom-log-policy.mjs +23 -0
- package/package.json +17 -2
- package/src/compiled-known.js +55 -0
- package/src/detection.js +9 -0
- package/src/document-catalog.js +246 -0
- package/src/document-entities.js +8 -2
- package/src/document-experience.js +9 -4
- package/src/document-extras.js +2 -2
- package/src/document-vocabulary.js +80 -68
- package/src/engines.js +81 -34
- package/src/index.d.ts +52 -4
- package/src/index.js +5 -0
- package/src/jsonl-stream.js +2 -5
- package/src/ner.d.ts +5 -0
- package/src/ner.js +96 -0
- package/src/personal-variants.js +29 -8
- package/src/policy.js +107 -0
- package/src/record-worker.js +6 -0
- package/src/rule-catalog.js +669 -0
- package/src/sanitizer.js +99 -19
- package/src/stream-worker.js +5 -0
- package/src/stream.js +11 -6
- package/src/strict.js +66 -0
- package/src/structured.js +111 -47
- package/src/sync-detectors.js +38 -0
- package/src/sync-sanitizer.js +16 -0
- package/src/transforms.js +85 -7
- package/src/vocabulary.js +217 -0
- package/src/worker-options.js +12 -0
package/docs/RULES.md
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
# Stable finding rule identifiers
|
|
2
|
+
|
|
3
|
+
Use keys from the exported frozen `builtInRules` list in `rules: {id: false}`.
|
|
4
|
+
Unknown ids fail with ERR_CONFIG. Credential and mixed encoded/scanner rules
|
|
5
|
+
require `allowCredentialDisable: true`. A disabled rule does not suppress
|
|
6
|
+
another rule's overlapping finding. Rules gate automatic built-in findings;
|
|
7
|
+
explicit findings and custom callbacks retain caller policy. See [API](API.md#rule-type-and-field-policy).
|
|
8
|
+
|
|
9
|
+
Regenerate with `node experiments/issue-118/generate-rule-catalog.mjs`.
|
|
10
|
+
|
|
11
|
+
- `age-context`
|
|
12
|
+
- `anthropic`
|
|
13
|
+
- `authorization`
|
|
14
|
+
- `aws`
|
|
15
|
+
- `birth-context`
|
|
16
|
+
- `birth-year`
|
|
17
|
+
- `booking-context`
|
|
18
|
+
- `booking-filename`
|
|
19
|
+
- `catalog/aws`
|
|
20
|
+
- `catalog/azure`
|
|
21
|
+
- `catalog/google`
|
|
22
|
+
- `cli-password`
|
|
23
|
+
- `context`
|
|
24
|
+
- `cookie`
|
|
25
|
+
- `databricks`
|
|
26
|
+
- `detect-secrets`
|
|
27
|
+
- `digitalocean`
|
|
28
|
+
- `discord`
|
|
29
|
+
- `document-age-unit`
|
|
30
|
+
- `document-at-employer`
|
|
31
|
+
- `document-bank-suffix`
|
|
32
|
+
- `document-birthday`
|
|
33
|
+
- `document-citizenship`
|
|
34
|
+
- `document-email-obfuscation`
|
|
35
|
+
- `document-email-spaces`
|
|
36
|
+
- `document-employer-dash`
|
|
37
|
+
- `document-employer-prefix`
|
|
38
|
+
- `document-industry`
|
|
39
|
+
- `document-introduction`
|
|
40
|
+
- `document-legal-lowercase`
|
|
41
|
+
- `document-local-phone`
|
|
42
|
+
- `document-messenger`
|
|
43
|
+
- `document-military-id`
|
|
44
|
+
- `document-mixed-name`
|
|
45
|
+
- `document-mobile-bare`
|
|
46
|
+
- `document-mobile-comma`
|
|
47
|
+
- `document-mobile-context`
|
|
48
|
+
- `document-msu`
|
|
49
|
+
- `document-patronymic`
|
|
50
|
+
- `document-personal-path`
|
|
51
|
+
- `document-phone`
|
|
52
|
+
- `document-phone-label`
|
|
53
|
+
- `document-propagation`
|
|
54
|
+
- `document-region`
|
|
55
|
+
- `document-resume-link`
|
|
56
|
+
- `document-reversed-role`
|
|
57
|
+
- `document-role`
|
|
58
|
+
- `document-role-employer`
|
|
59
|
+
- `document-school-context`
|
|
60
|
+
- `document-school-year`
|
|
61
|
+
- `document-share-link`
|
|
62
|
+
- `document-share-path`
|
|
63
|
+
- `document-social-link`
|
|
64
|
+
- `document-spaced-mobile`
|
|
65
|
+
- `document-street`
|
|
66
|
+
- `document-street-complete`
|
|
67
|
+
- `document-unfamiliar-name`
|
|
68
|
+
- `document-uppercase-initials`
|
|
69
|
+
- `document-vehicle-plate`
|
|
70
|
+
- `document-vin`
|
|
71
|
+
- `education-acronym`
|
|
72
|
+
- `education-bracket`
|
|
73
|
+
- `education-label`
|
|
74
|
+
- `education-named-acronym`
|
|
75
|
+
- `education-russian`
|
|
76
|
+
- `education-training`
|
|
77
|
+
- `education-type`
|
|
78
|
+
- `email`
|
|
79
|
+
- `employer-label`
|
|
80
|
+
- `employer-prose`
|
|
81
|
+
- `employer-years`
|
|
82
|
+
- `encoded`
|
|
83
|
+
- `encoded-engine`
|
|
84
|
+
- `encoded-limit`
|
|
85
|
+
- `entity-format`
|
|
86
|
+
- `entropy`
|
|
87
|
+
- `firebase`
|
|
88
|
+
- `gender-context`
|
|
89
|
+
- `github`
|
|
90
|
+
- `gitlab`
|
|
91
|
+
- `gitlab-runner`
|
|
92
|
+
- `gitleaks/1password-secret-key`
|
|
93
|
+
- `gitleaks/1password-service-account-token`
|
|
94
|
+
- `gitleaks/adafruit-api-key`
|
|
95
|
+
- `gitleaks/adobe-client-id`
|
|
96
|
+
- `gitleaks/adobe-client-secret`
|
|
97
|
+
- `gitleaks/age-secret-key`
|
|
98
|
+
- `gitleaks/airtable-api-key`
|
|
99
|
+
- `gitleaks/airtable-personnal-access-token`
|
|
100
|
+
- `gitleaks/algolia-api-key`
|
|
101
|
+
- `gitleaks/alibaba-access-key-id`
|
|
102
|
+
- `gitleaks/alibaba-secret-key`
|
|
103
|
+
- `gitleaks/anthropic-admin-api-key`
|
|
104
|
+
- `gitleaks/anthropic-api-key`
|
|
105
|
+
- `gitleaks/artifactory-api-key`
|
|
106
|
+
- `gitleaks/artifactory-reference-token`
|
|
107
|
+
- `gitleaks/asana-client-id`
|
|
108
|
+
- `gitleaks/asana-client-secret`
|
|
109
|
+
- `gitleaks/atlassian-api-token`
|
|
110
|
+
- `gitleaks/authress-service-client-access-key`
|
|
111
|
+
- `gitleaks/aws-access-token`
|
|
112
|
+
- `gitleaks/aws-amazon-bedrock-api-key-long-lived`
|
|
113
|
+
- `gitleaks/aws-amazon-bedrock-api-key-short-lived`
|
|
114
|
+
- `gitleaks/azure-ad-client-secret`
|
|
115
|
+
- `gitleaks/beamer-api-token`
|
|
116
|
+
- `gitleaks/bitbucket-client-id`
|
|
117
|
+
- `gitleaks/bitbucket-client-secret`
|
|
118
|
+
- `gitleaks/bittrex-access-key`
|
|
119
|
+
- `gitleaks/bittrex-secret-key`
|
|
120
|
+
- `gitleaks/cisco-meraki-api-key`
|
|
121
|
+
- `gitleaks/clickhouse-cloud-api-secret-key`
|
|
122
|
+
- `gitleaks/clojars-api-token`
|
|
123
|
+
- `gitleaks/cloudflare-api-key`
|
|
124
|
+
- `gitleaks/cloudflare-global-api-key`
|
|
125
|
+
- `gitleaks/cloudflare-origin-ca-key`
|
|
126
|
+
- `gitleaks/codecov-access-token`
|
|
127
|
+
- `gitleaks/cohere-api-token`
|
|
128
|
+
- `gitleaks/coinbase-access-token`
|
|
129
|
+
- `gitleaks/confluent-access-token`
|
|
130
|
+
- `gitleaks/confluent-secret-key`
|
|
131
|
+
- `gitleaks/contentful-delivery-api-token`
|
|
132
|
+
- `gitleaks/curl-auth-header`
|
|
133
|
+
- `gitleaks/curl-auth-user`
|
|
134
|
+
- `gitleaks/databricks-api-token`
|
|
135
|
+
- `gitleaks/datadog-access-token`
|
|
136
|
+
- `gitleaks/defined-networking-api-token`
|
|
137
|
+
- `gitleaks/digitalocean-access-token`
|
|
138
|
+
- `gitleaks/digitalocean-pat`
|
|
139
|
+
- `gitleaks/digitalocean-refresh-token`
|
|
140
|
+
- `gitleaks/discord-api-token`
|
|
141
|
+
- `gitleaks/discord-client-id`
|
|
142
|
+
- `gitleaks/discord-client-secret`
|
|
143
|
+
- `gitleaks/doppler-api-token`
|
|
144
|
+
- `gitleaks/droneci-access-token`
|
|
145
|
+
- `gitleaks/dropbox-api-token`
|
|
146
|
+
- `gitleaks/dropbox-long-lived-api-token`
|
|
147
|
+
- `gitleaks/dropbox-short-lived-api-token`
|
|
148
|
+
- `gitleaks/duffel-api-token`
|
|
149
|
+
- `gitleaks/dynatrace-api-token`
|
|
150
|
+
- `gitleaks/easypost-api-token`
|
|
151
|
+
- `gitleaks/easypost-test-api-token`
|
|
152
|
+
- `gitleaks/etsy-access-token`
|
|
153
|
+
- `gitleaks/facebook-access-token`
|
|
154
|
+
- `gitleaks/facebook-page-access-token`
|
|
155
|
+
- `gitleaks/facebook-secret`
|
|
156
|
+
- `gitleaks/fastly-api-token`
|
|
157
|
+
- `gitleaks/finicity-api-token`
|
|
158
|
+
- `gitleaks/finicity-client-secret`
|
|
159
|
+
- `gitleaks/finnhub-access-token`
|
|
160
|
+
- `gitleaks/flickr-access-token`
|
|
161
|
+
- `gitleaks/flutterwave-encryption-key`
|
|
162
|
+
- `gitleaks/flutterwave-public-key`
|
|
163
|
+
- `gitleaks/flutterwave-secret-key`
|
|
164
|
+
- `gitleaks/flyio-access-token`
|
|
165
|
+
- `gitleaks/frameio-api-token`
|
|
166
|
+
- `gitleaks/freemius-secret-key`
|
|
167
|
+
- `gitleaks/freshbooks-access-token`
|
|
168
|
+
- `gitleaks/gcp-api-key`
|
|
169
|
+
- `gitleaks/generic-api-key`
|
|
170
|
+
- `gitleaks/github-app-token`
|
|
171
|
+
- `gitleaks/github-fine-grained-pat`
|
|
172
|
+
- `gitleaks/github-oauth`
|
|
173
|
+
- `gitleaks/github-pat`
|
|
174
|
+
- `gitleaks/github-refresh-token`
|
|
175
|
+
- `gitleaks/gitlab-cicd-job-token`
|
|
176
|
+
- `gitleaks/gitlab-deploy-token`
|
|
177
|
+
- `gitleaks/gitlab-feature-flag-client-token`
|
|
178
|
+
- `gitleaks/gitlab-feed-token`
|
|
179
|
+
- `gitleaks/gitlab-incoming-mail-token`
|
|
180
|
+
- `gitleaks/gitlab-kubernetes-agent-token`
|
|
181
|
+
- `gitleaks/gitlab-oauth-app-secret`
|
|
182
|
+
- `gitleaks/gitlab-pat`
|
|
183
|
+
- `gitleaks/gitlab-pat-routable`
|
|
184
|
+
- `gitleaks/gitlab-ptt`
|
|
185
|
+
- `gitleaks/gitlab-rrt`
|
|
186
|
+
- `gitleaks/gitlab-runner-authentication-token`
|
|
187
|
+
- `gitleaks/gitlab-runner-authentication-token-routable`
|
|
188
|
+
- `gitleaks/gitlab-scim-token`
|
|
189
|
+
- `gitleaks/gitlab-session-cookie`
|
|
190
|
+
- `gitleaks/gitter-access-token`
|
|
191
|
+
- `gitleaks/gocardless-api-token`
|
|
192
|
+
- `gitleaks/grafana-api-key`
|
|
193
|
+
- `gitleaks/grafana-cloud-api-token`
|
|
194
|
+
- `gitleaks/grafana-service-account-token`
|
|
195
|
+
- `gitleaks/harness-api-key`
|
|
196
|
+
- `gitleaks/hashicorp-tf-api-token`
|
|
197
|
+
- `gitleaks/hashicorp-tf-password`
|
|
198
|
+
- `gitleaks/heroku-api-key`
|
|
199
|
+
- `gitleaks/heroku-api-key-v2`
|
|
200
|
+
- `gitleaks/hubspot-api-key`
|
|
201
|
+
- `gitleaks/huggingface-access-token`
|
|
202
|
+
- `gitleaks/huggingface-organization-api-token`
|
|
203
|
+
- `gitleaks/infracost-api-token`
|
|
204
|
+
- `gitleaks/intercom-api-key`
|
|
205
|
+
- `gitleaks/intra42-client-secret`
|
|
206
|
+
- `gitleaks/jfrog-api-key`
|
|
207
|
+
- `gitleaks/jfrog-identity-token`
|
|
208
|
+
- `gitleaks/jwt`
|
|
209
|
+
- `gitleaks/jwt-base64`
|
|
210
|
+
- `gitleaks/kraken-access-token`
|
|
211
|
+
- `gitleaks/kubernetes-secret-yaml`
|
|
212
|
+
- `gitleaks/kucoin-access-token`
|
|
213
|
+
- `gitleaks/kucoin-secret-key`
|
|
214
|
+
- `gitleaks/launchdarkly-access-token`
|
|
215
|
+
- `gitleaks/linear-api-key`
|
|
216
|
+
- `gitleaks/linear-client-secret`
|
|
217
|
+
- `gitleaks/linkedin-client-id`
|
|
218
|
+
- `gitleaks/linkedin-client-secret`
|
|
219
|
+
- `gitleaks/lob-api-key`
|
|
220
|
+
- `gitleaks/lob-pub-api-key`
|
|
221
|
+
- `gitleaks/looker-client-id`
|
|
222
|
+
- `gitleaks/looker-client-secret`
|
|
223
|
+
- `gitleaks/mailchimp-api-key`
|
|
224
|
+
- `gitleaks/mailgun-private-api-token`
|
|
225
|
+
- `gitleaks/mailgun-pub-key`
|
|
226
|
+
- `gitleaks/mailgun-signing-key`
|
|
227
|
+
- `gitleaks/mapbox-api-token`
|
|
228
|
+
- `gitleaks/mattermost-access-token`
|
|
229
|
+
- `gitleaks/maxmind-license-key`
|
|
230
|
+
- `gitleaks/messagebird-api-token`
|
|
231
|
+
- `gitleaks/messagebird-client-id`
|
|
232
|
+
- `gitleaks/microsoft-teams-webhook`
|
|
233
|
+
- `gitleaks/netlify-access-token`
|
|
234
|
+
- `gitleaks/new-relic-browser-api-token`
|
|
235
|
+
- `gitleaks/new-relic-insert-key`
|
|
236
|
+
- `gitleaks/new-relic-user-api-id`
|
|
237
|
+
- `gitleaks/new-relic-user-api-key`
|
|
238
|
+
- `gitleaks/notion-api-token`
|
|
239
|
+
- `gitleaks/npm-access-token`
|
|
240
|
+
- `gitleaks/nuget-config-password`
|
|
241
|
+
- `gitleaks/nytimes-access-token`
|
|
242
|
+
- `gitleaks/octopus-deploy-api-key`
|
|
243
|
+
- `gitleaks/okta-access-token`
|
|
244
|
+
- `gitleaks/openai-api-key`
|
|
245
|
+
- `gitleaks/openshift-user-token`
|
|
246
|
+
- `gitleaks/perplexity-api-key`
|
|
247
|
+
- `gitleaks/pkcs12-file`
|
|
248
|
+
- `gitleaks/plaid-api-token`
|
|
249
|
+
- `gitleaks/plaid-client-id`
|
|
250
|
+
- `gitleaks/plaid-secret-key`
|
|
251
|
+
- `gitleaks/planetscale-api-token`
|
|
252
|
+
- `gitleaks/planetscale-oauth-token`
|
|
253
|
+
- `gitleaks/planetscale-password`
|
|
254
|
+
- `gitleaks/postman-api-token`
|
|
255
|
+
- `gitleaks/prefect-api-token`
|
|
256
|
+
- `gitleaks/private-key`
|
|
257
|
+
- `gitleaks/privateai-api-token`
|
|
258
|
+
- `gitleaks/pulumi-api-token`
|
|
259
|
+
- `gitleaks/pypi-upload-token`
|
|
260
|
+
- `gitleaks/rapidapi-access-token`
|
|
261
|
+
- `gitleaks/readme-api-token`
|
|
262
|
+
- `gitleaks/rubygems-api-token`
|
|
263
|
+
- `gitleaks/scalingo-api-token`
|
|
264
|
+
- `gitleaks/sendbird-access-id`
|
|
265
|
+
- `gitleaks/sendbird-access-token`
|
|
266
|
+
- `gitleaks/sendgrid-api-token`
|
|
267
|
+
- `gitleaks/sendinblue-api-token`
|
|
268
|
+
- `gitleaks/sentry-access-token`
|
|
269
|
+
- `gitleaks/sentry-org-token`
|
|
270
|
+
- `gitleaks/sentry-user-token`
|
|
271
|
+
- `gitleaks/settlemint-application-access-token`
|
|
272
|
+
- `gitleaks/settlemint-personal-access-token`
|
|
273
|
+
- `gitleaks/settlemint-service-access-token`
|
|
274
|
+
- `gitleaks/shippo-api-token`
|
|
275
|
+
- `gitleaks/shopify-access-token`
|
|
276
|
+
- `gitleaks/shopify-custom-access-token`
|
|
277
|
+
- `gitleaks/shopify-private-app-access-token`
|
|
278
|
+
- `gitleaks/shopify-shared-secret`
|
|
279
|
+
- `gitleaks/sidekiq-secret`
|
|
280
|
+
- `gitleaks/sidekiq-sensitive-url`
|
|
281
|
+
- `gitleaks/slack-app-token`
|
|
282
|
+
- `gitleaks/slack-bot-token`
|
|
283
|
+
- `gitleaks/slack-config-access-token`
|
|
284
|
+
- `gitleaks/slack-config-refresh-token`
|
|
285
|
+
- `gitleaks/slack-legacy-bot-token`
|
|
286
|
+
- `gitleaks/slack-legacy-token`
|
|
287
|
+
- `gitleaks/slack-legacy-workspace-token`
|
|
288
|
+
- `gitleaks/slack-user-token`
|
|
289
|
+
- `gitleaks/slack-webhook-url`
|
|
290
|
+
- `gitleaks/snyk-api-token`
|
|
291
|
+
- `gitleaks/sonar-api-token`
|
|
292
|
+
- `gitleaks/sourcegraph-access-token`
|
|
293
|
+
- `gitleaks/square-access-token`
|
|
294
|
+
- `gitleaks/squarespace-access-token`
|
|
295
|
+
- `gitleaks/stripe-access-token`
|
|
296
|
+
- `gitleaks/sumologic-access-id`
|
|
297
|
+
- `gitleaks/sumologic-access-token`
|
|
298
|
+
- `gitleaks/telegram-bot-api-token`
|
|
299
|
+
- `gitleaks/travisci-access-token`
|
|
300
|
+
- `gitleaks/twilio-api-key`
|
|
301
|
+
- `gitleaks/twitch-api-token`
|
|
302
|
+
- `gitleaks/twitter-access-secret`
|
|
303
|
+
- `gitleaks/twitter-access-token`
|
|
304
|
+
- `gitleaks/twitter-api-key`
|
|
305
|
+
- `gitleaks/twitter-api-secret`
|
|
306
|
+
- `gitleaks/twitter-bearer-token`
|
|
307
|
+
- `gitleaks/typeform-api-token`
|
|
308
|
+
- `gitleaks/vault-batch-token`
|
|
309
|
+
- `gitleaks/vault-service-token`
|
|
310
|
+
- `gitleaks/yandex-access-token`
|
|
311
|
+
- `gitleaks/yandex-api-key`
|
|
312
|
+
- `gitleaks/yandex-aws-access-token`
|
|
313
|
+
- `gitleaks/zendesk-secret-key`
|
|
314
|
+
- `google`
|
|
315
|
+
- `grafana`
|
|
316
|
+
- `home-path`
|
|
317
|
+
- `huggingface`
|
|
318
|
+
- `iban-checksum`
|
|
319
|
+
- `identity-number`
|
|
320
|
+
- `international-phone`
|
|
321
|
+
- `ipv4`
|
|
322
|
+
- `ipv6`
|
|
323
|
+
- `jwt`
|
|
324
|
+
- `known-personal`
|
|
325
|
+
- `known-secret`
|
|
326
|
+
- `label`
|
|
327
|
+
- `linear`
|
|
328
|
+
- `location-gazetteer`
|
|
329
|
+
- `location-label`
|
|
330
|
+
- `location-residence`
|
|
331
|
+
- `luhn`
|
|
332
|
+
- `mac`
|
|
333
|
+
- `mailchimp`
|
|
334
|
+
- `messenger-handle`
|
|
335
|
+
- `messenger-label`
|
|
336
|
+
- `mrz`
|
|
337
|
+
- `name-case`
|
|
338
|
+
- `name-document`
|
|
339
|
+
- `name-gazetteer`
|
|
340
|
+
- `name-identity`
|
|
341
|
+
- `name-initials`
|
|
342
|
+
- `name-title`
|
|
343
|
+
- `name-variant`
|
|
344
|
+
- `national-format`
|
|
345
|
+
- `national-phone`
|
|
346
|
+
- `ner/offline`
|
|
347
|
+
- `netrc`
|
|
348
|
+
- `notion`
|
|
349
|
+
- `npm`
|
|
350
|
+
- `nuget`
|
|
351
|
+
- `numbered-school`
|
|
352
|
+
- `obfuscated-email`
|
|
353
|
+
- `openai`
|
|
354
|
+
- `organization-context`
|
|
355
|
+
- `organization-continuation`
|
|
356
|
+
- `organization-core`
|
|
357
|
+
- `organization-cue`
|
|
358
|
+
- `organization-duration`
|
|
359
|
+
- `organization-experience`
|
|
360
|
+
- `organization-experience-prose`
|
|
361
|
+
- `organization-group`
|
|
362
|
+
- `organization-group-cue`
|
|
363
|
+
- `organization-legal-form`
|
|
364
|
+
- `passport-format`
|
|
365
|
+
- `passport-issuer`
|
|
366
|
+
- `passport-series`
|
|
367
|
+
- `personal-profile-url`
|
|
368
|
+
- `phone-context`
|
|
369
|
+
- `postal-address`
|
|
370
|
+
- `postal-code`
|
|
371
|
+
- `presidio`
|
|
372
|
+
- `private-key`
|
|
373
|
+
- `profile-attribute`
|
|
374
|
+
- `profile-prose`
|
|
375
|
+
- `proper-name-prose`
|
|
376
|
+
- `putty-private-key`
|
|
377
|
+
- `pypi`
|
|
378
|
+
- `quoted-entropy`
|
|
379
|
+
- `residence-prose`
|
|
380
|
+
- `school-acronym-context`
|
|
381
|
+
- `secretlint`
|
|
382
|
+
- `sendgrid`
|
|
383
|
+
- `shopify`
|
|
384
|
+
- `slack`
|
|
385
|
+
- `square`
|
|
386
|
+
- `strict-age`
|
|
387
|
+
- `strict-attribute`
|
|
388
|
+
- `strict-date`
|
|
389
|
+
- `strict-number`
|
|
390
|
+
- `stripe`
|
|
391
|
+
- `tel-uri`
|
|
392
|
+
- `telegram`
|
|
393
|
+
- `ticket-context`
|
|
394
|
+
- `twilio`
|
|
395
|
+
- `url-userinfo`
|
|
396
|
+
- `us-ssn`
|
|
397
|
+
- `vault`
|
|
398
|
+
- `vercel`
|
|
399
|
+
- `visa-context`
|
|
400
|
+
- `vocabulary-cue`
|
|
401
|
+
- `vocabulary-role`
|
|
402
|
+
- `webhook`
|
|
403
|
+
- `wordpress`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { compileKnown, createSyncSanitizer } from '../src/index.js';
|
|
2
|
+
|
|
3
|
+
// Reuse caller-owned compilation in a synchronous logging hook.
|
|
4
|
+
const known = compileKnown([{ type: 'ORGANIZATION', value: 'Ромашка' }]);
|
|
5
|
+
const loggerPolicy = createSyncSanitizer({
|
|
6
|
+
profile: 'documents',
|
|
7
|
+
knownPersonal: known,
|
|
8
|
+
vocabulary: { roles: ['маркетолог'] },
|
|
9
|
+
structured: 'json',
|
|
10
|
+
allowedFields: ['level', 'msg'],
|
|
11
|
+
fields: { location: 'scan' },
|
|
12
|
+
transformations: { ORGANIZATION: () => 'PrivateCompany' },
|
|
13
|
+
});
|
|
14
|
+
console.log(
|
|
15
|
+
loggerPolicy.sanitize(
|
|
16
|
+
JSON.stringify({
|
|
17
|
+
level: 'info',
|
|
18
|
+
msg: 'работал в Ромашке',
|
|
19
|
+
privateNote: 'caller-private text',
|
|
20
|
+
count: 1,
|
|
21
|
+
})
|
|
22
|
+
).text
|
|
23
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@link-foundation/sensitive-data-sanitizer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Offline sensitive-text sanitization with credential, multilingual personal-data and scanner union detection",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
"README.md",
|
|
26
26
|
"examples/shared-tool-logs.mjs",
|
|
27
27
|
"examples/reversible-placeholders.mjs",
|
|
28
|
-
"examples/prose-logs.mjs"
|
|
28
|
+
"examples/prose-logs.mjs",
|
|
29
|
+
"docs/RULES.md",
|
|
30
|
+
"examples/custom-log-policy.mjs"
|
|
29
31
|
],
|
|
30
32
|
"exports": {
|
|
31
33
|
".": {
|
|
@@ -40,6 +42,10 @@
|
|
|
40
42
|
"types": "./src/legacy.d.ts",
|
|
41
43
|
"browser": "./src/arithmetic.js",
|
|
42
44
|
"import": "./src/legacy.js"
|
|
45
|
+
},
|
|
46
|
+
"./ner": {
|
|
47
|
+
"types": "./src/ner.d.ts",
|
|
48
|
+
"import": "./src/ner.js"
|
|
43
49
|
}
|
|
44
50
|
},
|
|
45
51
|
"scripts": {
|
|
@@ -96,6 +102,7 @@
|
|
|
96
102
|
"devDependencies": {
|
|
97
103
|
"@changesets/cli": "^3.0.3",
|
|
98
104
|
"@eslint/js": "^10.0.1",
|
|
105
|
+
"@nlpjs/ner": "4.27.0",
|
|
99
106
|
"browser-commander": "0.34.1",
|
|
100
107
|
"cmd-shim": "^9.0.2",
|
|
101
108
|
"command-stream": "2.6.0",
|
|
@@ -151,5 +158,13 @@
|
|
|
151
158
|
},
|
|
152
159
|
"overrides": {
|
|
153
160
|
"minimatch@>=7 <11": "^11.0.5"
|
|
161
|
+
},
|
|
162
|
+
"peerDependencies": {
|
|
163
|
+
"@nlpjs/ner": "^4.27.0"
|
|
164
|
+
},
|
|
165
|
+
"peerDependenciesMeta": {
|
|
166
|
+
"@nlpjs/ner": {
|
|
167
|
+
"optional": true
|
|
168
|
+
}
|
|
154
169
|
}
|
|
155
170
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { failure } from './detection.js';
|
|
2
|
+
import { personalRegex } from './personal-variants.js';
|
|
3
|
+
import { projectText } from './projection.js';
|
|
4
|
+
|
|
5
|
+
// Caller-owned frozen arrays remain compatible with maps, streams and fakes.
|
|
6
|
+
// Weak keys allow the caller to release all values and compiled expressions.
|
|
7
|
+
const compiled = new WeakMap();
|
|
8
|
+
export const isCompiledKnown = (entries) => compiled.has(entries);
|
|
9
|
+
export const compiledPatterns = (entries) => compiled.get(entries)?.patterns;
|
|
10
|
+
export const projectedKnown = (entries) => compiled.get(entries)?.projected;
|
|
11
|
+
|
|
12
|
+
export function compileKnown(...lists) {
|
|
13
|
+
if (lists.some((list) => !Array.isArray(list))) {
|
|
14
|
+
throw failure('ERR_CONFIG');
|
|
15
|
+
}
|
|
16
|
+
const values = new Map();
|
|
17
|
+
for (const entry of lists.flat()) {
|
|
18
|
+
if (
|
|
19
|
+
!entry ||
|
|
20
|
+
typeof entry.value !== 'string' ||
|
|
21
|
+
!entry.value ||
|
|
22
|
+
!/^[A-Z][A-Z0-9_]{0,63}$/.test(entry.type) ||
|
|
23
|
+
(entry.properCase !== undefined && typeof entry.properCase !== 'boolean')
|
|
24
|
+
) {
|
|
25
|
+
throw failure('ERR_CONFIG');
|
|
26
|
+
}
|
|
27
|
+
const copy = Object.freeze({
|
|
28
|
+
type: entry.type,
|
|
29
|
+
value: entry.value,
|
|
30
|
+
...(entry.properCase === undefined
|
|
31
|
+
? {}
|
|
32
|
+
: { properCase: entry.properCase }),
|
|
33
|
+
});
|
|
34
|
+
values.set(
|
|
35
|
+
`${entry.type}\0${entry.value}\0${entry.properCase ?? false}`,
|
|
36
|
+
copy
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
const entries = Object.freeze([...values.values()]);
|
|
40
|
+
const patterns = entries.map((entry) =>
|
|
41
|
+
personalRegex(entry.value, entry.type)
|
|
42
|
+
);
|
|
43
|
+
const projected = entries.map((entry) => ({
|
|
44
|
+
...entry,
|
|
45
|
+
value: projectText(entry.value).text,
|
|
46
|
+
}));
|
|
47
|
+
const changed = projected.some(
|
|
48
|
+
(entry, i) => entry.value !== entries[i].value
|
|
49
|
+
);
|
|
50
|
+
compiled.set(entries, {
|
|
51
|
+
patterns,
|
|
52
|
+
projected: changed ? compileKnown(projected) : entries,
|
|
53
|
+
});
|
|
54
|
+
return entries;
|
|
55
|
+
}
|
package/src/detection.js
CHANGED
|
@@ -16,6 +16,8 @@ import { localAddress } from './public.js';
|
|
|
16
16
|
import { detectKnownPersonal } from './personal-variants.js';
|
|
17
17
|
import { detectDocumentEntities } from './document-entities.js';
|
|
18
18
|
import { detectProseAndDocuments } from './proper-names.js';
|
|
19
|
+
import { builtInEnabled } from './policy.js';
|
|
20
|
+
import { detectStrict } from './strict.js';
|
|
19
21
|
|
|
20
22
|
export const REDACTED = '[REDACTED]';
|
|
21
23
|
export const failure = (code = 'ERR_SANITIZATION', location = {}) =>
|
|
@@ -137,6 +139,12 @@ function detectCookies(text, emit) {
|
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
export function nativeDetect(text, options, emit) {
|
|
142
|
+
const output = emit;
|
|
143
|
+
emit = (finding) => {
|
|
144
|
+
if (builtInEnabled(finding, options)) {
|
|
145
|
+
output(finding);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
140
148
|
const credential = { type: 'SECRET', category: 'credential' };
|
|
141
149
|
for (const value of options.knownSecrets ?? []) {
|
|
142
150
|
collectMatches(text, new RegExp(escapePattern(value), 'g'), emit, {
|
|
@@ -179,6 +187,7 @@ export function nativeDetect(text, options, emit) {
|
|
|
179
187
|
detectIdentity(text, emit);
|
|
180
188
|
detectNational(text, emit);
|
|
181
189
|
detectPersonalContext(text, emit);
|
|
190
|
+
detectStrict(text, emit, options);
|
|
182
191
|
}
|
|
183
192
|
detectCredentialFormats(text, emit);
|
|
184
193
|
// detect-secrets-style quoted entropy detection; bare commit hashes and
|