feat(compose): unify resource source configuration#335
Conversation
|
PR Title: feat(compose): unify resource source configuration Commit: 本次 PR 将 workspace、skill 和 script source 的配置统一为新的
发现一处高严重性问题:旧版 git workspace ConfigJSON(包含 branch/commit/path 字段)在新的 |
1d84a7f to
ce2e98c
Compare
|
PR Title: feat(compose): unify resource source configuration Commit: 本次 PR 将代码库中分散的资源来源配置(workspace、skill、script)统一收敛到新的
整体评估:这是一次结构清晰的重构,消除了多处重复凭证处理和 git 调用逻辑。但 GitClient 中仍存在一些安全性与正确性细节需要关注,如临时目录清理、命令参数校验、以及 |
| "path/filepath" | ||
| "strings" | ||
|
|
||
| domain "agent-compose/pkg/model" | ||
| "agent-compose/pkg/sources" |
There was a problem hiding this comment.
旧版 git workspace ConfigJSON 反序列化时静默丢失 branch/commit/clone target
新的 GitWorkspaceConfig 嵌入了 sources.Source 并将旧的 CloneTarget 重命名为 Target(JSON tag 从 path 改为 target)。对于数据库中仍然使用旧格式存储的 git workspace ConfigJSON(包含 branch、commit、path 等字段),反序列化时会静默丢失数据:branch/commit → 新结构没有对应字段,Ref 为空,运行时会 fallback 到 HEAD,导致旧 workspace 无法检出指定分支或 commit;path(旧 CloneTarget)→ 新结构的 sources.Source.Path 接收了该值,但语义从“clone 目标路径”变成了“仓库内子路径”,而 Target 为空导致文件被 clone 到 workspace 根目录而非预期的子目录。legacy_workspace_migration.go 中的 mapLegacyWorkspaceConfig 同样使用新结构反序列化旧数据,但未对 branch/commit/path 做兼容映射。
Problem code:
Changed code at pkg/workspaces/git_workspace.go:12
Recommendation:
- 为 GitWorkspaceConfig 增加旧字段的兼容反序列化(custom UnmarshalJSON),将旧字段 branch/commit 映射到 Ref,将旧字段 path(CloneTarget)映射到 Target。2. 或在 mapLegacyWorkspaceConfig 中显式解析旧字段并进行映射。3. 添加覆盖旧格式 ConfigJSON 的单元测试,确保迁移和运行时都能正确读取历史数据。
|
PR Title: feat(compose): unify resource source configuration Commit: 本次变更在 实现思路清晰, containment 校验覆盖了绝对路径、相对路径以及符号链接解析后的逃逸场景。测试覆盖了典型的 symlink 逃逸攻击向量。整体评估:改动合理,安全加固有效,未发现引入新的正确性或安全问题。 |
Summary
provider,url,ref,path,format, and authentication fieldsformat: zip) instead of a provider, replace Workspacebranch/commitwithref, and separate Workspace sourcepathfrom destinationtargetpkg/sourcesmodel and Git client used by Skills, Workspaces, and Git-backed Scheduler scripts, including ref resolution, authentication, validation, and credential redactionCloses #332
Testing
task generate:protoGOFLAGS=-buildvcs=false task lint GO_BUILD_CACHE_DIR="$GOCACHE" GOLANGCI_LINT_CACHE_DIR="$GOLANGCI_LINT_CACHE"GOFLAGS=-buildvcs=false task build GO_BUILD_CACHE_DIR="$GOCACHE"task test GO_BUILD_CACHE_DIR="$GOCACHE"task docs:buildThe full test task was run in a subprocess with inherited daemon/product configuration variables cleared as documented in
DEVELOPMENT_WORKFLOW.md. The build reused runtime artifacts whose source fingerprints matched the current branch.Checklist