qing
edbb7ef1c6
fix(db2): 修复第六轮审计定位的 4 个问题并更新审计文档
...
- ND-1(P2): start() 引入 CleanupGuard RAII 守卫,rpc.start() 异常路径
下清理线程被优雅回收,消除 std::terminate 硬崩溃
- ND-4(P3): where/limit/offset 类型不符立即抛错,不再静默忽略
- ND-5(P3): _bind_value 对超 INT64_MAX 的 uint64 抛错,防截断溢出
- ND-6(P3): in 运算符非数组值抛错,仅空数组保留恒假语义
- 记录 2 项已知限制 ND-2/ND-3(无结果集上限、无 WHERE 全表更新/删除)
审计文档更新至 26/26(100%) 修复、30 项安全机制;clang++/g++ 双编译验证通过
2026-08-07 21:42:06 +08:00
qing
3ace5931e6
fix(db2): security audit round 5 - fix all remaining P3 issues
...
- P3-7: replace gmtime() with thread-safe gmtime_r() in utc_now()
- P3-9: validate columns array elements are strings before as_string()
- P3-10: use sqlite3_close_v2() instead of sqlite3_close() in DbConn dtor
- P3-11: introduce safe_stoi() helper wrapping all 9 std::stoi call sites
with field-name-aware error messages
- P3-12: log _log_internal exceptions to stderr instead of silent swallow
- P3-13: log _do_cleanup COUNT prepare failures to stderr; simplify
finalize to single exit point
- P3-14: reject invalid order_by elements (non-object, missing column)
instead of silently skipping
- P3-15: reject non-string action field instead of defaulting to "select"
- P3-16: validate order_by column is string and desc is boolean
All 22 audit issues now resolved (100%).
2026-08-07 21:33:13 +08:00
qing
9256a8157b
fix(db2): add numeric config range validation (fix P2-3/P3-8)
...
- Add range checks in load_config() for all numeric config values:
* listen_port: 1-65535
* workers: >= 1
* cleanup_interval: >= 1 (prevents busy loop DoS when misconfigured to 0/negative)
* retention_days: >= 0
* max_records: >= 1
- Fix unused lambda capture 'this' in RpcServer error handler
(-Wunused-lambda-capture with -Wall -Werror)
- Update security audit doc: mark P2-3/P3-8 fixed, mark production ready
Verified: g++ -std=c++20 -O3 -Wall -Werror compiles with zero warnings.
2026-08-07 20:48:22 +08:00
qing
761cfd4987
fix(db2): 修复剩余P3问题(limit/offset负值、WHERE/IN规模上限)
...
- limit/offset 增加非负校验
- WHERE 条件数上限 64,单个 IN 元素上限 1000
- 审计文档:11/11 问题全部修复
2026-08-07 07:46:46 +00:00
qing
2f7a99c2a4
fix(db2): schema缓存基于schema_version自动失效,更新审计文档
...
- 缓存项携带 PRAGMA schema_version,DDL变更后自动重新反射
- 修复P3-1低危问题,剩余未修复P3问题降至2项
2026-08-07 07:26:29 +00:00
qing
176fb13908
fix(db2): 修复空values和未知运算符问题,更新审计文档
...
P3-5: INSERT/UPDATE 空 values 前置校验,不再生成无效 SQL
P3-6: 未知 WHERE 运算符立即报错,不再静默跳过
审计文档:新增并发性分析章节,更新进度至 8/11 已修复
剩余 3 项 P3(schema缓存失效、limit负值、条件数上限)待后续迭代
2026-08-07 07:07:55 +00:00
qing
ec626dc8d5
fix(db2): 修复清理时间戳格式偏差,增加配置完整性校验
...
P2-1: 清理 SQL 改用 strftime 统一 T 分隔格式,消除保留期约 1 天偏移
P2-2: load_config 对 7 个必需字段做必填校验,缺失则 exit(1)
审计进度:已修复 6/9(P0×2 P1×1 P2×2 P3×1),剩余 3 项 P3
2026-08-07 06:55:31 +00:00
qing
00421182e4
fix(db2): 按 JSON 类型分别绑定 SQLite 参数,修复类型丢失
...
- _coerce_value 改为返回 json::value,保留 int/double/bool/null 原始类型
- 新增 _bind_value,按类型调用 sqlite3_bind_int64/double/text/null
- WhereClause::params 改为 vector<json::value>,删除 is_null 向量
- INSERT/UPDATE/SELECT/DELETE 统一使用按类型绑定
修复 P1-1(所有值绑定为 TEXT)和 P3-2(_coerce_value null 处理误导)
2026-08-06 18:23:30 +00:00
qing
1970f3f824
feat(db2): C++20 数据库 RPC 服务,对齐 Python db 模块 execute 路由
...
- 完整实现 execute 路由(select/insert/update/delete)
- 相同 where 语法(eq/ne/gt/lt/ge/le/like/in)及响应格式
- 启动时从 confs 拉取 db.ini,支持环境变量和命令行覆盖
- per-thread SQLite 连接 + WAL/mmap/busy_timeout PRAGMA
- PRAGMA table_info 驱动的列类型反射与缓存
- $now 哨兵值自动替换为 UTC 时间
- 内置 Logs 表自动建表 + 后台清理线程(retention_days + max_records)
- 表名白名单校验防 SQL 注入
- gateway DbC::call_msg() 零改动可直接切换
2026-08-06 17:40:07 +00:00