Commit Graph
562 Commits
Author SHA1 Message Date
qing f93ae59521 feat: 切换 dnfs 到 dnfs2 启动与安装配置 2026-08-08 13:24:30 +08:00
qing f59988ceda Merge branch 'main' of https://git.cancerai.top/qing/blackbird 2026-08-08 08:34:58 +08:00
qing 546b19aece refactor(static): 重写首页,统一设计语言提升视觉和谐感
- index.html: 品牌树 SVG 扩展为 4 层节点,新增径向渐变光晕底衬;
  About 面板新增同心圆装饰 SVG;CTA 树水印重绘为紧凑 7 节点版本
- css/index.css: 统一渐变方向为 135deg;光晕/点阵透明度更克制;
  卡片 hover 阴影更柔和;树动画幅度降低周期放慢;间距节奏统一
- js/index.js: IntersectionObserver 选择器适配新 section 命名
2026-08-08 00:28:30 +00:00
qing 3708a9ca0c Merge branch 'main' of https://git.cancerai.top/qing/blackbird 2026-08-08 05:50:31 +08:00
qing 79b2e5b4be Merge branch 'main' of https://git.cancerai.top/qing/blackbird 2026-08-08 02:57:22 +08:00
qing 7ec5d71e06 docs: 添加 blackbird 项目深度研究报告
覆盖架构、安全、代码质量与部署运维五大主题,含 15 个引用来源
2026-08-08 02:47:02 +08:00
qing 00ce3eac6a fix(waf): 修复P3安全审计缺陷
P3-1: logclient 复用 TCP 长连接,失败时重建,消除 TIME_WAIT 堆积
P3-2: TLS 显式限定 CipherSuites + CurvePreferences,排除弱加密套件
P3-3: CheckInput query 编码改用 url.Parse + Query().Encode()

修复率 76% -> 94%(P3 全部清零,仅剩 P0-3 为设计依赖)
2026-08-08 02:39:22 +08:00
qing dd9f8e51ff fix(waf): 修复P1/P2安全审计缺陷
P1-1: IPv6 地址解析改用 net.SplitHostPort,修复 XFF 带方括号致限流失效
P1-2: 捕获 ProcessResponseHeaders 返回值,命中记录 WARNING 告警
P1-4: 新增 SIGINT/SIGTERM 优雅关闭 + logclient.Flush()
P1-5: 标准日志输出到 stderr,保留 panic 堆栈
P2-1: 规则文件加载前校验大小(1 MiB 上限)防 OOM
P2-2: logclient db 地址支持 LOG_DB_ADDR 环境变量
P2-5: 日志失败输出到 stderr 而非 stdout

修复率 35% -> 76%(P1/P2 全部清零)
2026-08-08 02:36:22 +08:00
qing bcec529761 fix(static): 第2轮审计修复12项安全缺陷
修复 P1 路径遍历前缀 bypass、代理错误信息泄露、大文件 OOM、邮箱枚举与 CORS 通配;P2 Range 边界、hash 参数校验、db 连接复用、favicon 端口校验、日志批丢、端口解析异常。CSP/SSL 标记为已知限制。审计文档同步更新,修复率 36% → 88%。
2026-08-08 02:21:08 +08:00
qing 1d1b80a049 docs: 修正宣传文案中 7 处不准确描述
- 请求链路补上 redirect80(7步→8步),ai_review 触发条件改为新增节点前
- 模块地图补全 redirect80/db2/dnfs2/BotOps/lci,libtry 归入共享基础库
- core 管理接口修正为实际路由 /list /exec /kill(需管理员 Token)
- 安全评级改为各模块独立评级(gateway A- / dnfs2 A),不再暗示整体升级
- 快速上手 /status 改为 POST /list,init.txt 补全全部模块并强调顺序
- CTA 去掉安全评级从 A 推向更高的表述
- 共享基础库列表补入 libtry
2026-08-08 02:18:31 +08:00
qing 1ed48a1f48 build(db2,dnfs2): 补齐 Dockerfile 支持容器化部署
- db2/Dockerfile: 多阶段构建(libmsg+db2),含 schema 初始化 entrypoint
- dnfs2/Dockerfile: 多阶段构建(libhttp+libmsg+dnfs2),curl 健康检查
- .dockerignore: 豁免 libhttp/libmsg 供 C++ 服务构建

两者均基于 ubuntu:24.04(boost 1.83 含 json.hpp),可平替 Python 版
2026-08-08 01:59:48 +08:00
qing 40bc0ad5c7 docs(readme): 补充未记录模块 db2/dnfs2/redirect80/BotOps/lci
- redirect80: HTTP→HTTPS 重定向服务,补充至架构图/服务表/端口表/启动顺序
- db2/dnfs2: db/dnfs 的 C++20 重实现,补充详细章节
- BotOps: aibox 智能体 TUI 前端,补充详细章节
- lci: 嵌入式帧缓冲图形界面(仅记录该功能)
- 同步更新多语言异构列表与安装顺序
2026-08-08 01:59:14 +08:00
qing 2e0805eb05 fix(dnfs2): 第2轮审计修复 db 错误处理不一致
- P2-N6: _note_exists db 业务错误误判为节点不存在,改抛 500
- P2-N7: delete_note/update_note 所有权检查分离 db 错误(500)和节点不存在(404)
- P3-N8: CONFS_PORT 添加 [1,65535] 范围校验
- P3-N9: main() 添加 curl_global_cleanup,配对 curl_global_init
- 更新审计文档为第 2 轮,评级 A- → A
2026-08-08 01:44:04 +08:00
qing 117fc0241e fix(libhttp,dnfs2): HttpClient 新增超时接口,dnfs2 启用配置超时
修复 dnfs2 审计 L-3(P2-N5):

libhttp HttpClient 硬编码 CURLOPT_TIMEOUT=30L/CONNECTTIMEOUT=10L,
dnfs2 的 gateway_timeout/review_timeout 配置加载后从未使用,实际超时恒为 30s。

修复:
- libhttp HttpClient 新增 set_timeout/set_connect_timeout 接口
  (默认 30s/10s,向后兼容 gateway/core)
- request_stream_sync 使用成员变量替代硬编码值
- dnfs2 decode_token 设置 gateway_timeout
- dnfs2 review_content 设置 review_timeout

安全评级 A- → A,已知限制 6→5 项。
2026-08-08 01:33:57 +08:00
qing 9804838e96 feat(dnfs2): C++20 重实现 dnfs,修复全部 P0/P1 + 审计新发现 4 项
dnfs2 基于 libhttp + libmsg + boost::json 重写 Python dnfs,接口完全兼容:
- 4 个路由 (get_notes/add_note/delete_note/update_note) + 特殊节点 (link/js/image/file)
- Token 验签经 gateway /whoami (fail-closed 503)
- AI 内容审核 fail-closed
- AsyncQueue 异步日志 → db2 Logs 表
- 安全响应头 (CSP/X-Frame-Options 等)

修复 dnfs 继承的 6 项 P0/P1:
- P0-4 统一 _call_db() 检查 success 后再访问 data
- P1-6 setMaxBodySize(10MB)
- P1-7 日志客户端复用主配置
- P1-8 update_note pid≠0 校验父节点存在
- P1-9 RpcClient retry_on_refused=true
- P1-11 note_id 显式 as_int64() + 类型校验

审计新发现并修复 4 项:
- P1-N1 stop_watcher detach 改 join,修复 use-after-free (CWE-416)
- P1-N2 main() 添加 curl_global_init,修复多线程首次 curl_easy_init 竞态 (CWE-362)
- P2-N3 delete_note 分离 db 错误(500) 和子节点检查(400)
- P2-N4 threads 上限 256,对齐项目约定

安全评级 A-,6 项已知限制已记录。
2026-08-08 01:26:55 +08:00
qing 5628010d45 Merge branch 'main' of https://git.cancerai.top/qing/blackbird 2026-08-08 00:16:09 +08:00
qing e815f0ec40 fix(gateway,libhttp): 修复进程无法退出bug,完成P0安全问题修复
安全修复(P0):
- 修复4处错误消息泄露内部步骤问题,替换为用户友好文案
- 修正拼写错误 "Registe" -> "Registration"
- 修正注册失败HTTP状态码 400 -> 500
- 所有P0严重问题100%修复,安全评级提升至A-

稳定性修复(关键):
- 修复信号处理非async-signal-safe问题:仅设置原子标志,杜绝死锁
- 新增SIGPIPE忽略处理,防止写关闭socket时进程意外终止
- 修复Listener::doAccept()关闭后无限递归导致CPU 100%空转bug
- 新增Listener::close()方法,stop()先关闭acceptor再停止ioc
- 改进stop()流程:acceptor->WS客户端->ioc->worker线程 有序关闭
- 新增双重超时保护:stop() 8秒、日志flush 3秒,超时强制exit保证进程绝不挂死
- 服务器事件循环改为独立线程运行,主线程负责信号检测和关闭协调

文档:
- 新增CHANGELOG.md更新日志
- 更新gateway安全审计文档,添加稳定性修复记录
- 更新docs/INDEX.md文档索引
2026-08-07 23:07:35 +08:00
qing b33c5e6d1d fix(gateway): 修复P0安全问题,错误消息脱敏
- 将4处暴露内部处理步骤的错误消息替换为用户友好文案
- 修正拼写错误 "Registe" -> "Registration"
- 修正注册失败HTTP状态码 400 -> 500
- 更新安全审计文档至2026-08-07版本
- P0严重问题全部修复,安全评级提升至A-

修复内容:
- "Login (Query Step) Failed" -> "Login failed, please try again later"
- "Login (Update Step) Failed" -> "Login failed, please try again later"
- "Registe Failed" -> "Registration failed, please try again later"
- "Reset Failed" -> "Password reset failed, please try again later"
2026-08-07 22:53:26 +08:00
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 e2f05f9a43 fix(libmsg): security audit round 4 - eliminate residual race + atomic server_fd
- P1-3: introduce ConnectionLock (mutex + atomic active) to close the residual
  CWE-362 race where _remove_client closes fd before reply/broadcast acquires
  the lock; senders now check active after locking and abort if fd was closed
- P2-7: make _server_fd std::atomic<int> to remove the data-race UB between
  stop() and _event_loop
- P2-8: validate on_message is non-null in MsgServer::start()
- P3-2: distinguish missing _route vs wrong-typed _route in RpcServer
- P3-3: set TCP_NODELAY/SO_SNDTIMEO before registering fd in _clients
- doc: add SO_SNDTIMEO precondition note to pmsg_send
2026-08-07 21:27:05 +08:00
qing 63c22a3d60 fix(libmsg): security audit round 3 - add server send timeout + harden RPC validation 2026-08-07 21:13:14 +08:00
qing 3c50a862d3 fix(libmsg): complete security audit round 2 - fix P0 race + harden input validation
- P0: fix _close_all_clients() race condition (CWE-362) - hold per-connection send_lock
  before close() to prevent messages being sent to wrong client after fd reuse
- P2: add comprehensive input validation for all public APIs
  (timeout/port/workers/max_connections/batch_size etc. bounds checking)
- P2: add UTF-8 payload validation (isValidUtf8) aligning with Python pymsg behavior,
  rejecting overlong encodings, surrogate pairs, truncated/invalid sequences
- P2: document pmsg_recv(int) precondition and recommend deadline mode
- add constructor validation for MsgClient/MsgServer/AsyncQueue/RpcClient/RpcServer
- add add_route() validation for empty route name and null handler
- update security audit report with round 2 findings and fixes (8 issues total, 100% fixed)
2026-08-07 21:01:34 +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 cc0475e5dc Merge branch 'main' of https://git.cancerai.top/qing/blackbird 2026-08-07 15:47:34 +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
shufeng2012 cc3aafdfa1 🙈 更新db2的.gitignore 2026-08-07 15:36:21 +08: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 6644775934 Merge branch 'main' of https://git.cancerai.top/qing/blackbird 2026-08-07 14:06:20 +08:00
qing c45e2e13f4 refactor(static): 首页统一 1024px 版心,特性网格改为 2×2 等宽布局
- 新增 .wrap 统一版心,头部胶囊、特性、关于、CTA、页脚全部对齐同一内容栏
- 特性卡片由 Bento 跨列网格改为 2×2 等宽,取消旋转装饰
- 关于面板改为居中排版,数据行移至底部横排
- 章节间距统一由 .section 控制,移动端断点适配同步收敛
2026-08-07 06:04:15 +00:00
qing df39e5d006 迁移db到db2 2026-08-07 13:43:55 +08:00
qing 64907f45c5 Merge branch 'main' of https://git.cancerai.top/qing/blackbird 2026-08-07 13:42:19 +08:00
qing f3ba13a6b9 fix(static): 特效节点全屏 iframe 改挂 body,修复被后续卡片盖住
全屏特效 iframe 原挂载在卡片容器内,卡片入场动画的 opacity<1 会在
卡片上产生层叠上下文,iframe 的 z-index:9999 被困在卡片内部生效,
DOM 序靠后的兄弟卡片把整张卡片(含特效)压在下面。改为全屏特效
直接挂载 document.body,z-index 在根层叠上下文竞争;in-node 特效
保持挂在卡片内。清理路径(clearAllEffects 全文档按 class 查找)
不受影响。
2026-08-07 05:40:28 +00:00
qing 7f358faaf4 Merge branch 'main' of https://git.cancerai.top/qing/blackbird 2026-08-07 13:04:21 +08:00
qing 74aaa668ce Merge branch 'main' of https://git.cancerai.top/qing/blackbird 2026-08-07 05:03:33 +00:00
qing 46c1fdd914 feat(static): 首页新增 Bento 特性卡、CTA 横幅与品牌页脚
- 特性区改 Bento 网格(首尾卡跨两列)并加底部标签胶囊
- 关于区改左文右数据面板,移动端转竖排横数据
- 新增结尾品牌渐变 CTA 横幅(含深色模式适配)
- 页脚重构为品牌+导航+备案三段
- CTA 按钮改 data-cta 多按钮绑定,渐显目标同步补全
2026-08-07 05:02:35 +00:00
qing 8a661291c0 chore(db2): 从索引移除 build/db2,交由 .gitignore 忽略 2026-08-07 04:57:53 +00:00
qing e2b99529fc chore(db2): 添加 .gitignore,忽略 build/ 与编译产物 2026-08-07 04:56:34 +00:00
shufeng2012 36443ae1fb 🙈 更新适用于vscode的.gitignore 2026-08-07 11:28:12 +08:00
qing 9676e5cacb docs(readme): 补充 libmsg 到共享基础库表格 2026-08-07 02:26:12 +00:00
qing 5dc8956b55 fix(gateway): implement dual-track token revocation mechanism (P0-1)
Add thread-safe in-memory token revocation to fix the critical issue
where logged-out or password-reset tokens remain valid until expiry.

- Add jti (uuid v4) to all issued tokens for single-token revocation
- Add per-user version number for bulk revocation on password reset
- Add jti blacklist with TTL-based auto-cleanup to prevent memory leaks
- Introduce unified verify_token() replacing 4 copies of inline logic
- Refactor all handlers (login/logout/refresh/reset_password/proxy/whoami/
  admin_verify/ws_admin) to use the new verification pipeline
- Refresh token now revokes old jti (prevents replay after refresh)
- Bump version to 0.8.0
2026-08-07 02:35:08 +08:00
qing daf4bbe6c2 docs(index): 补充 db2 审计报告与 README 索引 2026-08-06 18:26:12 +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 cb31db1078 docs(security): 更新 libsqlite3 审计报告修复状态
- P0-3 参数化 exec 已修复
- P1-2/P1-3/P1-4 绑定类型与异常信息已修复
- P2-2/P2-3 读取接口与文档已修复
- 修正 P2 问题数量统计(6 项而非 5 项)
2026-08-06 18:14:01 +00:00
qing 48714b88af fix(libsqlite3): 增加参数化 exec 与完整绑定/读取接口
- 新增模板 exec(sql, args...) 参数化执行,支持 int / int64_t / double /
  std::string / const char* / nullptr / std::vector<unsigned char>
- 扩展 Sqlite3_stmt:bind_int64、bind_double、bind_blob、bind_null、execute
- 增加 read_int64、read_double,read_text 补充生命周期注释
- 构造/打开异常携带 sqlite3_errmsg 详情
- 原 exec(sql) 增加硬编码 SQL 警告注释
2026-08-06 18:13:52 +00:00
qing 1c55443d43 docs(security): 新增 libsqlite3 安全审计报告
- 记录 P0/P1/P2 级别问题与修复状态
- 已修复 double free / 移动语义、close_v2、const 引用等 5 项问题
2026-08-06 18:07:14 +00:00
qing 985ff47c84 fix(libsqlite3): 修复 double free 与移动语义缺陷
- 为 Sqlite3 与 Sqlite3_stmt 显式 delete 拷贝、实现 noexcept 移动构造/赋值
- 析构函数判空后释放,防止重复释放与 use-after-free
- ~Sqlite3() 改用 sqlite3_close_v2,确保所有 statement 释放后再关闭
- stmt() 参数改为 const std::string&,支持字符串字面量
- 成员指针显式初始化为 nullptr,errMsg 初始化为 nullptr
2026-08-06 18:07:06 +00:00
qing b781a8d2fe fix(static): 修复特效节点全屏 iframe 被卡片 transform 困住的问题
卡片入场动画的 translateY 使卡片成为 position:fixed 后代的包含块,
全屏特效 iframe 被限制在卡片内渲染,表现为部分特效不自动启动
(in-node 特效为 relative 定位不受影响)。卡片入场改为纯 opacity 淡入;
带位移的 rise-in 仅用于无 fixed 后代的骨架元素,并排除依赖
transform 垂直居中的 .minimap。
2026-08-06 17:49:15 +00:00