Repository navigation
Commit b3db5ef
committed
fix(sleep): contain staging paths, harden run launcher, type config writes
Addresses three review findings on the dashboard.
* Staging path containment. `os.path.basename` is not containment:
`basename("..")` is `".."`, so `/api/night/..` resolved to the staging
parent and `/api/adopt` would have handed that directory to
adopt_staging, copying whatever it found over the live SKILL.md and
CLAUDE.md. Both endpoints now share `_night_dir`, which percent-decodes
first, rejects anything that is not a plain single path component, and
then confirms the *resolved* path is still under the staging root — so a
symlink or junction planted inside staging cannot redirect the read
either. Non-string `ts` values are rejected rather than stringified.
* Run launcher resilience. A failing `subprocess.Popen` raised straight
out of the request-handler thread, dropping the connection and leaving
the UI waiting; it now returns {ok: false, error} and the launcher stays
usable. The parent also closes its own copy of the log descriptor after
spawning instead of relying on refcounting to release it, which on
Windows kept the file locked.
* Config value typing. The editor declared fields as "number" but rendered
every one as `type="text"` (a no-op ternary) and decided what to coerce
by matching a regex against the *label text* — so renaming a label would
silently start writing strings into config.json, and `load_config` does
not type-coerce. Fields now declare a kind (text/select/bool/int/float),
rendering and parsing both key off that kind, and the server validates
independently in `_coerce_config_value` against the type of each built-in
default, since the client is not the only possible caller. A value that
cannot be coerced is a 400 and nothing is written, so a bad field cannot
half-apply a form. Free text is no longer coerced: "true" in the house
rules stays the string "true".
Adds 12 tests: traversal and link-escape attempts on both endpoints
(asserting nothing was adopted, with a junction fallback so the link case
runs on unprivileged Windows too), spawn-failure handling and log-handle
release, and config typing including the partial-write and free-text cases.1 parent 3f23736 commit b3db5ef
3 files changed
Lines changed: 305 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
533 | 533 | | |
534 | 534 | | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
535 | 538 | | |
536 | 539 | | |
537 | 540 | | |
538 | 541 | | |
539 | 542 | | |
540 | | - | |
541 | | - | |
542 | | - | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
543 | 550 | | |
544 | | - | |
| 551 | + | |
545 | 552 | | |
546 | 553 | | |
547 | 554 | | |
548 | 555 | | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
549 | 567 | | |
550 | 568 | | |
| 569 | + | |
551 | 570 | | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
556 | 574 | | |
| 575 | + | |
557 | 576 | | |
558 | 577 | | |
559 | 578 | | |
560 | 579 | | |
| 580 | + | |
561 | 581 | | |
562 | 582 | | |
563 | 583 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
96 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
97 | 138 | | |
98 | 139 | | |
| 140 | + | |
| 141 | + | |
99 | 142 | | |
100 | 143 | | |
101 | 144 | | |
102 | 145 | | |
103 | | - | |
104 | | - | |
| 146 | + | |
105 | 147 | | |
106 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
107 | 152 | | |
108 | 153 | | |
109 | 154 | | |
| |||
158 | 203 | | |
159 | 204 | | |
160 | 205 | | |
161 | | - | |
162 | | - | |
| 206 | + | |
| 207 | + | |
163 | 208 | | |
164 | | - | |
165 | 209 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
170 | 225 | | |
171 | 226 | | |
172 | 227 | | |
| |||
181 | 236 | | |
182 | 237 | | |
183 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
184 | 273 | | |
185 | 274 | | |
186 | 275 | | |
| |||
342 | 431 | | |
343 | 432 | | |
344 | 433 | | |
345 | | - | |
346 | | - | |
347 | | - | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
348 | 437 | | |
349 | 438 | | |
350 | 439 | | |
| |||
378 | 467 | | |
379 | 468 | | |
380 | 469 | | |
381 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
382 | 475 | | |
383 | 476 | | |
384 | 477 | | |
| |||
395 | 488 | | |
396 | 489 | | |
397 | 490 | | |
398 | | - | |
399 | | - | |
400 | | - | |
| 491 | + | |
| 492 | + | |
401 | 493 | | |
402 | 494 | | |
403 | 495 | | |
| |||
0 commit comments