Commit e26085d
committed
fix(cli): address #612 review — fail-closed webhook pre-read + tests + nits
B1 (fail-open re-armed the clobber): the pre-read catch swallowed EVERY
GetSecretValue error and treated it as 'first install — nothing to preserve'.
That only holds for ResourceNotFoundException; for AccessDenied / KMSAccessDenied
/ Throttling / network / a corrupt bundle — all on a secret that EXISTS —
existingWebhookSecret stayed undefined → resolveWebhookSecretAction mirrors the
stack-wide (workspace #1's) secret over this workspace's real one, re-arming the
#611 401 clobber silently behind a green 'Setup complete'. Extracted the pre-read
into readExistingWebhookSecret() which FAILS CLOSED: only ResourceNotFound → 'none
to preserve'; a corrupt bundle (JSON.parse) or any other SM error propagates, and
setup re-throws an actionable CliError with an IAM/KMS hint (mirroring the sibling
isWebhookSecretConfigured).
B2 (fix was untested end-to-end): the 5 prior tests only exercised the pure
resolveWebhookSecretAction. Added 7 tests for readExistingWebhookSecret covering
the load-bearing seam — preserve-not-clobber, ResourceNotFound→undefined,
malformed/absent secret, and the fail-closed THROW on AccessDenied / KMS /
Throttling / corrupt JSON (the exact B1 path).
N1 (stale comment): the Step-6 header still described the REMOVED behavior ('the
stored value is this workspace's secret — lift it in'). Rewrote it to describe the
preserve → mirror-stackwide → prompt decision so a maintainer can't revert the fix.
N2 (double-write + failure window): fold the preserved secret into the INITIAL
bundle so the OAuth-secret write lands it in ONE PutSecretValue; the
preserve path skips the later re-write (guarded by !== stored.webhook_signing_secret).
Closes the window where a throw between the two writes left the bundle persisted
without the secret (401 until update-webhook-secret).
Full cli build green (616 tests).1 parent 45a770b commit e26085d
3 files changed
Lines changed: 149 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
609 | 610 | | |
610 | 611 | | |
611 | 612 | | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
612 | 620 | | |
613 | 621 | | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
623 | 641 | | |
624 | 642 | | |
625 | 643 | | |
| |||
635 | 653 | | |
636 | 654 | | |
637 | 655 | | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
638 | 664 | | |
639 | 665 | | |
640 | 666 | | |
| |||
696 | 722 | | |
697 | 723 | | |
698 | 724 | | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
707 | 740 | | |
708 | 741 | | |
709 | 742 | | |
| |||
759 | 792 | | |
760 | 793 | | |
761 | 794 | | |
762 | | - | |
763 | | - | |
764 | | - | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
765 | 800 | | |
766 | 801 | | |
767 | 802 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
314 | 315 | | |
315 | 316 | | |
316 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
0 commit comments