Repository navigation
Refactor/debt remediation 第二批历史债务修复 - #17
Merged
Merged
Conversation
- 债务分册移除「令牌表为内存 map」,新增「代理信任链未收敛导致 ClientIP() 可伪造」 - 修正该项原先与实测不符的两处表述:并非「恒为网关地址」,gin 默认信任全部代理时取 X-Forwarded-For 最左值;受影响面为 IP 限流、审计落库与访客去重,不含登录锁定与 WAF - 架构细则第 7 节拆为形态事实、变更前提(当前不触发)、代理信任链缺陷三节 - 令牌表持久化与限流器外置降为变更前提,不再作为待还债务 - 同步认证协议、会话接口、网关与中间件说明、结构红线与 README 清单 - 订正两处过期基线:依赖命中数 33 改为 35,admin lib/utils 四文件改为六文件
- 新增 security.trusted_proxies 白名单,代码默认只信任 127.0.0.1/32 与 ::1/128 - 引擎构造期调用 SetTrustedProxies,NewRouter 改为返回错误,组合根在启动期终止 - 配置校验拒绝空项、非法 IP 或 CIDR,以及覆盖全部地址的 0.0.0.0/0 与 ::/0 - 信任链为列表,通用环境覆盖只处理标量,故新增逗号分隔的专用通道 MYBLOG_SECURITY_TRUSTED_PROXIES,取值为空串表示服务前方没有代理 - 容器编排注入 172.16.0.0/12:nginx 为唯一入口且 server 未发布端口,仅容器网络可达 - 新增四态回归用例:非受信来源伪造 X-Forwarded-For 时取连接来源地址、经受信代理转发时取 最右侧非受信地址、受信代理单值转发被采信、信任列表为空时一律取连接来源地址 - 接线前实测三例失败,结构化日志的 clientIp 字段即为伪造值 - 同步债务条目状态与基线、架构细则第 7 至 9 节、结构红线、README 清单与三份 README
- 新建 packages/components(@myblog/components):主题切换组件与形态解析纯函数, 按包名导入且不设应用别名;packages/ui 维持 shadcn 库存件专属 - 删除两应用 theme-toggle.svelte 副本(45 行 ×2)与只导出该组件的 lib/components 桶 - packages/auth 移除 isBrowser 注入,环境判定改复用 @myblog/shared 的 isBrowser, 应用侧 auth.ts 由 15 行降至 10 行,定性为纯注入接缝并设 10 行上限 - 两应用接线新包依赖、ssr.noExternal 与 app.css 的 @source 扫描 - 新包补包级 prettier 配置:根配置未挂 Svelte 解析器,含 .svelte 的包须覆盖插件数组 - 根 test:packages、format-check 与 pre-commit-guard 三处门禁清单纳入新包 - 同步债务基线(2 文件 60 行收敛为 1 文件 10 行)、结构红线、复用决策树与组件归属规范 - 一并提交两处生成物:auto-imports.d.ts 的 goto 声明与 .eslintrc-auto-import.js 的移除项
identity.go 原先以 repository.UserRepository 作为实现字段类型,使 HTTP 横切层 直接依赖仓储包。改为在包内声明窄接口 userLookup,只保留身份解析实际消费的 GetByID,仓储实现由组合根注入后结构化满足,运行行为不变。
基线口径拆分为允许边与违例边后,CI 只统计 middleware 与 router 两处的 import,断言由「命中数 ≤ 13」改为「= 0」,步骤名同步。
原基线把两类性质不同的依赖合并计数:service 消费仓储接口属 §2.1 允许图, 按「接口与实现同包声明」的约定必然 import 该包,共 12 个文件;真正的违例边 只有 middleware 的 1 个文件。 - 债务条目由「存量」改为「已修复」,基线 13 改为 0,并写明允许边与已接受口径 - §2.1 中间件行、§2.3 验证命令、§8 索引红线同步订正,§9 新增阶段七 - 查询参数与结果结构随接口留在 repository 包,在 repository/README.md 与 条目中写明为已接受,不迁移至 internal/domain 登记表同时由「债务」改为「债务与取舍」:登记两类事项,已清除的违例与取舍 已定的架构决定,后者不构成债务,写存量与待处理字样会误导为待修项。 - 状态枚举定为已修复 / 已统一 / 已接受 / 推进中;已接受条目不设基线,只写明 上限与前提,维护纪律同步改写 - 四条取舍条目就地改语义:frontend 第 1、6、7 条与 §1 核心机制段 - 删除 debt/testing.md:唯一条目与 development.md 的替身覆写约定重复,分册 由 4 降为 3,合计 19 条,索引表同步删行 - AGENTS.md 第 1.5、5 节与文档地图改口径,§5 移除指向已修复条目的过期引用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.