memos/store/db/postgres
Claude 1a3298554b
fix(security): implement security review recommendations
This commit addresses all critical and high-priority recommendations from the security review:

**Critical Fixes:**
- Add nil checks before accessing memo properties in SetMemoAttachments and SetMemoRelations
  to prevent potential nil pointer dereference
- Fix information disclosure in DeleteMemoReaction by returning consistent errors
  (now returns permission denied instead of not found to avoid revealing reaction existence)

**Medium Priority Improvements:**
- Add GetReaction() method to store interface for better performance
  (single reaction lookup instead of list operation)
- Implement GetReaction() in all database drivers (SQLite, MySQL, PostgreSQL)
- Update DeleteMemoReaction to use the new GetReaction() method

**Test Coverage:**
- Add comprehensive test coverage for SetMemoAttachments authorization checks
- Add comprehensive test coverage for SetMemoRelations authorization checks
- Add comprehensive test coverage for DeleteMemoReaction authorization checks
- Add comprehensive test coverage for CreateUser registration enforcement

All tests follow the same patterns as existing IDP service tests and cover:
- Success cases for resource owners
- Success cases for superuser/host users
- Permission denied cases for non-owners
- Unauthenticated access attempts
- Not found scenarios

Related to PR #5217 security review recommendations.
2025-11-06 12:07:38 +00:00
..
activity.go chore: fix postgres stmts 2024-01-05 21:27:16 +08:00
attachment.go fix(store): correct PostgreSQL placeholder generation in IN clauses 2025-10-25 06:47:06 +08:00
common.go chore: fix postgres stmts 2024-01-05 21:27:16 +08:00
idp.go fix: create idp in postgres 2024-05-29 23:22:20 +08:00
inbox.go fix: remove errors.Wrap(nil) (#4576) 2025-03-31 12:56:51 +08:00
instance_setting.go refactor: rename workspace to instance throughout codebase 2025-11-05 23:35:35 +08:00
memo.go fix(store): correct PostgreSQL placeholder generation in IN clauses 2025-10-25 06:47:06 +08:00
memo_filter_test.go feat(store): add hierarchical tag filtering support 2025-10-30 00:21:53 +08:00
memo_relation.go refactor: memo filter 2025-10-16 09:22:52 +08:00
migration_history.go refactor: update migration history methods 2025-10-20 23:05:50 +08:00
postgres.go chore: fix linter 2025-06-15 10:27:24 +08:00
reaction.go fix(security): implement security review recommendations 2025-11-06 12:07:38 +00:00
user.go refactor: memo filter 2025-10-16 09:22:52 +08:00
user_setting.go refactor: general user setting 2025-06-23 23:23:57 +08:00