Commit 8d6db2d
committed
refactor: one adapter core, so a fifth copy cannot drift
Express, Fastify, Next.js (twice — the middleware and the Pages wrapper)
and the fetch guard each carried their own copy of the same decisions:
skip-path matching, the 429 payload, the 403 payload, honeytoken arming.
Five copies of one set of rules.
Not a tidiness complaint. The leftmost-X-Forwarded-For bug survived in two
adapters after the same class had been fixed elsewhere, precisely because
there was no one place to fix. Every copy is a place the next correction
can fail to land, and each reads sensibly on its own, which is why review
does not catch it.
adapter-core.ts holds the decisions. The adapters keep the I/O, which
differs genuinely: Express intercepts res.write/res.end, Fastify uses an
onSend hook, a fetch handler rebuilds a Response, and the detail in each
is hard-won.
Fastify keeps its awaited arming. It derives during plugin registration,
which is already an async boot phase, so it has no window where early
requests are served without the link -- forcing it onto the
fire-and-forget getter would have REGRESSED it. deriveAndArm() is the same
logic with the other timing, not a second implementation.
Every existing honeytoken-injection test passes unchanged, which was the
acceptance criterion: the response mechanics are untouched.
Three invariants stop the sixth copy, and writing them found a false
positive worth keeping: nextjs/honeytoken.ts derives a token without
arming, deliberately -- it is the render-side helper a layout calls, and
the developer arms in middleware from the same HMAC. A second caller, not
a second answer. Excluded with that reason rather than by loosening the
rule.
Closes WebDecoy/app#7391 parent ff61975 commit 8d6db2d
7 files changed
Lines changed: 296 additions & 228 deletions
File tree
- packages
- express/src
- fastify/src
- nextjs/src
- webdecoy/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | | - | |
16 | 14 | | |
17 | 15 | | |
18 | | - | |
19 | 16 | | |
20 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | 172 | | |
189 | 173 | | |
190 | 174 | | |
| |||
218 | 202 | | |
219 | 203 | | |
220 | 204 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
242 | 212 | | |
243 | 213 | | |
244 | 214 | | |
| |||
282 | 252 | | |
283 | 253 | | |
284 | 254 | | |
285 | | - | |
286 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
287 | 259 | | |
288 | 260 | | |
289 | 261 | | |
| |||
358 | 330 | | |
359 | 331 | | |
360 | 332 | | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
383 | 339 | | |
| 340 | + | |
| 341 | + | |
384 | 342 | | |
385 | 343 | | |
386 | 344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | | - | |
16 | 14 | | |
17 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | 157 | | |
173 | 158 | | |
174 | 159 | | |
| |||
235 | 220 | | |
236 | 221 | | |
237 | 222 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
251 | 229 | | |
252 | 230 | | |
253 | 231 | | |
| |||
305 | 283 | | |
306 | 284 | | |
307 | 285 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
330 | 292 | | |
| 293 | + | |
| 294 | + | |
331 | 295 | | |
332 | 296 | | |
333 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | 133 | | |
148 | 134 | | |
149 | 135 | | |
| |||
224 | 210 | | |
225 | 211 | | |
226 | 212 | | |
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 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
256 | 221 | | |
257 | 222 | | |
258 | 223 | | |
| |||
359 | 324 | | |
360 | 325 | | |
361 | 326 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
371 | 335 | | |
372 | 336 | | |
| 337 | + | |
373 | 338 | | |
374 | 339 | | |
375 | 340 | | |
| |||
0 commit comments