1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | exports.DEFAULT_REDACTION_PATTERNS = [
|
26 | {
|
27 | regexp: /\b[A-F0-9]{64}\b/g,
|
28 | replacement: "[ATOMIST_API_KEY]",
|
29 | },
|
30 | {
|
31 | regexp: /[1-9][0-9]+-[0-9a-zA-Z]{40}/g,
|
32 | replacement: "[TWITTER_ACCESS_TOKEN]",
|
33 | },
|
34 | {
|
35 | regexp: /EAACEdEose0cBA[0-9A-Za-z]+/g,
|
36 | replacement: "[FACEBOOK_ACCESS_TOKEN]",
|
37 | },
|
38 | {
|
39 | regexp: /AIza[0-9A-Za-z\-_]{35}/g,
|
40 | replacement: "[GOOGLE_API_KEY]",
|
41 | },
|
42 | {
|
43 | regexp: /[0-9]+-[0-9A-Za-z_]{32}\.apps\.googleusercontent\.com/g,
|
44 | replacement: "[GOOGLE_OAUTH_ID]",
|
45 | },
|
46 | {
|
47 | regexp: /sk_live_[0-9a-z]{32}/g,
|
48 | replacement: "[PICATIC_API_KEY|",
|
49 | },
|
50 | {
|
51 | regexp: /sk_live_[0-9a-zA-Z]{24}/g,
|
52 | replacement: "[STRIPE_REGULAR_API_KEY]",
|
53 | },
|
54 | {
|
55 | regexp: /rk_live_[0-9a-zA-Z]{24}/g,
|
56 | replacement: "[STRIPE_RESTRICTED_API_KEY]",
|
57 | },
|
58 | {
|
59 | regexp: /sq0atp-[0-9A-Za-z\-_]{22}/g,
|
60 | replacement: "[SQUARE_OAUTH_TOKEN]",
|
61 | },
|
62 | {
|
63 | regexp: /sq0csp-[0-9A-Za-z\-_]{43}/g,
|
64 | replacement: "[SQUARE_OAUTH_SECRET]",
|
65 | },
|
66 | {
|
67 | regexp: /access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32}/g,
|
68 | replacement: "[BRAINTREE_ACCESS_TOKEN]",
|
69 | },
|
70 | {
|
71 | regexp: /amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/g,
|
72 | replacement: "[AMAZON_AUTH_TOKEN]",
|
73 | },
|
74 | {
|
75 | regexp: /SK[0-9a-fA-F]{32}/g,
|
76 | replacement: "[TWILLIO_API_KEY]",
|
77 | },
|
78 | {
|
79 | regexp: /key-[0-9a-zA-Z]{32}/g,
|
80 | replacement: "[MAILGUN_KEY]",
|
81 | },
|
82 | {
|
83 | regexp: /[0-9a-f]{32}-us[0-9]{1,2}/g,
|
84 | replacement: "[MAILCHIMP_API_KEY]",
|
85 | },
|
86 | {
|
87 | regexp: /\bAK[0-9A-Z]{18}\b/g,
|
88 | replacement: "[AMAZON_ACCESS_KEY]",
|
89 | },
|
90 | {
|
91 | regexp: /\b(https?:\/\/)(?:v1\.)?[a-f0-9]{40}((?::x-oauth-basic)?@)/g,
|
92 | replacement: "$1[GITHUB_TOKEN]$2",
|
93 | },
|
94 | {
|
95 |
|
96 |
|
97 | regexp: /\b((?:ht|f|sm)tps?:\/\/)[^:/?#\[\]@""<>{}|\\^``\s]+:[^:/?#\[\]@""<>{}|\\^``\s]+@/g,
|
98 | replacement: "$1[USER]:[PASSWORD]@",
|
99 | },
|
100 | ];
|
101 | function redact(message) {
|
102 | let output = message;
|
103 | exports.DEFAULT_REDACTION_PATTERNS.forEach(r => {
|
104 | output = typeof output === "string" ? output.replace(r.regexp, r.replacement) : output;
|
105 | });
|
106 | return output;
|
107 | }
|
108 | exports.redact = redact;
|
109 |
|
\ | No newline at end of file |