Commit c3555c9
authored
fix: comprehensive audit fixes — security, performance, tech debt, tests (#51)
Security:
- Credentials file permissions set to 0o600 on Unix
- Input validation for MCP tool_store (topic max 255, content max 100k)
- FTS query hardening (length limit, token cap, quote stripping)
- Embedding dims validated to 64-4096 range
- Search result limits capped to 100
Performance:
- CLI recall uses batch_update_access instead of N individual calls
- Reduced cloning in search_hybrid (owned keys iteration)
- Reduced cloning in tool_store dedup (struct literal vs clone)
Tech debt + Logging:
- Replaced eprintln! with tracing::warn! (6 locations)
- Fixed unwrap() panic in extract_patterns
- Replaced .expect() with proper error handling in embed command
- Added tracing on rollback paths and datetime parse failures
- Added DEFAULT_EMBEDDING_DIMS constant (replaces hardcoded 384)
- Added DEDUP_SIMILARITY_THRESHOLD constant (replaces magic 0.85)
Redundancy + Dead code:
- Removed unused delete_cloud_memory and sync_memory_background
- Extracted topic_matches/keyword_matches to icm-core (shared CLI+MCP)
- Added MSG_NO_MEMORIES constant for consistent messaging
Tests (+29 new):
- Store: empty queries, nonexistent CRUD, batch access, auto-consolidate,
decay, prune, topics, stats, topic prefix
- MCP: empty recall, input validation (topic/content length)
- Security: FTS sanitization, embedding dims bounds, search limits,
credentials permissions1 parent b2a98da commit c3555c9
8 files changed
Lines changed: 499 additions & 116 deletions
File tree
- crates
- icm-cli/src
- icm-core/src
- icm-mcp/src
- icm-store
- src
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
80 | 88 | | |
81 | 89 | | |
82 | 90 | | |
| |||
459 | 467 | | |
460 | 468 | | |
461 | 469 | | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | 470 | | |
508 | 471 | | |
509 | 472 | | |
| |||
541 | 504 | | |
542 | 505 | | |
543 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
544 | 529 | | |
545 | 530 | | |
546 | 531 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
681 | | - | |
| 681 | + | |
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
| |||
774 | 774 | | |
775 | 775 | | |
776 | 776 | | |
777 | | - | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
778 | 781 | | |
779 | 782 | | |
780 | 783 | | |
| |||
919 | 922 | | |
920 | 923 | | |
921 | 924 | | |
922 | | - | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
923 | 928 | | |
924 | 929 | | |
925 | 930 | | |
926 | 931 | | |
927 | 932 | | |
928 | 933 | | |
929 | 934 | | |
930 | | - | |
| 935 | + | |
931 | 936 | | |
932 | 937 | | |
933 | | - | |
| 938 | + | |
934 | 939 | | |
935 | 940 | | |
936 | 941 | | |
937 | | - | |
| 942 | + | |
938 | 943 | | |
939 | 944 | | |
940 | 945 | | |
| 946 | + | |
| 947 | + | |
941 | 948 | | |
942 | | - | |
943 | 949 | | |
944 | 950 | | |
945 | 951 | | |
| |||
956 | 962 | | |
957 | 963 | | |
958 | 964 | | |
959 | | - | |
| 965 | + | |
960 | 966 | | |
961 | 967 | | |
962 | | - | |
| 968 | + | |
963 | 969 | | |
964 | 970 | | |
965 | 971 | | |
966 | | - | |
| 972 | + | |
967 | 973 | | |
968 | 974 | | |
969 | 975 | | |
| 976 | + | |
| 977 | + | |
970 | 978 | | |
971 | | - | |
972 | 979 | | |
973 | 980 | | |
974 | 981 | | |
| |||
992 | 999 | | |
993 | 1000 | | |
994 | 1001 | | |
995 | | - | |
| 1002 | + | |
996 | 1003 | | |
997 | 1004 | | |
998 | 1005 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
0 commit comments