Commit 59fdca5
authored
fix(cli): harden extension registration and discovery workflows (#2499)
* chore: update community catalog with latest extension versions
- Update memory-md from 0.7.9 to 0.8.0
- Update architecture-guard from 1.6.7 to 1.8.0
* fix(cli): harden extension registration with project-level tracking in extensions.yml
* test(cli): add comprehensive unit tests for extension registration logic
* chore: remove out-of-scope catalog changes
* refactor: address PR feedback for extension registration hardening
* fix: harden extension registration defensive logic and add comprehensive unregister_hooks tests
- Add dict guard to register_hooks() to handle corrupted extensions.yml (non-dict root)
- Add 5 comprehensive tests for unregister_hooks() workflow:
* Full workflow with hooks + installed list removal
* Resilience when config has no 'hooks' key
* Corrupted YAML handling
* Multiple extension scenarios
* All 11 tests passing
* fix: sanitize installed to strings, guard unregister_hooks dict, handle null hook values
- register_extension(): filter non-string entries from installed before sort
- register_hooks(): normalize hooks to {} when missing or not a dict
- unregister_hooks(): add isinstance(config, dict) guard before key checks
- unregister_hooks(): coerce null/scalar hook lists to [] before iteration
- tests: add 3 regression tests for no-hooks manifest, mixed-type installed, null hook values
- All 14 tests passing
* fix(cli): persist sanitization results and harden hook registration
* Harden extension registration to always persist sanitization results
* Hardening extension registration: support mapping entries, improve persistence, and fix update rollback
* fix(cli): harden extension update and unregistration workflows
* fix(cli): move update sentinels outside try block to prevent NameError on rollback
* fix(cli): sanitize hook event lists in register_hooks to prevent crashes
* fix(cli): deduplicate hook entries and harden rollback hooks-restore guards
* test(cli): add regression tests for extension update and rollback hardening
* fix(cli): deduplicate installed list by id in register_extension
* fix(cli): consolidate and harden extension update rollback logic
* fix(cli): initialize backup_registry_entry before try block to prevent UnboundLocalError on rollback
* fix(tests): return Path from download_extension mock and add Path import
* fix(cli): normalize get_project_config() return to dict; deduplicate in unregister_extension()
* fix(cli): normalize hooks/installed/settings in get_project_config(); use tmp_path-scoped zip in tests
* fix(cli): set modified=True on hook coercion in rollback; sanitize hook event values in get_project_config(); harden test assertions
* fix(cli): filter non-dict hook entries in get_project_config(); remove dead MISSING sentinel
* fix(cli): gate extensions.yml rollback on backup_hooks is not None; update stale comment
* fix(cli): move _AgentReg import outside try block; assert result.exception is None in tests
* fix(extensions): consistent key order in default config; deep-copy backup_installed
* test: fix misleading comment; assert exit_code==1 in rollback test
* test: clean up duplicate imports in hardening tests
* refactor(extensions): extract _sanitize_installed_list helper; strengthen hook unregister assertion
* fix(extensions): validate extension IDs in _sanitize_installed_list; clarify test comment1 parent 2fb9d3b commit 59fdca5
4 files changed
Lines changed: 846 additions & 60 deletions
File tree
- src/specify_cli
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4295 | 4295 | | |
4296 | 4296 | | |
4297 | 4297 | | |
| 4298 | + | |
| 4299 | + | |
| 4300 | + | |
| 4301 | + | |
4298 | 4302 | | |
4299 | 4303 | | |
4300 | 4304 | | |
| |||
4308 | 4312 | | |
4309 | 4313 | | |
4310 | 4314 | | |
4311 | | - | |
4312 | | - | |
| 4315 | + | |
| 4316 | + | |
| 4317 | + | |
4313 | 4318 | | |
4314 | 4319 | | |
4315 | 4320 | | |
| |||
4334 | 4339 | | |
4335 | 4340 | | |
4336 | 4341 | | |
4337 | | - | |
4338 | | - | |
| 4342 | + | |
4339 | 4343 | | |
4340 | 4344 | | |
4341 | 4345 | | |
| |||
4360 | 4364 | | |
4361 | 4365 | | |
4362 | 4366 | | |
4363 | | - | |
4364 | | - | |
4365 | | - | |
| 4367 | + | |
| 4368 | + | |
| 4369 | + | |
4366 | 4370 | | |
4367 | | - | |
4368 | | - | |
4369 | | - | |
4370 | | - | |
| 4371 | + | |
| 4372 | + | |
| 4373 | + | |
| 4374 | + | |
| 4375 | + | |
| 4376 | + | |
| 4377 | + | |
| 4378 | + | |
| 4379 | + | |
| 4380 | + | |
4371 | 4381 | | |
4372 | 4382 | | |
4373 | 4383 | | |
| |||
4520 | 4530 | | |
4521 | 4531 | | |
4522 | 4532 | | |
4523 | | - | |
4524 | | - | |
4525 | | - | |
4526 | | - | |
4527 | | - | |
| 4533 | + | |
| 4534 | + | |
| 4535 | + | |
| 4536 | + | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
| 4540 | + | |
| 4541 | + | |
4528 | 4542 | | |
4529 | 4543 | | |
4530 | | - | |
4531 | | - | |
4532 | | - | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
4533 | 4547 | | |
4534 | | - | |
4535 | | - | |
4536 | | - | |
4537 | | - | |
4538 | | - | |
4539 | | - | |
4540 | | - | |
4541 | | - | |
4542 | | - | |
4543 | | - | |
4544 | | - | |
4545 | | - | |
4546 | | - | |
4547 | | - | |
4548 | | - | |
4549 | | - | |
4550 | | - | |
4551 | | - | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
| 4551 | + | |
| 4552 | + | |
| 4553 | + | |
| 4554 | + | |
| 4555 | + | |
| 4556 | + | |
| 4557 | + | |
| 4558 | + | |
| 4559 | + | |
| 4560 | + | |
| 4561 | + | |
| 4562 | + | |
| 4563 | + | |
| 4564 | + | |
| 4565 | + | |
| 4566 | + | |
| 4567 | + | |
| 4568 | + | |
| 4569 | + | |
| 4570 | + | |
| 4571 | + | |
| 4572 | + | |
| 4573 | + | |
| 4574 | + | |
| 4575 | + | |
| 4576 | + | |
| 4577 | + | |
4552 | 4578 | | |
4553 | 4579 | | |
4554 | 4580 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1190 | 1190 | | |
1191 | 1191 | | |
1192 | 1192 | | |
1193 | | - | |
| 1193 | + | |
1194 | 1194 | | |
1195 | 1195 | | |
1196 | 1196 | | |
| |||
2481 | 2481 | | |
2482 | 2482 | | |
2483 | 2483 | | |
2484 | | - | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
2485 | 2510 | | |
2486 | 2511 | | |
2487 | 2512 | | |
| |||
2501 | 2526 | | |
2502 | 2527 | | |
2503 | 2528 | | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
2504 | 2622 | | |
2505 | 2623 | | |
2506 | 2624 | | |
2507 | 2625 | | |
2508 | 2626 | | |
2509 | 2627 | | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
2510 | 2631 | | |
2511 | 2632 | | |
2512 | 2633 | | |
2513 | 2634 | | |
2514 | 2635 | | |
2515 | | - | |
2516 | | - | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
2517 | 2644 | | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
2518 | 2658 | | |
2519 | 2659 | | |
2520 | 2660 | | |
2521 | | - | |
| 2661 | + | |
2522 | 2662 | | |
| 2663 | + | |
2523 | 2664 | | |
2524 | 2665 | | |
2525 | 2666 | | |
| |||
2534 | 2675 | | |
2535 | 2676 | | |
2536 | 2677 | | |
2537 | | - | |
2538 | | - | |
2539 | | - | |
2540 | | - | |
2541 | | - | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
2542 | 2686 | | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
2543 | 2691 | | |
2544 | | - | |
2545 | | - | |
2546 | | - | |
2547 | | - | |
2548 | | - | |
2549 | | - | |
2550 | | - | |
2551 | | - | |
2552 | | - | |
| 2692 | + | |
| 2693 | + | |
2553 | 2694 | | |
2554 | 2695 | | |
2555 | 2696 | | |
2556 | 2697 | | |
2557 | 2698 | | |
2558 | 2699 | | |
2559 | 2700 | | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
2560 | 2704 | | |
2561 | 2705 | | |
2562 | | - | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
2563 | 2713 | | |
2564 | 2714 | | |
2565 | 2715 | | |
2566 | | - | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
2567 | 2721 | | |
2568 | 2722 | | |
2569 | | - | |
2570 | | - | |
| 2723 | + | |
| 2724 | + | |
2571 | 2725 | | |
2572 | 2726 | | |
2573 | 2727 | | |
| |||
0 commit comments