Repository navigation
refactor(engine): ports 的上游复制段归零 - #282
Merged
Merged
Conversation
PEB 跨进程读取的偏移改由 32/64 位两张表按目标字长选择,不再用本机 镜像结构体的 unsafe.Offsetof 推导;UNICODE_STRING 头按目标字长解出长度 与缓冲区,UTF-16 解码与路径规范化同步重写。 行为不变:拒绝短读、空/奇数长度、空缓冲区与越界偏移的用例保留。 Co-Authored-By: Claude Code <noreply@anthropic.com>
ProcSample 按「启动身份 / 负载 / 状态」分组,DockerStatsEntry 按「容器 状态 / 负载」分组;Apply 把同一来源的字段合并赋值,行为不变。 Co-Authored-By: Claude Code <noreply@anthropic.com>
三项覆盖不变:ps 行里带空格的命令行只丢坏行、lstart 按本机时区解释、 显示名按运行器与语言分组取命令里真正标识服务的那一段。 Co-Authored-By: Claude Code <noreply@anthropic.com>
对照 26dbcae:总量 9,610 → 8,933 行 / 664 段、135 个文件(生产 3,564、 测试 5,369),internal/ports 整包归零。 Co-Authored-By: Claude Code <noreply@anthropic.com>
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.
这次做了什么
internal/ports按本项目的对象模型重写,审计(对照26dbcae)里这一包从 677 行降到 0:引擎总量 9,610 → 8,933 行 / 664 段 / 135 文件(生产 3,564,测试 5,369)。
怎么重写的
unsafe.Offsetof推导,改成按目标字长选择的两张 ABI 表;UNICODE_STRING头、UTF-16 解码与路径规范化一起重写。失败语义不变:短读、空/奇数长度、空缓冲区都拒绝,读不到的 pid 仍然缺省。ProcSample、DockerStatsEntry按「启动身份 / 负载 / 状态」重新分组,Apply合并同来源字段。ps进程表、tasklist、启动时间与显示名的用例按运行器/语言分组重述,覆盖不减少。Windows ABI 的常量属于事实,保留;改的是表达与结构,不是把同一份代码改个名字。文件路径未动,审计仍按同一相对路径对照上游。
验证
go vet ./...go test -count=1 -timeout=8m ./...(全绿)go test -race -count=1 ./internal/ports/GOOS=windows go vet ./internal/ports/、GOOS=windows GOARCH=arm64 go build ./...python3 scripts/audit-upstream-origin.py --upstream /tmp/sonar:ports 无输出,总量 8,933本机是 macOS,Windows 只做了交叉编译与 vet,没有原生运行 PEB 读取。
🤖 Generated with Claude Code