Commit 8c3b208
authored
refactor(log): source sensitive redaction lists from config as pure extensions (#3961)
* refactor(log): source sensitive redaction markers from config
lib/ must stay module-agnostic — SENSITIVE_PATH_MARKERS and
SENSITIVE_QUERY_KEYS in lib/helpers/redactUrl.js hardcoded auth/invitations
route vocabulary owned by feature modules (#3935). Move both lists to
config.log.sensitivePathMarkers / config.log.sensitiveQueryKeys (current
values as defaults in config/defaults/development.config.js) so a module
extends redaction coverage from its own config without editing shared lib/.
redactUrl.js reads the lists from config once at module load, falling back
to the built-in literals when config or the key is absent — redaction
degrades safely instead of silently redacting nothing in an edge context.
Exports/API unchanged (existing consumers: lib/middlewares/analytics.js,
lib/services/express.js).
Closes #3953
Claude-Session: https://claude.ai/code/session_01WfNC8bt1TgL4AsiYgCEGup
* fix(log): union config-provided redaction lists with built-in defaults
deepMerge replaces arrays (no union), so a module-level
config.log.sensitivePathMarkers/sensitiveQueryKeys extension clobbered
the global default instead of extending it, and a `??` fallback let an
explicit empty array silently disable redaction for that vector.
Compute the effective lists as a Set-deduped union of the built-in
DEFAULT_SENSITIVE_* base with config.log.*, so config is purely
additive from any layer and redaction can never be disabled via
config. development.config.js's entries become empty arrays (the
extension point), killing the literal duplication with redactUrl.js.
Claude-Session: https://claude.ai/code/session_01WfNC8bt1TgL4AsiYgCEGup
* fix(log): make redaction config extension layer-proof and shape-safe
Phase-0 iteration-2 review findings on #3953:
- Remove log.sensitivePathMarkers/sensitiveQueryKeys from
config/defaults/development.config.js. deepMerge (config/index.js)
replaces arrays wholesale, so declaring these as [] at Layer 2 (global
defaults) silently clobbered any Layer 1 (module config) extension of
the same key. Omitting the key lets a module value pass through
untouched; a comment documents the extension point.
- Guard redactUrl.js against non-array config values via a
sanitizeConfigList helper: an object/number would throw at
module-eval (boot crash), a string would spread char-by-char (silent
over-redaction). Malformed values now fall back to [] (defaults still
apply) and log a console.warn identifying the offending config path.
- Add malformed-value tests (object + string) and a lockstep guard test
pinning that development.config.js never re-declares either key.
Claude-Session: https://claude.ai/code/session_01WfNC8bt1TgL4AsiYgCEGup
* test(log): restore console.warn spy in finally to prevent mock leakage
Claude-Session: https://claude.ai/code/session_01WfNC8bt1TgL4AsiYgCEGup1 parent dffc577 commit 8c3b208
3 files changed
Lines changed: 202 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
84 | 100 | | |
85 | 101 | | |
86 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
1 | 41 | | |
2 | 42 | | |
3 | 43 | | |
4 | 44 | | |
5 | 45 | | |
6 | 46 | | |
7 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
8 | 55 | | |
9 | | - | |
| 56 | + | |
10 | 57 | | |
11 | 58 | | |
12 | 59 | | |
| |||
15 | 62 | | |
16 | 63 | | |
17 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
18 | 72 | | |
19 | | - | |
| 73 | + | |
20 | 74 | | |
21 | 75 | | |
22 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
113 | 114 | | |
114 | 115 | | |
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 | + | |
0 commit comments