@bymax-one/nest-logger 1.4.27 → 1.4.29
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 +80 -1
- package/README.md +16 -14
- package/dist/server/index.cjs +260 -105
- package/dist/server/index.mjs +260 -105
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,83 @@ heading here.
|
|
|
12
12
|
|
|
13
13
|
## [Unreleased]
|
|
14
14
|
|
|
15
|
+
## [1.4.29] - 2026-11-21
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **Only the key `message` is left to the serializer of `err`.** A field of the object under `err` that
|
|
20
|
+
only spells it (`Message`, a zero-width character inside it, a look-alike letter) is a field like any
|
|
21
|
+
other and is hidden when `message` is a name to hide.
|
|
22
|
+
- **A configured name hides a field however its key is spelled.** The names of `redactPaths`, the
|
|
23
|
+
default names and the leaves of a configured path were compared with a key by exact name, in lower
|
|
24
|
+
case, so a field spelled with a zero-width character, a soft hyphen, a byte order mark, fullwidth
|
|
25
|
+
letters, a no-break space, a tab, a trailing space, a Cyrillic letter, a combining mark, a dotless
|
|
26
|
+
`i` or a separator (`api_key`, `api.Key`) was written in clear under `redactStrategy: 'names'`. Both
|
|
27
|
+
sides are now folded with the folding the library's own keys use (separators folded too), also for the
|
|
28
|
+
header names of a flat `rawHeaders` array. A name that is another word (`apiKeys` for `apiKey`) is
|
|
29
|
+
still another name. Every character that is not a letter or a digit is dropped from both sides (so
|
|
30
|
+
`x\u2011api\u2011key`, `access\u2010token`, `api\u2212key` and `pass:word` are `xapikey`, `accesstoken`, `apikey`
|
|
31
|
+
and `password`), and every letter that is not ASCII and that the look-alike list does not read as one Latin letter
|
|
32
|
+
stands for one or for two letters of a name (`ß`, `ꜷ` and `ꝏ` are two; a capital Cyrillic or Greek i,
|
|
33
|
+
drawn like an `I` and an `l`, is one): a key with such letters is hidden by any name it matches
|
|
34
|
+
everywhere else, which can hide the value of a key that only shares a name's ASCII letters and a
|
|
35
|
+
compatible length. The rule holds for a key made only of letters of another script too, as long as it
|
|
36
|
+
is no longer than the longest name: a spelling of `token` in Cyrillic and Armenian letters is hidden,
|
|
37
|
+
and so is a short field written in words of another script, which is the price of never letting a
|
|
38
|
+
spelling through. A key longer than every name is never taken for one (a configured name written in
|
|
39
|
+
that script still matches itself exactly), and a key with more candidate names of a compatible length
|
|
40
|
+
than a bound is hidden without being compared. This is for hiding a value only: the keys the entry owns, the keys
|
|
41
|
+
its derived fields use and the keys of the mixin are compared exactly after folding, so a caller
|
|
42
|
+
field written with such letters is not dropped for resembling one of them. Under `redactStrategy: 'paths'` the paths are matched exactly by `fast-redact`
|
|
43
|
+
and are not folded.
|
|
44
|
+
- **The stack header is hidden against every key that spells `message` or `stack`.** An object with
|
|
45
|
+
`{ message: 'x', Message: secret, stack: 'Error: secret' }`, or a `stack` beside a `Stack`, kept the
|
|
46
|
+
secret in a header: only the first key that spelled the name was read. Every one is read, once, and
|
|
47
|
+
every distinct text is hidden in every stack, longest first. The 1.4.27 line "whatever the case or
|
|
48
|
+
the look of the two keys" held for a single key of each name only.
|
|
49
|
+
- **More characters that print as nothing, and more letters and dots drawn like another, are read
|
|
50
|
+
through:** the Hangul fillers and the blank Braille pattern, the characters drawn like a full stop
|
|
51
|
+
(`U+3002`, `U+00B7`, `U+22C5` and others) and a few more letters drawn like a Latin one, in the
|
|
52
|
+
comparison of the derived keys, of the owned keys and of the configured names. The list of drawn
|
|
53
|
+
letters is a list, not every look-alike Unicode has.
|
|
54
|
+
- **A message the options hide is hidden wherever a stack repeats it.** Only the header of a stack was
|
|
55
|
+
rewritten, so a library that appends `Caused by: Error: <message>` left the text readable in the first
|
|
56
|
+
16 KiB of `err.stack`, of the stack of a cause and of `exception.stacktrace`. Every occurrence of the
|
|
57
|
+
message in the part of the stack that is read is replaced now, for an `Error`, an `Error` whose name is
|
|
58
|
+
not text, a cause and an object that is no `Error`. A message short enough to appear in a frame is
|
|
59
|
+
replaced there too.
|
|
60
|
+
- **The `stack` of an object that is no `Error` is bounded and scrubbed at any depth.** A nested plain
|
|
61
|
+
object with a `stack` was written whole, up to its full length and with its dependency frames and
|
|
62
|
+
control characters. It is read up to the same bound as the stack of an error, written without
|
|
63
|
+
`node_modules` frames and with control characters escaped, and cut at the text limit with the suffix.
|
|
64
|
+
The name and the message of such an object are still written as given.
|
|
65
|
+
- **The search for hidden messages in the stacks of one object is bounded.** An object with more than
|
|
66
|
+
eight distinct messages under keys that spell `message`, or more than eight keys that spell `stack`,
|
|
67
|
+
has every stack written as the censor instead of searched, so a payload of thousands of look-alike
|
|
68
|
+
keys cannot stall the event loop.
|
|
69
|
+
- **A list option whose length is not a count is refused.** A Proxy that reports `-1`, `NaN`, `1.5` or
|
|
70
|
+
an infinite length was read as empty; it is refused by the name of the option.
|
|
71
|
+
- **A list option is capped at 10,000 entries.** `redactPaths`, `errorOwnFieldNames`, `destinations`,
|
|
72
|
+
`http.excludePaths` and `http.secretPathSegments` longer than that are refused at startup, by the
|
|
73
|
+
name of the option, before an element is read; a length a host reports as a billion no longer
|
|
74
|
+
allocates.
|
|
75
|
+
|
|
76
|
+
## [1.4.28] - 2026-11-21
|
|
77
|
+
|
|
78
|
+
### Fixed
|
|
79
|
+
|
|
80
|
+
- The options are read once: the snapshot that passes validation is the one the defaults are made from,
|
|
81
|
+
including the `service` metadata, each list (`redactPaths`, `errorOwnFieldNames`, `destinations`,
|
|
82
|
+
`http.excludePaths`, `http.secretPathSegments`, read element by element) and the `serializers` table.
|
|
83
|
+
A getter or a Proxy that answered differently on a second read could pass the validator and then
|
|
84
|
+
change, and the module builder now receives the same copy.
|
|
85
|
+
- The derived keys (`exception.type` and the others) are compared with the same folding as the other
|
|
86
|
+
owned keys, with the separators kept: a variation selector, a line or paragraph separator, a
|
|
87
|
+
combining mark or a lookalike letter no longer lets a spelling of them through; `exception_type`,
|
|
88
|
+
`exceptionType` and `errorType` are still the caller's.
|
|
89
|
+
- Searching the stack of an error whose `name` is not text for its message is bounded by the part of
|
|
90
|
+
the stack the scrub reads, and nothing beyond that part is kept.
|
|
91
|
+
|
|
15
92
|
## [1.4.27] - 2026-11-21
|
|
16
93
|
|
|
17
94
|
### Fixed
|
|
@@ -3392,7 +3469,9 @@ published `dist/` is identical — no runtime behaviour changes for consumers.
|
|
|
3392
3469
|
- Professional CI suite: `ci.yml`, `bench.yml`, `codeql.yml`, `scorecard.yml`,
|
|
3393
3470
|
`release.yml`, Dependabot, and issue templates
|
|
3394
3471
|
|
|
3395
|
-
[Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.
|
|
3472
|
+
[Unreleased]: https://github.com/bymaxone/nest-logger/compare/v1.4.29...HEAD
|
|
3473
|
+
[1.4.29]: https://github.com/bymaxone/nest-logger/compare/v1.4.28...v1.4.29
|
|
3474
|
+
[1.4.28]: https://github.com/bymaxone/nest-logger/compare/v1.4.27...v1.4.28
|
|
3396
3475
|
[1.4.27]: https://github.com/bymaxone/nest-logger/compare/v1.4.26...v1.4.27
|
|
3397
3476
|
[1.4.26]: https://github.com/bymaxone/nest-logger/compare/v1.4.25...v1.4.26
|
|
3398
3477
|
[1.4.25]: https://github.com/bymaxone/nest-logger/compare/v1.4.24...v1.4.25
|
package/README.md
CHANGED
|
@@ -879,7 +879,7 @@ The library censors **62 sensitive field names** wherever they appear in a recor
|
|
|
879
879
|
| Other spellings | `access_token`, `refresh_token`, `id_token`, `api_key`, `apikey`, `api_secret`, `client_secret`, `signing_secret`, `private_key`, `secret_key`, `secretKey`, `access-token`, `refresh-token`, `id-token`, `api-key`, `client-secret`, `private-key`, `proxy-authorization`, `session_token`, `sessionToken`, `sessiontoken`, `session-token`, `x-csrf-token`, `x-xsrf-token`, `csrf_token`, `csrfToken`, `csrf-token`, `password_hash`, `new_password`, `old_password` |
|
|
880
880
|
| HTTP headers (absolute) | `req.headers.authorization`, `req.headers.cookie`, `req.headers["x-api-key"]`, `req.headers["x-auth-token"]`, `res.headers["set-cookie"]` — retained for the legacy `'paths'` strategy; the by-name row above already covers these shapes and every other |
|
|
881
881
|
|
|
882
|
-
Redaction is one **recursive, snapshotting walk**: a value is censored when its key name is in the set, wherever it sits. Nothing the caller passed is mutated, and every value is read once and pinned into a fresh structure, so what reaches the sink is what was inspected even when the payload carries accessors or a `toJSON` that could answer differently on a second read. A value with a `toJSON` is inspected through that method's output; when the source object itself carries a sensitive key, the method is not trusted and the whole value is censored, because a method could rename what it exposes. `DEFAULT_REDACT_PATHS` is still exported at full fidelity, and `redactStrategy: 'paths'` feeds it to `fast-redact` for anyone depending on exact path semantics, with a four-level ceiling and a much higher cost.
|
|
882
|
+
Redaction is one **recursive, snapshotting walk**: a value is censored when its key name is in the set, wherever it sits. A name and a key are compared in one folded form: the case, every character that is not a letter or a digit (the separators `_`, `.` and `-` and every other dash, mark and punctuation), white space, control and zero-width characters, combining marks, the compatibility forms Unicode defines and a list of letters drawn like a Latin one are read through, and a letter that is not ASCII and that the list does not read as one Latin letter stands for one or two letters (in a key no longer than the longest name; a key longer than every name is never taken for one, so a field of another script is hidden when it is short, which is the price of never letting a spelling of a name through, and kept when it is long), so a key that has one is hidden by a name it matches everywhere else; the keys the entry owns are compared exactly after folding, so a caller field is never dropped for looking like one, so a key that has one is hidden by a name of a compatible length that matches it everywhere else (`autһorization` is hidden by `authorization`, and a key of the same length that only shares its ASCII letters is hidden too), so `apiKey` also hides `api_key`, `API-KEY`, `api\u200bKey` and `\u0430piKey`, and a name hides the field however an untrusted payload spells it. A key that spells a configured name another way is the same name, so a field whose name only differs in those ways is hidden too. Under `redactStrategy: 'paths'` the paths are matched exactly by `fast-redact`: literally, with no folding of case, separators or look-alikes, and none of this applies. Nothing the caller passed is mutated, and every value is read once and pinned into a fresh structure, so what reaches the sink is what was inspected even when the payload carries accessors or a `toJSON` that could answer differently on a second read. A value with a `toJSON` is inspected through that method's output; when the source object itself carries a sensitive key, the method is not trusted and the whole value is censored, because a method could rename what it exposes. `DEFAULT_REDACT_PATHS` is still exported at full fidelity, and `redactStrategy: 'paths'` feeds it to `fast-redact` for anyone depending on exact path semantics, with a four-level ceiling and a much higher cost.
|
|
883
883
|
|
|
884
884
|
> [!NOTE]
|
|
885
885
|
> A bare `sessionId`, `session_id` or `session-id` is **not** on the list: many applications carry one as a correlation key, and a name cannot be switched off one at a time. A session id that is itself a bearer credential in your system must be added to your own `redactPaths` (`redactPaths: ['sessionId']` censors it at any depth under the default strategy).
|
|
@@ -1066,7 +1066,7 @@ Implements NestJS `LoggerService`. All methods are available via `@InjectLogger(
|
|
|
1066
1066
|
| `fatal` | `(message, ...optionalParams)` | → Pino `fatal` |
|
|
1067
1067
|
| `error` | `(message \| Error, stack?, context?)` | An `Error` routes to the serialized `err` path |
|
|
1068
1068
|
|
|
1069
|
-
**An object as the message.** A plain object (an object literal or a parsed JSON object) passed as the message of `log`, `warn`, `error`, `debug`, `verbose` or `fatal` is written as the fields of the entry, through the same redaction and `maxStringLength` pipeline as any other field, so `this.logger.warn({ event: 'QUEUE_DRAINED', jobs: 7, password })` gives an entry with `event`, `jobs` and a censored `password`. The entry text (`msg`) is its `message` string, else its `event` string, else empty; a `message` that is the text is not repeated as a field. `logKey`, `userId`, `context`, `level`, `time`, `msg`, `service`, `service.*`, `deployment` and `deployment.*` in the object are dropped, as they are from `meta`. The text is censored under the names of the field it came from (`event` or `message`), also with `redactStrategy: 'paths'`, and cut at `maxStringLength` like that field, within the 16 KiB cap that bounds every log message. A serializer keyed `event` or `message` shapes the field and not `msg`; redaction by name is what covers the text. An `Error`, and an object shaped like one (a string `name` and a string `message`), keep their own error-only path (the text of the entry is the `message`, censored under the name `message` as `err.message` is, and the same text is censored where it opens `err.stack`, the stack of each cause and `exception.stacktrace`, and in `exception.message`; like every log message it is capped at 16 KiB and not cut at `maxStringLength`), and a value that is not plain (a class instance, an array) is still written as its string form. An object that is no error to the library but carries a `message` and a `stack` that are text has the message hidden in the header of that `stack`, everything before its first frame, wherever the options hide `message`; the
|
|
1069
|
+
**An object as the message.** A plain object (an object literal or a parsed JSON object) passed as the message of `log`, `warn`, `error`, `debug`, `verbose` or `fatal` is written as the fields of the entry, through the same redaction and `maxStringLength` pipeline as any other field, so `this.logger.warn({ event: 'QUEUE_DRAINED', jobs: 7, password })` gives an entry with `event`, `jobs` and a censored `password`. The entry text (`msg`) is its `message` string, else its `event` string, else empty; a `message` that is the text is not repeated as a field. `logKey`, `userId`, `context`, `level`, `time`, `msg`, `service`, `service.*`, `deployment` and `deployment.*` in the object are dropped, as they are from `meta`. The text is censored under the names of the field it came from (`event` or `message`), also with `redactStrategy: 'paths'`, and cut at `maxStringLength` like that field, within the 16 KiB cap that bounds every log message. A serializer keyed `event` or `message` shapes the field and not `msg`; redaction by name is what covers the text. An `Error`, and an object shaped like one (a string `name` and a string `message`), keep their own error-only path (the text of the entry is the `message`, censored under the name `message` as `err.message` is, and the same text is censored where it opens `err.stack`, the stack of each cause and `exception.stacktrace`, and in `exception.message`; like every log message it is capped at 16 KiB and not cut at `maxStringLength`), and a value that is not plain (a class instance, an array) is still written as its string form. An object that is no error to the library but carries a `message` and a `stack` that are text has the message hidden in the header of that `stack`, everything before its first frame, wherever the options hide `message`; the message is hidden wherever the stack repeats it (a `Caused by:` line, a frame), within the part of the stack that is read, and this holds for such an object below the top level of the record as well. The `stack` of any object that is no `Error`, at any depth, is written like the stack of an error: without dependency frames, with control characters escaped and cut at the text limit. An object with more than eight distinct messages under keys that spell `message`, or more than eight keys that spell `stack`, has every stack written as the censor. A `name` that is an object, an array or a function is hidden with the message, as it may carry anything, and a number `name` is kept. The keys the library owns (`exception.type`, `exception.message`, `exception.stacktrace`, `error.type`) are matched as they look in a viewer: the same key in another case, with white space, combining marks, zero-width characters or characters that print as nothing inside it, in fullwidth letters, or with a letter of another script drawn like a Latin one is dropped too, while `errorType`, `exception_type`, `exceptionType` and `event.name` are other keys and are kept. An object whose `toJSON` returns a `message` that is not text and a `stack` carrying a secret that is not the message text leaves nothing to match, so name such a secret in `redactPaths`. Redaction works on field names and never reads the content of a string, so a text a caller passes as a string, such as ``logger.warn(`card ${number}`)``, is written as it is.
|
|
1070
1070
|
|
|
1071
1071
|
**Helpers**
|
|
1072
1072
|
|
|
@@ -1237,18 +1237,20 @@ Two kinds of failure, and they surface differently. A **thrown `Error`** carries
|
|
|
1237
1237
|
|
|
1238
1238
|
### Thrown errors
|
|
1239
1239
|
|
|
1240
|
-
| Message starts with | Thrown from | When
|
|
1241
|
-
| -------------------------------------------------------- | ------------------------------------------- |
|
|
1242
|
-
| `[BymaxLoggerModule] options.` | `forRoot` / `forRootAsync`, at module setup | any option fails validation: a missing `service`, a `level` outside the set, a bad type
|
|
1243
|
-
| `[BymaxLoggerModule] options could not be read` | `forRoot` / `forRootAsync`, at module setup | an option the host supplies threw when it was read (a getter or a Proxy trap)
|
|
1244
|
-
| `
|
|
1245
|
-
| `
|
|
1246
|
-
| `[BymaxLoggerModule]
|
|
1247
|
-
| `[
|
|
1248
|
-
| `[
|
|
1249
|
-
| `[PrettyDevDestination]
|
|
1250
|
-
| `[
|
|
1251
|
-
| `[
|
|
1240
|
+
| Message starts with | Thrown from | When | Action |
|
|
1241
|
+
| -------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
|
|
1242
|
+
| `[BymaxLoggerModule] options.` | `forRoot` / `forRootAsync`, at module setup | any option fails validation: a missing `service`, a `level` outside the set, a bad type | Fix the option the message names; it prints the path and what it received |
|
|
1243
|
+
| `[BymaxLoggerModule] options could not be read` | `forRoot` / `forRootAsync`, at module setup | an option the host supplies threw when it was read (a getter or a Proxy trap) | Fix the option; the error the host threw is the `cause` |
|
|
1244
|
+
| `holds more than` | `forRoot` / `forRootAsync`, at module setup | a list option (`redactPaths`, `errorOwnFieldNames`, `destinations`, `http.excludePaths`, `http.secretPathSegments`) is longer than 10,000 entries | Shorten the list; it is refused before any element is read |
|
|
1245
|
+
| `has a length that is not a count` | `forRoot` / `forRootAsync`, at module setup | a list option reports a length that is negative, fractional, `NaN` or infinite (a Proxy; an array never does) | Fix the option; it is refused before any element is read |
|
|
1246
|
+
| `[BymaxLoggerModule] useNestLogger(app) called but` | `BymaxLoggerModule.useNestLogger` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
|
|
1247
|
+
| `[BymaxLoggerModule] applyAccessLog(app) called but` | `applyAccessLog` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
|
|
1248
|
+
| `[BymaxLoggerModule] useRequestContext(app) called but` | `useRequestContext` | the module was never imported into the application | Import `BymaxLoggerModule` before calling it |
|
|
1249
|
+
| `[PrettyDevDestination] pino-pretty is not installed` | `PrettyDevDestination.onInit` | the destination is registered and resolving `pino-pretty` itself fails | Install `pino-pretty` or drop the destination |
|
|
1250
|
+
| `[PrettyDevDestination] pino-pretty failed to start` | `PrettyDevDestination.onInit` | `pino-pretty` is found but importing it or building the transform throws | Read the message and the error's `cause`: it is the real failure |
|
|
1251
|
+
| `[PrettyDevDestination] refused in production` | `PrettyDevDestination.onInit` | `NODE_ENV` is exactly `production` | Use `DefaultStdoutDestination` in production |
|
|
1252
|
+
| `[LogContextService] set() called outside run() scope` | `LogContextService.set` | called with no active `run()` | Wrap the work in `logContext.run({ ... }, () => ...)` |
|
|
1253
|
+
| `[LogContextService] Refusing to set unsafe context key` | `LogContextService.set` | the key is `__proto__`, `constructor` or `prototype` | Use an ordinary key |
|
|
1252
1254
|
|
|
1253
1255
|
The `PrettyDevDestination` errors are thrown inside `onInit`, which the registry contains: the boot continues and the failure is reported as `LOGGER_DESTINATION_INIT_FAILED` below.
|
|
1254
1256
|
|