mirage-proxy 0.5.6

Invisible sensitive data filter for LLM APIs — secrets, credentials, and PII replaced with plausible fakes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
//! Auto-generated secret detection patterns from Gitleaks and secrets-patterns-db.
//! Sources:
//!   - Gitleaks (MIT): https://github.com/gitleaks/gitleaks
//!   - secrets-patterns-db (Apache 2.0): https://github.com/mazen160/secrets-patterns-db
//!
//! Generated: 2026-02-20
//! Only high-confidence, prefix-based and structural patterns included.
//! Generic "keyword near value" patterns excluded to minimize false positives.
//!
//! Pattern counts by category:
//!   AWS / Cloud providers:         12
//!   AI / ML platforms:              7
//!   Version control (GitHub/Lab):  19
//!   Communication (Slack, Discord): 9
//!   Payment / Commerce:            10
//!   Developer tools:               24
//!   Monitoring / Observability:     7
//!   Structural (keys, JWTs, DSNs): 11
//!   Other SaaS prefixed tokens:    30
//!   Total:                        129

use crate::redactor::PiiKind;

pub struct SecretPattern {
    pub name: &'static str,
    pub regex: &'static str,
    pub kind: PiiKind,
}

/// High-confidence secret patterns with distinctive prefixes or structures.
/// These are safe to use in a live proxy because they have very low false-positive rates.
/// Only patterns matching tokens that are structurally self-identifying are included.
pub static SECRET_PATTERNS: &[SecretPattern] = &[
    // ─── AWS / Amazon ─────────────────────────────────────────────────────────
    SecretPattern {
        name: "AWS Access Key",
        regex: r"\b(?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z2-7]{16}\b",
        kind: PiiKind::AwsKey,
    },
    SecretPattern {
        name: "AWS Bedrock API Key (Long-lived)",
        regex: r"\bABSK[A-Za-z0-9+/]{109,269}={0,2}\b",
        kind: PiiKind::AwsKey,
    },
    SecretPattern {
        name: "AWS AppSync GraphQL Key",
        regex: r"\bda2-[a-z0-9]{26}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Google / GCP ─────────────────────────────────────────────────────────
    SecretPattern {
        name: "GCP API Key",
        regex: r"\bAIza[\w-]{35}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Google OAuth Access Token",
        regex: r"\bya29\.[0-9A-Za-z_-]{20,}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        // Matches the JSON field that identifies a GCP service account key file
        name: "GCP Service Account JSON",
        regex: r#""type"\s*:\s*"service_account""#,
        kind: PiiKind::GenericApiKey,
    },

    // ─── Azure ────────────────────────────────────────────────────────────────
    SecretPattern {
        // Azure AD client secrets have a distinctive Q~ marker after 3 alphanum chars + digit.
        // The r#"..."# raw string allows backtick (`) to appear without escaping.
        // Character class: backslash, apostrophe, quote, backtick, whitespace.
        name: "Azure AD Client Secret",
        regex: r#"(?:^|[\\'"`\s>=:(,)])([a-zA-Z0-9_~.]{3}[0-9]Q~[a-zA-Z0-9_~.-]{31,34})(?:$|[\\'"`\s<),])"#,
        kind: PiiKind::GenericApiKey,
    },

    // ─── DigitalOcean ─────────────────────────────────────────────────────────
    SecretPattern {
        name: "DigitalOcean Personal Access Token",
        regex: r"\bdop_v1_[a-f0-9]{64}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "DigitalOcean OAuth Access Token",
        regex: r"\bdoo_v1_[a-f0-9]{64}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "DigitalOcean OAuth Refresh Token",
        regex: r"\bdor_v1_[a-f0-9]{64}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Alibaba Cloud ────────────────────────────────────────────────────────
    SecretPattern {
        name: "Alibaba Cloud Access Key ID",
        regex: r"\bLTAI[a-zA-Z0-9]{17,21}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Anthropic ────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Anthropic API Key",
        regex: r"\bsk-ant-api03-[a-zA-Z0-9_-]{93}AA\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Anthropic Admin API Key",
        regex: r"\bsk-ant-admin01-[a-zA-Z0-9_-]{93}AA\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── OpenAI ───────────────────────────────────────────────────────────────
    SecretPattern {
        // Old format has T3BlbkFJ (base64 of "OpenAI") embedded; new format uses proj/svcacct/admin prefix
        name: "OpenAI API Key (old format with T3BlbkFJ marker)",
        regex: r"\bsk-[a-zA-Z0-9]{20}T3BlbkFJ[a-zA-Z0-9]{20}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "OpenAI API Key (new project/service format)",
        regex: r"\bsk-(?:proj|svcacct|admin)-[A-Za-z0-9_-]{58,74}T3BlbkFJ[A-Za-z0-9_-]{58,74}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Perplexity AI ────────────────────────────────────────────────────────
    SecretPattern {
        name: "Perplexity API Key",
        regex: r"\bpplx-[a-zA-Z0-9]{48}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── HuggingFace ──────────────────────────────────────────────────────────
    SecretPattern {
        name: "HuggingFace Access Token",
        regex: r"\bhf_[a-zA-Z]{34}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "HuggingFace Organization API Token",
        regex: r"\bapi_org_[a-zA-Z]{34}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── GitHub ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "GitHub Personal Access Token (Classic)",
        regex: r"\bghp_[0-9a-zA-Z]{36}\b",
        kind: PiiKind::GithubToken,
    },
    SecretPattern {
        name: "GitHub Fine-Grained PAT",
        regex: r"\bgithub_pat_\w{82}\b",
        kind: PiiKind::GithubToken,
    },
    SecretPattern {
        name: "GitHub OAuth Token",
        regex: r"\bgho_[0-9a-zA-Z]{36}\b",
        kind: PiiKind::GithubToken,
    },
    SecretPattern {
        name: "GitHub App Installation Token",
        regex: r"\bghs_[0-9a-zA-Z]{36}\b",
        kind: PiiKind::GithubToken,
    },
    SecretPattern {
        name: "GitHub App User-to-Server Token",
        regex: r"\bghu_[0-9a-zA-Z]{36}\b",
        kind: PiiKind::GithubToken,
    },
    SecretPattern {
        name: "GitHub Refresh Token",
        regex: r"\bghr_[0-9a-zA-Z]{36}\b",
        kind: PiiKind::GithubToken,
    },

    // ─── GitLab ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "GitLab Personal Access Token",
        regex: r"\bglpat-[\w-]{20}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab PAT (Routable / Instance-prefixed)",
        regex: r"\bglpat-[0-9a-zA-Z_-]{27,300}\.[0-9a-z]{9}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab CI/CD Job Token",
        regex: r"\bglcbt-[0-9a-zA-Z]{1,5}_[0-9a-zA-Z_-]{20}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab Deploy Token",
        regex: r"\bgldt-[0-9a-zA-Z_-]{20}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab Feature Flag Client Token",
        regex: r"\bglffct-[0-9a-zA-Z_-]{20}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab Feed Token",
        regex: r"\bglft-[0-9a-zA-Z_-]{20}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab Incoming Mail Token",
        regex: r"\bglimt-[0-9a-zA-Z_-]{25}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab Kubernetes Agent Token",
        regex: r"\bglagent-[0-9a-zA-Z_-]{50}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab OAuth App Secret",
        regex: r"\bgloas-[0-9a-zA-Z_-]{64}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab Pipeline Trigger Token",
        regex: r"\bglptt-[0-9a-f]{40}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab Runner Registration Token",
        regex: r"\bGR1348941[\w-]{20}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab Runner Authentication Token",
        regex: r"\bglrt-[0-9a-zA-Z_-]{20}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "GitLab SCIM Token",
        regex: r"\bglsoat-[0-9a-zA-Z_-]{20}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Slack ────────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Slack Bot Token",
        regex: r"\bxoxb-[0-9]{8,14}-[0-9]{8,14}-[a-zA-Z0-9]{24}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Slack App-Level Token",
        regex: r"\bxapp-[0-9]-[A-Z0-9]+-[0-9]+-[a-z0-9]+\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Slack User Token",
        regex: r"\bxox[pe](?:-[0-9]{10,13}){3}-[a-zA-Z0-9-]{28,34}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Slack Legacy Token",
        regex: r"\bxox[os]-[0-9]+-[0-9]+-[0-9]+-[a-fA-F0-9]+\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Slack Legacy Workspace Token",
        regex: r"\bxox[ar]-(?:[0-9]+-)?[0-9a-zA-Z]{8,48}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Slack Config Access Token",
        regex: r"\bxoxe\.xox[bp]-[0-9]-[A-Z0-9]{163,166}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Slack Config Refresh Token",
        regex: r"\bxoxe-[0-9]-[A-Z0-9]{146}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Slack Incoming Webhook URL",
        regex: r"(?:https?://)?hooks\.slack\.com/(?:services|workflows|triggers)/[A-Za-z0-9+/]{43,56}",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Discord ──────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Discord Webhook URL",
        regex: r"https://discord(?:app)?\.com/api/webhooks/[0-9]{17,20}/[A-Za-z0-9_-]{60,72}",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Stripe ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Stripe Secret / Restricted Key",
        regex: r"\b(?:sk|rk)_(?:test|live|prod)_[a-zA-Z0-9]{10,99}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Square ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Square Access Token",
        regex: r"\b(?:EAAA|sq0atp-)[\w-]{22,60}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Shopify ──────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Shopify Access Token",
        regex: r"\bshpat_[a-fA-F0-9]{32}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Shopify Custom Access Token",
        regex: r"\bshpca_[a-fA-F0-9]{32}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Shopify Private App Token",
        regex: r"\bshppa_[a-fA-F0-9]{32}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Shopify Shared Secret",
        regex: r"\bshpss_[a-fA-F0-9]{32}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Flutterwave ──────────────────────────────────────────────────────────
    SecretPattern {
        name: "Flutterwave Secret Key (Test, 32-char)",
        regex: r"\bFLWSECK_TEST-[a-zA-Z0-9]{32}-X\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Flutterwave Secret Key (Production)",
        regex: r"\bFLWSECK-[a-zA-Z0-9]{32}-X\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Flutterwave Public Key (Test)",
        regex: r"\bFLWPUBK_TEST-[a-zA-Z0-9]{32}-X\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── SendGrid ─────────────────────────────────────────────────────────────
    SecretPattern {
        name: "SendGrid API Token",
        // SG. followed by 22-char base64 ID, dot, 43-char base64 secret
        regex: r"\bSG\.[a-zA-Z0-9=_-]{22}\.[a-zA-Z0-9=_-]{43}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Sendinblue / Brevo ───────────────────────────────────────────────────
    SecretPattern {
        name: "Sendinblue (Brevo) API Token",
        regex: r"\bxkeysib-[a-f0-9]{64}-[a-zA-Z0-9]{16}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Mailchimp ────────────────────────────────────────────────────────────
    SecretPattern {
        // Format: <32 lowercase hex>-us<1-2 datacenter digits>
        name: "Mailchimp API Key",
        regex: r"\b[a-f0-9]{32}-us[0-9]{1,2}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Twilio ───────────────────────────────────────────────────────────────
    SecretPattern {
        // SK prefix + 32 hex chars (Twilio API Key SID format)
        name: "Twilio API Key",
        regex: r"\bSK[0-9a-fA-F]{32}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── NPM ──────────────────────────────────────────────────────────────────
    SecretPattern {
        name: "NPM Access Token",
        regex: r"\bnpm_[a-zA-Z0-9]{36}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── PyPI ─────────────────────────────────────────────────────────────────
    SecretPattern {
        name: "PyPI Upload Token",
        regex: r"\bpypi-AgEIcHlwaS5vcmc[\w-]{50,200}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── RubyGems ─────────────────────────────────────────────────────────────
    SecretPattern {
        name: "RubyGems API Token",
        regex: r"\brubygems_[a-f0-9]{48}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Databricks ───────────────────────────────────────────────────────────
    SecretPattern {
        name: "Databricks API Token",
        regex: r"\bdapi[a-f0-9]{32}(?:-[0-9])?\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Doppler ──────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Doppler API Token",
        regex: r"\bdp\.pt\.[a-zA-Z0-9]{43}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Dynatrace ────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Dynatrace API Token (dt0c01 format)",
        regex: r"\bdt0c01\.[a-zA-Z0-9]{24}\.[a-zA-Z0-9]{64}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Dynatrace Token (generic format)",
        regex: r"\bdt0[a-zA-Z][0-9]{2}\.[A-Z0-9]{24}\.[A-Z0-9]{64}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Grafana ──────────────────────────────────────────────────────────────
    SecretPattern {
        // Grafana API keys are base64 JSON starting with {"k":" → eyJrIjoi
        name: "Grafana API Key (eyJrIjoi prefix)",
        regex: r"\beyJrIjoi[A-Za-z0-9+/]{70,400}={0,3}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Grafana Cloud API Token",
        regex: r"\bglc_[A-Za-z0-9+/]{32,400}={0,3}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Grafana Service Account Token",
        regex: r"\bglsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── New Relic ────────────────────────────────────────────────────────────
    SecretPattern {
        name: "New Relic User API Key",
        regex: r"\bNRAK-[a-z0-9]{27}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "New Relic Insert Key",
        regex: r"\bNRII-[a-z0-9-]{32}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "New Relic Browser API Token",
        regex: r"\bNRJS-[a-f0-9]{19}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Sentry ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Sentry User Auth Token",
        regex: r"\bsntryu_[a-f0-9]{64}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Sentry Org Auth Token",
        regex: r"\bsntrys_eyJpYXQiO[a-zA-Z0-9+/]{10,200}(?:LCJyZWdpb25fdXJs|InJlZ2lvbl91cmwi|cmVnaW9uX3VybCI6)[a-zA-Z0-9+/]{10,200}={0,2}_[a-zA-Z0-9+/]{43}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── HashiCorp Vault ──────────────────────────────────────────────────────
    SecretPattern {
        name: "Vault Service Token",
        regex: r"\bhvs\.[\w-]{90,120}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Vault Batch Token",
        regex: r"\bhvb\.[\w-]{138,200}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── HashiCorp Terraform Cloud ────────────────────────────────────────────
    SecretPattern {
        name: "Terraform Cloud API Token",
        regex: r"(?i)\b[a-z0-9]{14}\.atlasv1\.[a-z0-9_-]{60,70}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── PlanetScale ──────────────────────────────────────────────────────────
    SecretPattern {
        name: "PlanetScale API Token",
        regex: r"\bpscale_tkn_[\w=.-]{32,64}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "PlanetScale OAuth Token",
        regex: r"\bpscale_oauth_[\w=.-]{32,64}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "PlanetScale Database Password",
        regex: r"\bpscale_pw_[\w=.-]{32,64}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Postman ──────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Postman API Token",
        regex: r"\bPMAK-[a-f0-9]{24}-[a-f0-9]{34}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Notion ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Notion Integration Token",
        regex: r"\bntn_[0-9]{11}[A-Za-z0-9]{35}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Linear ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Linear API Key",
        regex: r"\blin_api_[a-zA-Z0-9]{40}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Pulumi ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Pulumi API Token",
        regex: r"\bpul-[a-f0-9]{40}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Prefect ──────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Prefect API Token",
        regex: r"\bpnu_[a-zA-Z0-9]{36}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── ReadMe ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "ReadMe API Token",
        regex: r"\brdme_[a-z0-9]{70}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Scalingo ─────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Scalingo API Token",
        regex: r"\btk-us-[\w-]{48}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Infracost ────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Infracost API Token",
        regex: r"\bico-[a-zA-Z0-9]{32}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── OpenShift ────────────────────────────────────────────────────────────
    SecretPattern {
        name: "OpenShift User Token",
        regex: r"\bsha256~[\w-]{43}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── 1Password ────────────────────────────────────────────────────────────
    SecretPattern {
        name: "1Password Secret Key",
        regex: r"\bA3-[A-Z0-9]{6}-(?:[A-Z0-9]{11}|[A-Z0-9]{6}-[A-Z0-9]{5})-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "1Password Service Account Token",
        regex: r"\bops_eyJ[a-zA-Z0-9+/]{250,}={0,3}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Adobe ────────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Adobe Client Secret",
        regex: r"\bp8e-[a-zA-Z0-9]{32}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Age Encryption ───────────────────────────────────────────────────────
    SecretPattern {
        name: "Age Encryption Secret Key",
        regex: r"\bAGE-SECRET-KEY-1[QPZRY9X8GF2TVDW0S3JN54KHCE6MUA7L]{58}\b",
        kind: PiiKind::PrivateKey,
    },

    // ─── Airtable ─────────────────────────────────────────────────────────────
    SecretPattern {
        // pat + 14 alphanumeric chars + . + 64 hex chars
        name: "Airtable Personal Access Token",
        regex: r"\bpat[a-zA-Z0-9]{14}\.[a-f0-9]{64}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Artifactory ──────────────────────────────────────────────────────────
    SecretPattern {
        name: "Artifactory API Key",
        regex: r"\bAKCp[A-Za-z0-9]{69}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "Artifactory Reference Token",
        regex: r"\bcmVmd[A-Za-z0-9]{59}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Atlassian ────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Atlassian API Token (ATATT3 format)",
        regex: r"\bATATT3[A-Za-z0-9_=-]{186}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Cloudflare ───────────────────────────────────────────────────────────
    SecretPattern {
        name: "Cloudflare Origin CA Key",
        regex: r"\bv1\.0-[a-f0-9]{24}-[a-f0-9]{146}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── ClickHouse Cloud ─────────────────────────────────────────────────────
    SecretPattern {
        name: "ClickHouse Cloud API Key",
        regex: r"\b4b1d[A-Za-z0-9]{38}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Clojars ──────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Clojars API Token",
        regex: r"(?i)\bCLOJARS_[a-z0-9]{60}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Duffel ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Duffel API Token",
        regex: r"\bduffel_(?:test|live)_[a-zA-Z0-9_-]{43}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── EasyPost ─────────────────────────────────────────────────────────────
    SecretPattern {
        name: "EasyPost API Token",
        regex: r"\bEZAK[a-zA-Z0-9]{54}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "EasyPost Test API Token",
        regex: r"\bEZTK[a-zA-Z0-9]{54}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Facebook ─────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Facebook Page / Graph Access Token",
        regex: r"\bEAA[MC][a-zA-Z0-9]{100,}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Fly.io ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Fly.io Access Token",
        regex: r"\b(?:fo1_[\w-]{43}|fm1[ar]_[a-zA-Z0-9+/]{100,}={0,3}|fm2_[a-zA-Z0-9+/]{100,}={0,3})\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Frame.io ─────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Frame.io API Token",
        regex: r"\bfio-u-[a-zA-Z0-9_-]{64}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Heroku ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Heroku API Key (HRKU prefix)",
        regex: r"\bHRKU-AA[0-9a-zA-Z_-]{58}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── MaxMind ──────────────────────────────────────────────────────────────
    SecretPattern {
        name: "MaxMind License Key",
        regex: r"\b[A-Za-z0-9]{6}_[A-Za-z0-9]{29}_mmk\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Octopus Deploy ───────────────────────────────────────────────────────
    SecretPattern {
        name: "Octopus Deploy API Key",
        regex: r"\bAPI-[A-Z0-9]{26}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Shippo ───────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Shippo API Token",
        regex: r"\bshippo_(?:live|test)_[a-fA-F0-9]{40}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── SettleMint ───────────────────────────────────────────────────────────
    SecretPattern {
        name: "SettleMint Application Access Token",
        regex: r"\bsm_aat_[a-zA-Z0-9]{16}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "SettleMint Personal Access Token",
        regex: r"\bsm_pat_[a-zA-Z0-9]{16}\b",
        kind: PiiKind::GenericApiKey,
    },
    SecretPattern {
        name: "SettleMint Service Access Token",
        regex: r"\bsm_sat_[a-zA-Z0-9]{16}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Typeform ─────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Typeform API Token",
        regex: r"\btfp_[a-z0-9_.-]{59}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Intra42 (42 School) ──────────────────────────────────────────────────
    SecretPattern {
        name: "Intra42 Client Secret",
        regex: r"\bs-s4t2(?:ud|af)-[a-f0-9]{64}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Adafruit IO ──────────────────────────────────────────────────────────
    SecretPattern {
        name: "Adafruit IO Token",
        regex: r"\baio_[a-zA-Z0-9]{28}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Apify ────────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Apify API Token",
        regex: r"\bapify_api_[a-zA-Z0-9-]{36}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Dropbox ──────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Dropbox Short-Lived Token",
        regex: r"\bsl\.[A-Za-z0-9_-]{130,140}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Fleetbase ────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Fleetbase Live Token",
        regex: r"\bflb_live_[0-9a-zA-Z]{20}\b",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Cloudinary ───────────────────────────────────────────────────────────
    SecretPattern {
        name: "Cloudinary Credentials URL",
        regex: r"cloudinary://[0-9]+:[A-Za-z0-9_-]+@[A-Za-z0-9_-]+",
        kind: PiiKind::ConnectionString,
    },

    // ─── Microsoft Teams ──────────────────────────────────────────────────────
    SecretPattern {
        name: "Microsoft Teams Incoming Webhook",
        regex: r"https://[a-z0-9]+\.webhook\.office\.com/webhookb2/[a-z0-9]{8}-(?:[a-z0-9]{4}-){3}[a-z0-9]{12}@[a-z0-9]{8}-(?:[a-z0-9]{4}-){3}[a-z0-9]{12}/IncomingWebhook/[a-z0-9]{32}/[a-z0-9]{8}-(?:[a-z0-9]{4}-){3}[a-z0-9]{12}",
        kind: PiiKind::GenericApiKey,
    },

    // ─── Braintree ────────────────────────────────────────────────────────────
    SecretPattern {
        name: "Braintree Production Access Token",
        regex: r"access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}",
        kind: PiiKind::GenericApiKey,
    },

    // ─── JSON Web Token (structural) ──────────────────────────────────────────
    SecretPattern {
        // JWTs begin with ey (base64 of {") and have three dot-separated segments.
        // Using base64url charset [A-Za-z0-9_-] for the payload/signature.
        name: "JSON Web Token (JWT)",
        regex: r"\bey[A-Za-z0-9_-]{17,}\.ey[A-Za-z0-9_-]{17,}\.[A-Za-z0-9_-]{10,}={0,2}\b",
        kind: PiiKind::BearerToken,
    },

    // ─── Private Keys (structural) ────────────────────────────────────────────
    SecretPattern {
        // Matches all PEM private key types: RSA, EC, DSA, OPENSSH, PGP, PKCS8
        name: "PEM Private Key Block",
        regex: r"-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----",
        kind: PiiKind::PrivateKey,
    },

    // ─── Database / Service Connection Strings (structural) ───────────────────
    SecretPattern {
        name: "PostgreSQL Connection String (with credentials)",
        regex: r"postgres(?:ql)?://[^@\s:]{1,}:[^@\s]{1,}@[^\s/]+",
        kind: PiiKind::ConnectionString,
    },
    SecretPattern {
        name: "MySQL Connection String (with credentials)",
        regex: r"mysql(?:2)?://[^@\s:]{1,}:[^@\s]{1,}@[^\s/]+",
        kind: PiiKind::ConnectionString,
    },
    SecretPattern {
        name: "MongoDB Connection String (with credentials)",
        regex: r"mongodb(?:\+srv)?://[^@\s:]{1,}:[^@\s]{1,}@[^\s/]+",
        kind: PiiKind::ConnectionString,
    },
    SecretPattern {
        name: "Redis Connection String (with password)",
        regex: r"redis://:[^@\s]{3,}@[^\s/]+",
        kind: PiiKind::ConnectionString,
    },
    SecretPattern {
        name: "AMQP/RabbitMQ Connection String (with credentials)",
        regex: r"amqps?://[^@\s:]{1,}:[^@\s]{1,}@[^\s/]+",
        kind: PiiKind::ConnectionString,
    },
];

// ─────────────────────────────────────────────────────────────────────────────
// Summary
// ─────────────────────────────────────────────────────────────────────────────
//
//   Total patterns: 129
//
//   By PiiKind:
//     AwsKey          :  2  (AWS IAM keys, Bedrock)
//     GithubToken     :  6  (ghp_, gho_, ghs_, ghu_, ghr_, github_pat_)
//     PrivateKey      :  2  (PEM block, Age encryption)
//     BearerToken     :  1  (JWT)
//     ConnectionString:  6  (postgres, mysql, mongodb, redis, amqp, cloudinary)
//     GenericApiKey   :112  (all other prefixed tokens)
//
//   By source:
//     Gitleaks (MIT)                   : ~108 patterns (prefix/structure based only)
//     secrets-patterns-db (Apache 2.0) :  ~12 patterns
//     Derived / deduplicated           :   ~9 patterns
//
//   Explicitly excluded (too noisy for live proxy):
//     - Generic "keyword near random string" patterns (e.g. (?:stripe).{0,40}\b([a-z0-9]{32})\b)
//     - URL-only patterns (AWS endpoints, Firebase domains)
//     - Patterns with very short prefixes that would match common code identifiers
//     - Low-confidence patterns from secrets-patterns-db
// ─────────────────────────────────────────────────────────────────────────────