node-mongo-orm 0.0.1-security → 3.4.2

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.

Potentially problematic release.


This version of node-mongo-orm might be problematic. Click here for more details.

Files changed (200) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +8 -0
  3. package/.github/dependabot.yml +13 -0
  4. package/.github/workflows/bench.yml +61 -0
  5. package/.github/workflows/ci.yml +88 -0
  6. package/.github/workflows/lock-threads.yml +30 -0
  7. package/.github/workflows/target-main.yml +23 -0
  8. package/.nojekyll +0 -0
  9. package/.prettierignore +1 -0
  10. package/.taprc.yaml +8 -0
  11. package/CNAME +1 -0
  12. package/CONTRIBUTING.md +30 -0
  13. package/LICENSE +21 -0
  14. package/README.md +159 -3
  15. package/SECURITY.md +68 -0
  16. package/benchmarks/basic.bench.js +95 -0
  17. package/benchmarks/child-child.bench.js +52 -0
  18. package/benchmarks/child-creation.bench.js +73 -0
  19. package/benchmarks/child.bench.js +62 -0
  20. package/benchmarks/deep-object.bench.js +88 -0
  21. package/benchmarks/formatters.bench.js +50 -0
  22. package/benchmarks/internal/custom-levels.js +67 -0
  23. package/benchmarks/internal/just-pino-heavy.bench.js +76 -0
  24. package/benchmarks/internal/just-pino.bench.js +182 -0
  25. package/benchmarks/internal/parent-vs-child.bench.js +75 -0
  26. package/benchmarks/internal/redact.bench.js +86 -0
  27. package/benchmarks/long-string.bench.js +81 -0
  28. package/benchmarks/multi-arg.bench.js +193 -0
  29. package/benchmarks/multistream.js +98 -0
  30. package/benchmarks/object.bench.js +82 -0
  31. package/benchmarks/utils/generate-benchmark-doc.js +36 -0
  32. package/benchmarks/utils/runbench.js +138 -0
  33. package/benchmarks/utils/wrap-log-level.js +55 -0
  34. package/bin.js +6 -0
  35. package/browser.js +484 -0
  36. package/build/sync-version.js +10 -0
  37. package/docs/api.md +1487 -0
  38. package/docs/asynchronous.md +40 -0
  39. package/docs/benchmarks.md +55 -0
  40. package/docs/browser.md +227 -0
  41. package/docs/bundling.md +40 -0
  42. package/docs/child-loggers.md +95 -0
  43. package/docs/ecosystem.md +84 -0
  44. package/docs/help.md +345 -0
  45. package/docs/lts.md +64 -0
  46. package/docs/pretty.md +35 -0
  47. package/docs/redaction.md +135 -0
  48. package/docs/transports.md +1238 -0
  49. package/docs/web.md +269 -0
  50. package/docsify/sidebar.md +26 -0
  51. package/examples/basic.js +43 -0
  52. package/examples/transport.js +68 -0
  53. package/favicon-16x16.png +0 -0
  54. package/favicon-32x32.png +0 -0
  55. package/favicon.ico +0 -0
  56. package/file.js +12 -0
  57. package/inc-version.sh +42 -0
  58. package/index.html +55 -0
  59. package/lib/caller.js +30 -0
  60. package/lib/constants.js +28 -0
  61. package/lib/deprecations.js +8 -0
  62. package/lib/levels.js +241 -0
  63. package/lib/meta.js +3 -0
  64. package/lib/multistream.js +188 -0
  65. package/lib/proto.js +234 -0
  66. package/lib/redaction.js +118 -0
  67. package/lib/symbols.js +74 -0
  68. package/lib/time.js +11 -0
  69. package/lib/tools.js +394 -0
  70. package/lib/transport-stream.js +56 -0
  71. package/lib/transport.js +167 -0
  72. package/lib/worker.js +194 -0
  73. package/lib/writer.js +42 -0
  74. package/package.json +117 -3
  75. package/pino-banner.png +0 -0
  76. package/pino-logo-hire.png +0 -0
  77. package/pino-tree.png +0 -0
  78. package/pino.d.ts +889 -0
  79. package/pino.js +236 -0
  80. package/pretty-demo.png +0 -0
  81. package/test/basic.test.js +874 -0
  82. package/test/broken-pipe.test.js +57 -0
  83. package/test/browser-child.test.js +132 -0
  84. package/test/browser-disabled.test.js +87 -0
  85. package/test/browser-early-console-freeze.test.js +12 -0
  86. package/test/browser-levels.test.js +241 -0
  87. package/test/browser-serializers.test.js +352 -0
  88. package/test/browser-timestamp.test.js +88 -0
  89. package/test/browser-transmit.test.js +417 -0
  90. package/test/browser.test.js +659 -0
  91. package/test/complex-objects.test.js +34 -0
  92. package/test/crlf.test.js +32 -0
  93. package/test/custom-levels.test.js +253 -0
  94. package/test/error.test.js +398 -0
  95. package/test/errorKey.test.js +34 -0
  96. package/test/escaping.test.js +91 -0
  97. package/test/esm/esm.mjs +12 -0
  98. package/test/esm/index.test.js +34 -0
  99. package/test/esm/named-exports.mjs +27 -0
  100. package/test/exit.test.js +77 -0
  101. package/test/fixtures/broken-pipe/basic.js +9 -0
  102. package/test/fixtures/broken-pipe/destination.js +10 -0
  103. package/test/fixtures/broken-pipe/syncfalse.js +12 -0
  104. package/test/fixtures/console-transport.js +13 -0
  105. package/test/fixtures/default-exit.js +8 -0
  106. package/test/fixtures/destination-exit.js +8 -0
  107. package/test/fixtures/eval/index.js +13 -0
  108. package/test/fixtures/eval/node_modules/14-files.js +3 -0
  109. package/test/fixtures/eval/node_modules/2-files.js +3 -0
  110. package/test/fixtures/eval/node_modules/file1.js +5 -0
  111. package/test/fixtures/eval/node_modules/file10.js +5 -0
  112. package/test/fixtures/eval/node_modules/file11.js +5 -0
  113. package/test/fixtures/eval/node_modules/file12.js +5 -0
  114. package/test/fixtures/eval/node_modules/file13.js +5 -0
  115. package/test/fixtures/eval/node_modules/file14.js +11 -0
  116. package/test/fixtures/eval/node_modules/file2.js +5 -0
  117. package/test/fixtures/eval/node_modules/file3.js +5 -0
  118. package/test/fixtures/eval/node_modules/file4.js +5 -0
  119. package/test/fixtures/eval/node_modules/file5.js +5 -0
  120. package/test/fixtures/eval/node_modules/file6.js +5 -0
  121. package/test/fixtures/eval/node_modules/file7.js +5 -0
  122. package/test/fixtures/eval/node_modules/file8.js +5 -0
  123. package/test/fixtures/eval/node_modules/file9.js +5 -0
  124. package/test/fixtures/noop-transport.js +10 -0
  125. package/test/fixtures/pretty/null-prototype.js +8 -0
  126. package/test/fixtures/stdout-hack-protection.js +11 -0
  127. package/test/fixtures/syncfalse-child.js +6 -0
  128. package/test/fixtures/syncfalse-exit.js +9 -0
  129. package/test/fixtures/syncfalse-flush-exit.js +10 -0
  130. package/test/fixtures/syncfalse.js +6 -0
  131. package/test/fixtures/syntax-error-esm.mjs +2 -0
  132. package/test/fixtures/to-file-transport-with-transform.js +20 -0
  133. package/test/fixtures/to-file-transport.js +13 -0
  134. package/test/fixtures/to-file-transport.mjs +8 -0
  135. package/test/fixtures/transport/index.js +12 -0
  136. package/test/fixtures/transport/package.json +5 -0
  137. package/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
  138. package/test/fixtures/transport-exit-immediately.js +11 -0
  139. package/test/fixtures/transport-exit-on-ready.js +12 -0
  140. package/test/fixtures/transport-main.js +9 -0
  141. package/test/fixtures/transport-many-lines.js +29 -0
  142. package/test/fixtures/transport-string-stdout.js +9 -0
  143. package/test/fixtures/transport-transform.js +21 -0
  144. package/test/fixtures/transport-uses-pino-config.js +33 -0
  145. package/test/fixtures/transport-with-on-exit.js +12 -0
  146. package/test/fixtures/transport-worker-data.js +19 -0
  147. package/test/fixtures/transport-worker.js +15 -0
  148. package/test/fixtures/transport-wrong-export-type.js +3 -0
  149. package/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
  150. package/test/fixtures/ts/to-file-transport.ts +11 -0
  151. package/test/fixtures/ts/transpile.cjs +36 -0
  152. package/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
  153. package/test/fixtures/ts/transport-exit-immediately.ts +10 -0
  154. package/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
  155. package/test/fixtures/ts/transport-main.ts +8 -0
  156. package/test/fixtures/ts/transport-string-stdout.ts +8 -0
  157. package/test/fixtures/ts/transport-worker.ts +14 -0
  158. package/test/formatters.test.js +355 -0
  159. package/test/helper.d.ts +4 -0
  160. package/test/helper.js +128 -0
  161. package/test/hooks.test.js +118 -0
  162. package/test/http.test.js +242 -0
  163. package/test/internals/version.test.js +15 -0
  164. package/test/is-level-enabled.test.js +185 -0
  165. package/test/jest/basic.spec.js +10 -0
  166. package/test/levels.test.js +772 -0
  167. package/test/metadata.test.js +106 -0
  168. package/test/mixin-merge-strategy.test.js +55 -0
  169. package/test/mixin.test.js +218 -0
  170. package/test/multistream.test.js +673 -0
  171. package/test/pkg/index.js +46 -0
  172. package/test/pkg/pkg.config.json +17 -0
  173. package/test/pkg/pkg.test.js +56 -0
  174. package/test/redact.test.js +847 -0
  175. package/test/serializers.test.js +253 -0
  176. package/test/stdout-protection.test.js +39 -0
  177. package/test/syncfalse.test.js +188 -0
  178. package/test/timestamp.test.js +121 -0
  179. package/test/transport/big.test.js +43 -0
  180. package/test/transport/bundlers-support.test.js +97 -0
  181. package/test/transport/caller.test.js +23 -0
  182. package/test/transport/core.test.js +644 -0
  183. package/test/transport/core.test.ts +236 -0
  184. package/test/transport/core.transpiled.test.ts +112 -0
  185. package/test/transport/module-link.test.js +239 -0
  186. package/test/transport/pipeline.test.js +135 -0
  187. package/test/transport/repl.test.js +14 -0
  188. package/test/transport/syncTrue.test.js +55 -0
  189. package/test/transport/syncfalse.test.js +68 -0
  190. package/test/transport/targets.test.js +44 -0
  191. package/test/transport/uses-pino-config.test.js +167 -0
  192. package/test/transport-stream.test.js +26 -0
  193. package/test/types/pino-import.test-d.ts +29 -0
  194. package/test/types/pino-multistream.test-d.ts +28 -0
  195. package/test/types/pino-top-export.test-d.ts +35 -0
  196. package/test/types/pino-transport.test-d.ts +145 -0
  197. package/test/types/pino-type-only.test-d.ts +64 -0
  198. package/test/types/pino.test-d.ts +468 -0
  199. package/test/types/pino.ts +78 -0
  200. package/tsconfig.json +14 -0
@@ -0,0 +1,847 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('tap')
4
+ const { sink, once } = require('./helper')
5
+ const pino = require('../')
6
+
7
+ test('redact option – throws if not array', async ({ throws }) => {
8
+ throws(() => {
9
+ pino({ redact: 'req.headers.cookie' })
10
+ })
11
+ })
12
+
13
+ test('redact option – throws if array does not only contain strings', async ({ throws }) => {
14
+ throws(() => {
15
+ pino({ redact: ['req.headers.cookie', {}] })
16
+ })
17
+ })
18
+
19
+ test('redact option – throws if array contains an invalid path', async ({ throws }) => {
20
+ throws(() => {
21
+ pino({ redact: ['req,headers.cookie'] })
22
+ })
23
+ })
24
+
25
+ test('redact.paths option – throws if not array', async ({ throws }) => {
26
+ throws(() => {
27
+ pino({ redact: { paths: 'req.headers.cookie' } })
28
+ })
29
+ })
30
+
31
+ test('redact.paths option – throws if array does not only contain strings', async ({ throws }) => {
32
+ throws(() => {
33
+ pino({ redact: { paths: ['req.headers.cookie', {}] } })
34
+ })
35
+ })
36
+
37
+ test('redact.paths option – throws if array contains an invalid path', async ({ throws }) => {
38
+ throws(() => {
39
+ pino({ redact: { paths: ['req,headers.cookie'] } })
40
+ })
41
+ })
42
+
43
+ test('redact option – top level key', async ({ equal }) => {
44
+ const stream = sink()
45
+ const instance = pino({ redact: ['key'] }, stream)
46
+ instance.info({
47
+ key: { redact: 'me' }
48
+ })
49
+ const { key } = await once(stream, 'data')
50
+ equal(key, '[Redacted]')
51
+ })
52
+
53
+ test('redact option – top level key next level key', async ({ equal }) => {
54
+ const stream = sink()
55
+ const instance = pino({ redact: ['key', 'key.foo'] }, stream)
56
+ instance.info({
57
+ key: { redact: 'me' }
58
+ })
59
+ const { key } = await once(stream, 'data')
60
+ equal(key, '[Redacted]')
61
+ })
62
+
63
+ test('redact option – next level key then top level key', async ({ equal }) => {
64
+ const stream = sink()
65
+ const instance = pino({ redact: ['key.foo', 'key'] }, stream)
66
+ instance.info({
67
+ key: { redact: 'me' }
68
+ })
69
+ const { key } = await once(stream, 'data')
70
+ equal(key, '[Redacted]')
71
+ })
72
+
73
+ test('redact option – object', async ({ equal }) => {
74
+ const stream = sink()
75
+ const instance = pino({ redact: ['req.headers.cookie'] }, stream)
76
+ instance.info({
77
+ req: {
78
+ id: 7915,
79
+ method: 'GET',
80
+ url: '/',
81
+ headers: {
82
+ host: 'localhost:3000',
83
+ connection: 'keep-alive',
84
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
85
+ },
86
+ remoteAddress: '::ffff:127.0.0.1',
87
+ remotePort: 58022
88
+ }
89
+ })
90
+ const { req } = await once(stream, 'data')
91
+ equal(req.headers.cookie, '[Redacted]')
92
+ })
93
+
94
+ test('redact option – child object', async ({ equal }) => {
95
+ const stream = sink()
96
+ const instance = pino({ redact: ['req.headers.cookie'] }, stream)
97
+ instance.child({
98
+ req: {
99
+ id: 7915,
100
+ method: 'GET',
101
+ url: '/',
102
+ headers: {
103
+ host: 'localhost:3000',
104
+ connection: 'keep-alive',
105
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
106
+ },
107
+ remoteAddress: '::ffff:127.0.0.1',
108
+ remotePort: 58022
109
+ }
110
+ }).info('message completed')
111
+ const { req } = await once(stream, 'data')
112
+ equal(req.headers.cookie, '[Redacted]')
113
+ })
114
+
115
+ test('redact option – interpolated object', async ({ equal }) => {
116
+ const stream = sink()
117
+ const instance = pino({ redact: ['req.headers.cookie'] }, stream)
118
+
119
+ instance.info('test %j', {
120
+ req: {
121
+ id: 7915,
122
+ method: 'GET',
123
+ url: '/',
124
+ headers: {
125
+ host: 'localhost:3000',
126
+ connection: 'keep-alive',
127
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
128
+ },
129
+ remoteAddress: '::ffff:127.0.0.1',
130
+ remotePort: 58022
131
+ }
132
+ })
133
+ const { msg } = await once(stream, 'data')
134
+ equal(JSON.parse(msg.replace(/test /, '')).req.headers.cookie, '[Redacted]')
135
+ })
136
+
137
+ test('redact.paths option – object', async ({ equal }) => {
138
+ const stream = sink()
139
+ const instance = pino({ redact: { paths: ['req.headers.cookie'] } }, stream)
140
+ instance.info({
141
+ req: {
142
+ id: 7915,
143
+ method: 'GET',
144
+ url: '/',
145
+ headers: {
146
+ host: 'localhost:3000',
147
+ connection: 'keep-alive',
148
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
149
+ },
150
+ remoteAddress: '::ffff:127.0.0.1',
151
+ remotePort: 58022
152
+ }
153
+ })
154
+ const { req } = await once(stream, 'data')
155
+ equal(req.headers.cookie, '[Redacted]')
156
+ })
157
+
158
+ test('redact.paths option – child object', async ({ equal }) => {
159
+ const stream = sink()
160
+ const instance = pino({ redact: { paths: ['req.headers.cookie'] } }, stream)
161
+ instance.child({
162
+ req: {
163
+ id: 7915,
164
+ method: 'GET',
165
+ url: '/',
166
+ headers: {
167
+ host: 'localhost:3000',
168
+ connection: 'keep-alive',
169
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
170
+ },
171
+ remoteAddress: '::ffff:127.0.0.1',
172
+ remotePort: 58022
173
+ }
174
+ }).info('message completed')
175
+ const { req } = await once(stream, 'data')
176
+ equal(req.headers.cookie, '[Redacted]')
177
+ })
178
+
179
+ test('redact.paths option – interpolated object', async ({ equal }) => {
180
+ const stream = sink()
181
+ const instance = pino({ redact: { paths: ['req.headers.cookie'] } }, stream)
182
+
183
+ instance.info('test %j', {
184
+ req: {
185
+ id: 7915,
186
+ method: 'GET',
187
+ url: '/',
188
+ headers: {
189
+ host: 'localhost:3000',
190
+ connection: 'keep-alive',
191
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
192
+ },
193
+ remoteAddress: '::ffff:127.0.0.1',
194
+ remotePort: 58022
195
+ }
196
+ })
197
+ const { msg } = await once(stream, 'data')
198
+ equal(JSON.parse(msg.replace(/test /, '')).req.headers.cookie, '[Redacted]')
199
+ })
200
+
201
+ test('redact.censor option – sets the redact value', async ({ equal }) => {
202
+ const stream = sink()
203
+ const instance = pino({ redact: { paths: ['req.headers.cookie'], censor: 'test' } }, stream)
204
+ instance.info({
205
+ req: {
206
+ id: 7915,
207
+ method: 'GET',
208
+ url: '/',
209
+ headers: {
210
+ host: 'localhost:3000',
211
+ connection: 'keep-alive',
212
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
213
+ },
214
+ remoteAddress: '::ffff:127.0.0.1',
215
+ remotePort: 58022
216
+ }
217
+ })
218
+ const { req } = await once(stream, 'data')
219
+ equal(req.headers.cookie, 'test')
220
+ })
221
+
222
+ test('redact.censor option – can be a function that accepts value and path arguments', async ({ equal }) => {
223
+ const stream = sink()
224
+ const instance = pino({ redact: { paths: ['topLevel'], censor: (value, path) => value + ' ' + path.join('.') } }, stream)
225
+ instance.info({
226
+ topLevel: 'test'
227
+ })
228
+ const { topLevel } = await once(stream, 'data')
229
+ equal(topLevel, 'test topLevel')
230
+ })
231
+
232
+ test('redact.censor option – can be a function that accepts value and path arguments (nested path)', async ({ equal }) => {
233
+ const stream = sink()
234
+ const instance = pino({ redact: { paths: ['req.headers.cookie'], censor: (value, path) => value + ' ' + path.join('.') } }, stream)
235
+ instance.info({
236
+ req: {
237
+ id: 7915,
238
+ method: 'GET',
239
+ url: '/',
240
+ headers: {
241
+ host: 'localhost:3000',
242
+ connection: 'keep-alive',
243
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
244
+ },
245
+ remoteAddress: '::ffff:127.0.0.1',
246
+ remotePort: 58022
247
+ }
248
+ })
249
+ const { req } = await once(stream, 'data')
250
+ equal(req.headers.cookie, 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1; req.headers.cookie')
251
+ })
252
+
253
+ test('redact.remove option – removes both key and value', async ({ equal }) => {
254
+ const stream = sink()
255
+ const instance = pino({ redact: { paths: ['req.headers.cookie'], remove: true } }, stream)
256
+ instance.info({
257
+ req: {
258
+ id: 7915,
259
+ method: 'GET',
260
+ url: '/',
261
+ headers: {
262
+ host: 'localhost:3000',
263
+ connection: 'keep-alive',
264
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
265
+ },
266
+ remoteAddress: '::ffff:127.0.0.1',
267
+ remotePort: 58022
268
+ }
269
+ })
270
+ const { req } = await once(stream, 'data')
271
+ equal('cookie' in req.headers, false)
272
+ })
273
+
274
+ test('redact.remove – top level key - object value', async ({ equal }) => {
275
+ const stream = sink()
276
+ const instance = pino({ redact: { paths: ['key'], remove: true } }, stream)
277
+ instance.info({
278
+ key: { redact: 'me' }
279
+ })
280
+ const o = await once(stream, 'data')
281
+ equal('key' in o, false)
282
+ })
283
+
284
+ test('redact.remove – top level key - number value', async ({ equal }) => {
285
+ const stream = sink()
286
+ const instance = pino({ redact: { paths: ['key'], remove: true } }, stream)
287
+ instance.info({
288
+ key: 1
289
+ })
290
+ const o = await once(stream, 'data')
291
+ equal('key' in o, false)
292
+ })
293
+
294
+ test('redact.remove – top level key - boolean value', async ({ equal }) => {
295
+ const stream = sink()
296
+ const instance = pino({ redact: { paths: ['key'], remove: true } }, stream)
297
+ instance.info({
298
+ key: false
299
+ })
300
+ const o = await once(stream, 'data')
301
+ equal('key' in o, false)
302
+ })
303
+
304
+ test('redact.remove – top level key in child logger', async ({ equal }) => {
305
+ const stream = sink()
306
+ const opts = { redact: { paths: ['key'], remove: true } }
307
+ const instance = pino(opts, stream).child({ key: { redact: 'me' } })
308
+ instance.info('test')
309
+ const o = await once(stream, 'data')
310
+ equal('key' in o, false)
311
+ })
312
+
313
+ test('redact.paths preserves original object values after the log write', async ({ equal }) => {
314
+ const stream = sink()
315
+ const instance = pino({ redact: ['req.headers.cookie'] }, stream)
316
+ const obj = {
317
+ req: {
318
+ id: 7915,
319
+ method: 'GET',
320
+ url: '/',
321
+ headers: {
322
+ host: 'localhost:3000',
323
+ connection: 'keep-alive',
324
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
325
+ },
326
+ remoteAddress: '::ffff:127.0.0.1',
327
+ remotePort: 58022
328
+ }
329
+ }
330
+ instance.info(obj)
331
+ const o = await once(stream, 'data')
332
+ equal(o.req.headers.cookie, '[Redacted]')
333
+ equal(obj.req.headers.cookie, 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;')
334
+ })
335
+
336
+ test('redact.paths preserves original object values after the log write', async ({ equal }) => {
337
+ const stream = sink()
338
+ const instance = pino({ redact: { paths: ['req.headers.cookie'] } }, stream)
339
+ const obj = {
340
+ req: {
341
+ id: 7915,
342
+ method: 'GET',
343
+ url: '/',
344
+ headers: {
345
+ host: 'localhost:3000',
346
+ connection: 'keep-alive',
347
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
348
+ },
349
+ remoteAddress: '::ffff:127.0.0.1',
350
+ remotePort: 58022
351
+ }
352
+ }
353
+ instance.info(obj)
354
+ const o = await once(stream, 'data')
355
+ equal(o.req.headers.cookie, '[Redacted]')
356
+ equal(obj.req.headers.cookie, 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;')
357
+ })
358
+
359
+ test('redact.censor preserves original object values after the log write', async ({ equal }) => {
360
+ const stream = sink()
361
+ const instance = pino({ redact: { paths: ['req.headers.cookie'], censor: 'test' } }, stream)
362
+ const obj = {
363
+ req: {
364
+ id: 7915,
365
+ method: 'GET',
366
+ url: '/',
367
+ headers: {
368
+ host: 'localhost:3000',
369
+ connection: 'keep-alive',
370
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
371
+ },
372
+ remoteAddress: '::ffff:127.0.0.1',
373
+ remotePort: 58022
374
+ }
375
+ }
376
+ instance.info(obj)
377
+ const o = await once(stream, 'data')
378
+ equal(o.req.headers.cookie, 'test')
379
+ equal(obj.req.headers.cookie, 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;')
380
+ })
381
+
382
+ test('redact.remove preserves original object values after the log write', async ({ equal }) => {
383
+ const stream = sink()
384
+ const instance = pino({ redact: { paths: ['req.headers.cookie'], remove: true } }, stream)
385
+ const obj = {
386
+ req: {
387
+ id: 7915,
388
+ method: 'GET',
389
+ url: '/',
390
+ headers: {
391
+ host: 'localhost:3000',
392
+ connection: 'keep-alive',
393
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
394
+ },
395
+ remoteAddress: '::ffff:127.0.0.1',
396
+ remotePort: 58022
397
+ }
398
+ }
399
+ instance.info(obj)
400
+ const o = await once(stream, 'data')
401
+ equal('cookie' in o.req.headers, false)
402
+ equal('cookie' in obj.req.headers, true)
403
+ })
404
+
405
+ test('redact – supports last position wildcard paths', async ({ equal }) => {
406
+ const stream = sink()
407
+ const instance = pino({ redact: ['req.headers.*'] }, stream)
408
+ instance.info({
409
+ req: {
410
+ id: 7915,
411
+ method: 'GET',
412
+ url: '/',
413
+ headers: {
414
+ host: 'localhost:3000',
415
+ connection: 'keep-alive',
416
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
417
+ },
418
+ remoteAddress: '::ffff:127.0.0.1',
419
+ remotePort: 58022
420
+ }
421
+ })
422
+ const { req } = await once(stream, 'data')
423
+ equal(req.headers.cookie, '[Redacted]')
424
+ equal(req.headers.host, '[Redacted]')
425
+ equal(req.headers.connection, '[Redacted]')
426
+ })
427
+
428
+ test('redact – supports first position wildcard paths', async ({ equal }) => {
429
+ const stream = sink()
430
+ const instance = pino({ redact: ['*.headers'] }, stream)
431
+ instance.info({
432
+ req: {
433
+ id: 7915,
434
+ method: 'GET',
435
+ url: '/',
436
+ headers: {
437
+ host: 'localhost:3000',
438
+ connection: 'keep-alive',
439
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
440
+ },
441
+ remoteAddress: '::ffff:127.0.0.1',
442
+ remotePort: 58022
443
+ }
444
+ })
445
+ const { req } = await once(stream, 'data')
446
+ equal(req.headers, '[Redacted]')
447
+ })
448
+
449
+ test('redact – supports first position wildcards before other paths', async ({ equal }) => {
450
+ const stream = sink()
451
+ const instance = pino({ redact: ['*.headers.cookie', 'req.id'] }, stream)
452
+ instance.info({
453
+ req: {
454
+ id: 7915,
455
+ method: 'GET',
456
+ url: '/',
457
+ headers: {
458
+ host: 'localhost:3000',
459
+ connection: 'keep-alive',
460
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
461
+ },
462
+ remoteAddress: '::ffff:127.0.0.1',
463
+ remotePort: 58022
464
+ }
465
+ })
466
+ const { req } = await once(stream, 'data')
467
+ equal(req.headers.cookie, '[Redacted]')
468
+ equal(req.id, '[Redacted]')
469
+ })
470
+
471
+ test('redact – supports first position wildcards after other paths', async ({ equal }) => {
472
+ const stream = sink()
473
+ const instance = pino({ redact: ['req.id', '*.headers.cookie'] }, stream)
474
+ instance.info({
475
+ req: {
476
+ id: 7915,
477
+ method: 'GET',
478
+ url: '/',
479
+ headers: {
480
+ host: 'localhost:3000',
481
+ connection: 'keep-alive',
482
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
483
+ },
484
+ remoteAddress: '::ffff:127.0.0.1',
485
+ remotePort: 58022
486
+ }
487
+ })
488
+ const { req } = await once(stream, 'data')
489
+ equal(req.headers.cookie, '[Redacted]')
490
+ equal(req.id, '[Redacted]')
491
+ })
492
+
493
+ test('redact – supports first position wildcards after top level keys', async ({ equal }) => {
494
+ const stream = sink()
495
+ const instance = pino({ redact: ['key', '*.headers.cookie'] }, stream)
496
+ instance.info({
497
+ req: {
498
+ id: 7915,
499
+ method: 'GET',
500
+ url: '/',
501
+ headers: {
502
+ host: 'localhost:3000',
503
+ connection: 'keep-alive',
504
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
505
+ },
506
+ remoteAddress: '::ffff:127.0.0.1',
507
+ remotePort: 58022
508
+ }
509
+ })
510
+ const { req } = await once(stream, 'data')
511
+ equal(req.headers.cookie, '[Redacted]')
512
+ })
513
+
514
+ test('redact – supports top level wildcard', async ({ equal }) => {
515
+ const stream = sink()
516
+ const instance = pino({ redact: ['*'] }, stream)
517
+ instance.info({
518
+ req: {
519
+ id: 7915,
520
+ method: 'GET',
521
+ url: '/',
522
+ headers: {
523
+ host: 'localhost:3000',
524
+ connection: 'keep-alive',
525
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
526
+ },
527
+ remoteAddress: '::ffff:127.0.0.1',
528
+ remotePort: 58022
529
+ }
530
+ })
531
+ const { req } = await once(stream, 'data')
532
+ equal(req, '[Redacted]')
533
+ })
534
+
535
+ test('redact – supports top level wildcard with a censor function', async ({ equal }) => {
536
+ const stream = sink()
537
+ const instance = pino({
538
+ redact: {
539
+ paths: ['*'],
540
+ censor: () => '[Redacted]'
541
+ }
542
+ }, stream)
543
+ instance.info({
544
+ req: {
545
+ id: 7915,
546
+ method: 'GET',
547
+ url: '/',
548
+ headers: {
549
+ host: 'localhost:3000',
550
+ connection: 'keep-alive',
551
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
552
+ },
553
+ remoteAddress: '::ffff:127.0.0.1',
554
+ remotePort: 58022
555
+ }
556
+ })
557
+ const { req } = await once(stream, 'data')
558
+ equal(req, '[Redacted]')
559
+ })
560
+
561
+ test('redact – supports top level wildcard and leading wildcard', async ({ equal }) => {
562
+ const stream = sink()
563
+ const instance = pino({ redact: ['*', '*.req'] }, stream)
564
+ instance.info({
565
+ req: {
566
+ id: 7915,
567
+ method: 'GET',
568
+ url: '/',
569
+ headers: {
570
+ host: 'localhost:3000',
571
+ connection: 'keep-alive',
572
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
573
+ },
574
+ remoteAddress: '::ffff:127.0.0.1',
575
+ remotePort: 58022
576
+ }
577
+ })
578
+ const { req } = await once(stream, 'data')
579
+ equal(req, '[Redacted]')
580
+ })
581
+
582
+ test('redact – supports intermediate wildcard paths', async ({ equal }) => {
583
+ const stream = sink()
584
+ const instance = pino({ redact: ['req.*.cookie'] }, stream)
585
+ instance.info({
586
+ req: {
587
+ id: 7915,
588
+ method: 'GET',
589
+ url: '/',
590
+ headers: {
591
+ host: 'localhost:3000',
592
+ connection: 'keep-alive',
593
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
594
+ },
595
+ remoteAddress: '::ffff:127.0.0.1',
596
+ remotePort: 58022
597
+ }
598
+ })
599
+ const { req } = await once(stream, 'data')
600
+ equal(req.headers.cookie, '[Redacted]')
601
+ })
602
+
603
+ test('redacts numbers at the top level', async ({ equal }) => {
604
+ const stream = sink()
605
+ const instance = pino({ redact: ['id'] }, stream)
606
+ const obj = {
607
+ id: 7915
608
+ }
609
+ instance.info(obj)
610
+ const o = await once(stream, 'data')
611
+ equal(o.id, '[Redacted]')
612
+ })
613
+
614
+ test('redacts booleans at the top level', async ({ equal }) => {
615
+ const stream = sink()
616
+ const instance = pino({ redact: ['maybe'] }, stream)
617
+ const obj = {
618
+ maybe: true
619
+ }
620
+ instance.info(obj)
621
+ const o = await once(stream, 'data')
622
+ equal(o.maybe, '[Redacted]')
623
+ })
624
+
625
+ test('redacts strings at the top level', async ({ equal }) => {
626
+ const stream = sink()
627
+ const instance = pino({ redact: ['s'] }, stream)
628
+ const obj = {
629
+ s: 's'
630
+ }
631
+ instance.info(obj)
632
+ const o = await once(stream, 'data')
633
+ equal(o.s, '[Redacted]')
634
+ })
635
+
636
+ test('does not redact primitives if not objects', async ({ equal }) => {
637
+ const stream = sink()
638
+ const instance = pino({ redact: ['a.b'] }, stream)
639
+ const obj = {
640
+ a: 42
641
+ }
642
+ instance.info(obj)
643
+ const o = await once(stream, 'data')
644
+ equal(o.a, 42)
645
+ })
646
+
647
+ test('redacts null at the top level', async ({ equal }) => {
648
+ const stream = sink()
649
+ const instance = pino({ redact: ['n'] }, stream)
650
+ const obj = {
651
+ n: null
652
+ }
653
+ instance.info(obj)
654
+ const o = await once(stream, 'data')
655
+ equal(o.n, '[Redacted]')
656
+ })
657
+
658
+ test('supports bracket notation', async ({ equal }) => {
659
+ const stream = sink()
660
+ const instance = pino({ redact: ['a["b.b"]'] }, stream)
661
+ const obj = {
662
+ a: { 'b.b': 'c' }
663
+ }
664
+ instance.info(obj)
665
+ const o = await once(stream, 'data')
666
+ equal(o.a['b.b'], '[Redacted]')
667
+ })
668
+
669
+ test('supports bracket notation with further nesting', async ({ equal }) => {
670
+ const stream = sink()
671
+ const instance = pino({ redact: ['a["b.b"].c'] }, stream)
672
+ const obj = {
673
+ a: { 'b.b': { c: 'd' } }
674
+ }
675
+ instance.info(obj)
676
+ const o = await once(stream, 'data')
677
+ equal(o.a['b.b'].c, '[Redacted]')
678
+ })
679
+
680
+ test('supports bracket notation with empty string as path segment', async ({ equal }) => {
681
+ const stream = sink()
682
+ const instance = pino({ redact: ['a[""].c'] }, stream)
683
+ const obj = {
684
+ a: { '': { c: 'd' } }
685
+ }
686
+ instance.info(obj)
687
+ const o = await once(stream, 'data')
688
+ equal(o.a[''].c, '[Redacted]')
689
+ })
690
+
691
+ test('supports leading bracket notation (single quote)', async ({ equal }) => {
692
+ const stream = sink()
693
+ const instance = pino({ redact: ['[\'a.a\'].b'] }, stream)
694
+ const obj = {
695
+ 'a.a': { b: 'c' }
696
+ }
697
+ instance.info(obj)
698
+ const o = await once(stream, 'data')
699
+ equal(o['a.a'].b, '[Redacted]')
700
+ })
701
+
702
+ test('supports leading bracket notation (double quote)', async ({ equal }) => {
703
+ const stream = sink()
704
+ const instance = pino({ redact: ['["a.a"].b'] }, stream)
705
+ const obj = {
706
+ 'a.a': { b: 'c' }
707
+ }
708
+ instance.info(obj)
709
+ const o = await once(stream, 'data')
710
+ equal(o['a.a'].b, '[Redacted]')
711
+ })
712
+
713
+ test('supports leading bracket notation (backtick quote)', async ({ equal }) => {
714
+ const stream = sink()
715
+ const instance = pino({ redact: ['[`a.a`].b'] }, stream)
716
+ const obj = {
717
+ 'a.a': { b: 'c' }
718
+ }
719
+ instance.info(obj)
720
+ const o = await once(stream, 'data')
721
+ equal(o['a.a'].b, '[Redacted]')
722
+ })
723
+
724
+ test('supports leading bracket notation (single-segment path)', async ({ equal }) => {
725
+ const stream = sink()
726
+ const instance = pino({ redact: ['[`a.a`]'] }, stream)
727
+ const obj = {
728
+ 'a.a': { b: 'c' }
729
+ }
730
+ instance.info(obj)
731
+ const o = await once(stream, 'data')
732
+ equal(o['a.a'], '[Redacted]')
733
+ })
734
+
735
+ test('supports leading bracket notation (single-segment path, wildcard)', async ({ equal }) => {
736
+ const stream = sink()
737
+ const instance = pino({ redact: ['[*]'] }, stream)
738
+ const obj = {
739
+ 'a.a': { b: 'c' }
740
+ }
741
+ instance.info(obj)
742
+ const o = await once(stream, 'data')
743
+ equal(o['a.a'], '[Redacted]')
744
+ })
745
+
746
+ test('child bindings are redacted using wildcard path', async ({ equal }) => {
747
+ const stream = sink()
748
+ const instance = pino({ redact: ['*.headers.cookie'] }, stream)
749
+ instance.child({
750
+ req: {
751
+ method: 'GET',
752
+ url: '/',
753
+ headers: {
754
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
755
+ }
756
+ }
757
+ }).info('message completed')
758
+ const { req } = await once(stream, 'data')
759
+ equal(req.headers.cookie, '[Redacted]')
760
+ })
761
+
762
+ test('child bindings are redacted using wildcard and plain path keys', async ({ equal }) => {
763
+ const stream = sink()
764
+ const instance = pino({ redact: ['req.method', '*.headers.cookie'] }, stream)
765
+ instance.child({
766
+ req: {
767
+ method: 'GET',
768
+ url: '/',
769
+ headers: {
770
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
771
+ }
772
+ }
773
+ }).info('message completed')
774
+ const { req } = await once(stream, 'data')
775
+ equal(req.headers.cookie, '[Redacted]')
776
+ equal(req.method, '[Redacted]')
777
+ })
778
+
779
+ test('redacts boolean at the top level', async ({ equal }) => {
780
+ const stream = sink()
781
+ const instance = pino({ redact: ['msg'] }, stream)
782
+ const obj = {
783
+ s: 's'
784
+ }
785
+ instance.info(obj, true)
786
+ const o = await once(stream, 'data')
787
+ equal(o.s, 's')
788
+ equal(o.msg, '[Redacted]')
789
+ })
790
+
791
+ test('child can customize redact', async ({ equal }) => {
792
+ const stream = sink()
793
+ const instance = pino({ redact: ['req.method', '*.headers.cookie'] }, stream)
794
+ instance.child({
795
+ req: {
796
+ method: 'GET',
797
+ url: '/',
798
+ headers: {
799
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
800
+ }
801
+ }
802
+ }, {
803
+ redact: ['req.url']
804
+ }).info('message completed')
805
+ const { req } = await once(stream, 'data')
806
+ equal(req.headers.cookie, 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;')
807
+ equal(req.method, 'GET')
808
+ equal(req.url, '[Redacted]')
809
+ })
810
+
811
+ test('child can remove parent redact by array', async ({ equal }) => {
812
+ const stream = sink()
813
+ const instance = pino({ redact: ['req.method', '*.headers.cookie'] }, stream)
814
+ instance.child({
815
+ req: {
816
+ method: 'GET',
817
+ url: '/',
818
+ headers: {
819
+ cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
820
+ }
821
+ }
822
+ }, {
823
+ redact: []
824
+ }).info('message completed')
825
+ const { req } = await once(stream, 'data')
826
+ equal(req.headers.cookie, 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;')
827
+ equal(req.method, 'GET')
828
+ })
829
+
830
+ test('redact safe stringify', async ({ equal }) => {
831
+ const stream = sink()
832
+ const instance = pino({ redact: { paths: ['that.secret'] } }, stream)
833
+
834
+ instance.info({
835
+ that: {
836
+ secret: 'please hide me',
837
+ myBigInt: 123n
838
+ },
839
+ other: {
840
+ mySecondBigInt: 222n
841
+ }
842
+ })
843
+ const { that, other } = await once(stream, 'data')
844
+ equal(that.secret, '[Redacted]')
845
+ equal(that.myBigInt, 123)
846
+ equal(other.mySecondBigInt, 222)
847
+ })