Your Name
ab0b0cc031
fix(supply-api): close sms verify and audit flush gaps
...
Use a shared in-memory code store across mock, Tencent, and Aliyun SMS services so send and verify follow the same contract. Also surface batch flush failures through FlushNow and explicit error tracking hooks for audit buffering.
2026-04-14 12:22:10 +08:00
Your Name
6d7ef661e6
feat(supply-api): persist audit alerts
2026-04-14 11:52:45 +08:00
Your Name
879c09f6d3
test: improve domain and handler test coverage
...
- domain: add comprehensive PackageService and SettlementService tests
- handler: fix alert_handler_test mock audit store signature
- invariants_test.go: add CheckAccountDelete/Activate tests
- settlement_test.go: add Withdraw, Cancel, List, GetByID tests
- package_test.go: add Clone, BatchUpdatePrice tests
Coverage improvements:
- domain: 40.7% -> 71.2%
- middleware: 80.4%
- audit/handler: 79.6%
- audit/service: 83.0%
Fixes:
- mockAuditStore interface signature (interface{} -> audit.Event)
- newMockAccountStore syntax error
- Unlist test expects PackageStatusExpired not SoldOut
2026-04-08 10:01:41 +08:00
Your Name
862f313a74
test: improve audit/model coverage from 59.8% to 93.8%
...
- Add comprehensive Alert model tests
- Test NewAlert, generateAlertID, parseTenantID
- Test Alert methods: IsActive, IsResolved, Resolve, Acknowledge, Suppress
- Test UpdateLastSeen, AddEventID, SetMetadata, AddTag
- Test Alert constants
2026-04-08 09:06:36 +08:00
Your Name
7280ef565c
test: improve coverage for audit/events and security modules
...
- audit/events: 73.5% → 97.6% (+24.1%)
- Add tests for IsM013/M014/M015RelatedEvent
- Add tests for FormatSECURITYEvent
- Add comprehensive coverage for all CRED and SECURITY event functions
- security: 67.2% → 88.8% (+21.6%)
- Add tests for ValidateKeyID, DecryptionError.Error()
- Add tests for ValidateQueryParams, GetAllowedParamNames
- Add tests for isHexString, looksLikeAPIKey
- Fix test cases to match actual implementation behavior
- audit/sanitizer: Fix MaskMap []string handling bug
- Add maskSliceInterface for []interface{} type
- Tests now pass for string slice sensitive fields
All tests pass
2026-04-08 09:00:29 +08:00
Your Name
8ac23bf7d4
test: improve coverage and fix sanitizer bug
...
- Fix MaskMap to properly handle []string sensitive fields
- Add missing slice handling in sanitizer
- Add comprehensive tests for GetMetrics and CreateEventsBatch
- Improve audit/handler coverage from 49.8% to 68.8%
- Fix test expectations to match actual sanitizer behavior
- All tests pass
2026-04-08 07:44:58 +08:00
Your Name
d5b5a8ece0
fix: 系统性修复安全问题、性能问题和错误处理
...
安全问题修复:
- X-Forwarded-For越界检查(auth.go)
- checkTokenStatus Context参数传递(auth.go)
- Type Assertion安全检查(auth.go)
性能问题修复:
- TokenCache过期清理机制
- BruteForceProtection过期清理
- InMemoryIdempotencyStore过期清理
错误处理修复:
- AuditStore.Emit返回error
- domain层emitAudit辅助方法
- List方法返回空slice而非nil
- 金额/价格负数验证
架构一致性:
- 统一使用model.RoleHierarchyLevels
新增功能:
- Alert API完整实现(CRUD+Resolve)
- pkg/error错误码集中管理
2026-04-07 07:41:25 +08:00
Your Name
f34333dc09
fix: 修复代码审查中发现的P0/P1/P2问题
...
修复内容:
1. P0-01/P0-02: IAM Handler硬编码userID=1问题
- getUserIDFromContext现在从认证中间件的context获取真实userID
- 添加middleware.GetOperatorID公开函数
- CheckScope方法添加未认证检查
2. P1-01: 审计服务幂等竞态条件
- 重构锁保护范围,整个检查和插入过程在锁保护下
- 使用defer确保锁正确释放
3. P1-02: 幂等中间件响应码硬编码
- 添加statusCapturingResponseWriter包装器
- 捕获实际的状态码和响应体用于幂等记录
4. P2-01: 事件ID时间戳冲突
- generateEventID改用UUID替代时间戳
5. P2-02: ListScopes硬编码
- 使用model.PredefinedScopes替代硬编码列表
所有supply-api测试通过
2026-04-03 12:25:22 +08:00
Your Name
7254971918
feat(supply-api): 完成IAM和Audit数据库-backed Repository实现
...
- 新增 iam_schema_v1.sql DDL脚本 (iam_roles, iam_scopes, iam_role_scopes, iam_user_roles, iam_role_hierarchy)
- 新增 PostgresIAMRepository 实现数据库-backed IAM仓储
- 新增 DatabaseIAMService 使用数据库-backed Repository
- 新增 PostgresAuditRepository 实现数据库-backed Audit仓储
- 新增 DatabaseAuditService 使用数据库-backed Repository
- 更新实施状态文档 v1.3
R-07~R-09 完成。
2026-04-03 11:57:15 +08:00
Your Name
6fa703e02d
feat(audit): 实现Audit HTTP Handler并提升IAM Middleware覆盖率
...
1. 新增Audit HTTP Handler (AUD-05, AUD-06完成)
- POST /api/v1/audit/events - 创建审计事件(支持幂等)
- GET /api/v1/audit/events - 查询事件列表(支持分页和过滤)
2. 提升IAM Middleware测试覆盖率
- 从63.8%提升至83.5%
- 新增SetRouteScopePolicy测试
- 新增RequireRole/RequireMinLevel中间件测试
- 新增hasAnyScope测试
TDD完成:33/33任务 (100%)
2026-04-03 11:19:42 +08:00
Your Name
b2d32be14f
fix(P2): 修复4个P2轻微问题
...
P2-01: 通配符scope安全风险 (scope_auth.go)
- 添加hasWildcardScope()函数检测通配符scope
- 添加logWildcardScopeAccess()函数记录审计日志
- 在RequireScope/RequireAllScopes/RequireAnyScope中间件中调用审计日志
P2-02: isSamePayload比较字段不完整 (audit_service.go)
- 添加ActionDetail字段比较
- 添加ResultMessage字段比较
- 添加Extensions字段比较
- 添加compareExtensions()辅助函数
P2-03: regexp.MustCompile可能panic (sanitizer.go)
- 添加compileRegex()安全编译函数替代MustCompile
- 处理编译错误,避免panic
P2-04: StrategyRoundRobin未实现 (router.go)
- 添加selectByRoundRobin()方法
- 添加roundRobinCounter原子计数器
- 使用atomic.AddUint64实现线程安全的轮询
P2-05: 错误信息泄露内部细节 - 已在MED-09中处理,跳过
2026-04-03 09:39:32 +08:00
Your Name
732c97f85b
fix: 修复多个P0阻塞性问题
...
P0-01: Context值类型拷贝导致悬空指针
- GetIAMTokenClaims/getIAMTokenClaims改为使用*IAMTokenClaims指针类型
- WithIAMClaims改为存储指针而非值拷贝
P0-02: writeAuthError从未写入响应体
- 添加json.NewEncoder(w).Encode(resp)将错误响应写入HTTP响应
P0-03: 内存存储无上限导致OOM
- 添加MaxEvents常量(100000)限制内存存储容量
- 添加cleanupOldEvents方法清理旧事件
P0-04: 幂等性检查存在竞态条件
- 添加idempotencyMu互斥锁保护检查和插入之间的时间窗口
其他改进:
- 提取roleHierarchyLevels为包级变量,消除重复定义
- CheckScope空scope检查从返回true改为返回false(安全加固)
2026-04-03 09:05:29 +08:00
Your Name
89104bd0db
feat(P1/P2): 完成TDD开发及P1/P2设计文档
...
## 设计文档
- multi_role_permission_design: 多角色权限设计 (CONDITIONAL GO)
- audit_log_enhancement_design: 审计日志增强 (CONDITIONAL GO)
- routing_strategy_template_design: 路由策略模板 (CONDITIONAL GO)
- sso_saml_technical_research: SSO/SAML调研 (CONDITIONAL GO)
- compliance_capability_package_design: 合规能力包设计 (CONDITIONAL GO)
## TDD开发成果
- IAM模块: supply-api/internal/iam/ (111个测试)
- 审计日志模块: supply-api/internal/audit/ (40+测试)
- 路由策略模块: gateway/internal/router/ (33+测试)
- 合规能力包: gateway/internal/compliance/ + scripts/ci/compliance/
## 规范文档
- parallel_agent_output_quality_standards: 并行Agent产出质量规范
- project_experience_summary: 项目经验总结 (v2)
- 2026-04-02-p1-p2-tdd-execution-plan: TDD执行计划
## 评审报告
- 5个CONDITIONAL GO设计文档评审报告
- fix_verification_report: 修复验证报告
- full_verification_report: 全面质量验证报告
- tdd_module_quality_verification: TDD模块质量验证
- tdd_execution_summary: TDD执行总结
依据: Superpowers执行框架 + TDD规范
2026-04-02 23:35:53 +08:00
Your Name
ed0961d486
fix(supply-api): 修复编译错误和测试问题
...
- 添加 ErrNotFound 和 ErrConcurrencyConflict 错误定义
- 修复 pgx.NullTime 替换为 *time.Time
- 修复 db.go 事务类型 (pgx.Tx vs pgxpool.Tx)
- 移除未使用的导入和变量
- 修复 NewSupplyAPI 调用参数
- 修复中间件链路 handler 类型问题
- 修复适配器类型引用 (storage.InMemoryAccountStore 等)
- 所有测试通过
Test: go test ./...
2026-04-01 13:03:44 +08:00
Your Name
e9338dec28
feat: sync lijiaoqiao implementation and staging validation artifacts
2026-03-31 13:40:00 +08:00