Skip to content

refactor: unify types facade, split into sub-files, fix CI#32

Merged
M09Ic merged 7 commits into
masterfrom
refactor/types-unify-and-cleanup
Jul 8, 2026
Merged

refactor: unify types facade, split into sub-files, fix CI#32
M09Ic merged 7 commits into
masterfrom
refactor/types-unify-and-cleanup

Conversation

@M09Ic

@M09Ic M09Ic commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

L1/L2 引擎解耦,types 包统一重构,消除上游类型泄漏。

Breaking Changes

types 包重组

  • types.VulnResulttypes.TemplateResult,方法 ExecuteResult.VulnResult()ExecuteResult.TemplateResult()
  • types.NeutronResult 已删除,ExecuteResult.Value() 直接返回 *types.OperatorResult
  • ExecuteResult.Result() 已删除,用 ExecuteResult.Value() 替代
  • 新增 ExecuteResult.Events() 获取协议级事件
// 之前
nr := execResult.Result()           // *NeutronResult
op := nr.Result                     // *OperatorResult
events := nr.Events                 // []*ResultEvent
vr := execResult.VulnResult(target) // *VulnResult

// 现在
op := execResult.Value()              // *OperatorResult (直接)
events := execResult.Events()         // []*ResultEvent
tr := execResult.TemplateResult(target) // *TemplateResult

L2 引擎模块隔离

  • gogo/spray/zombie 各自独立 go.mod,通过 go get github.com/chainreactors/sdk/gogo 单独引入
  • L2 Option 类型从 types 包迁移到各自引擎包:
    • types.NewDefaultGogoOption()gogo.NewDefaultGogoOption()
    • types.SprayOption / types.NewDefaultSprayOption()spray 包内部,外部通过 Context 配置
    • types.NewDefaultZombieOption()zombie.NewDefaultOption()

New Features

  • types 拆分: types.go 拆为 scan.go/finger.go/template.go/neutron.go/proton.go
  • 新增 types.TemplateEvent 别名 + types.ReadRaw 函数,消除 httputils 直接依赖
  • 新增 client.Register()/client.Lookup() 引擎工厂注册表,L2 引擎 init() 自注册
  • CI: 补充 L2 模块测试步骤 + consumer-build L2 replace

Dependencies

  • fingers / neutron/operators/full / proton / utils 更新到 master

Test plan

  • go vet ./... 全部模块通过
  • go test ./... 全部模块通过 (L1 + gogo + spray + zombie)
  • go build ./... 全部模块通过 (含 examples)
  • CI workflow 通过 (2 轮)

🤖 Generated with Claude Code

M09Ic and others added 7 commits July 8, 2026 03:02
- Split pkg/types/types.go into focused sub-files: scan.go, finger.go,
  template.go, neutron.go, proton.go (core interfaces stay in types.go)
- Add TemplateEvent alias and ReadRaw function to eliminate httputils leak
- Fix VulnResult to use package-level aliases instead of direct imports
- Refactor neutron.ExecuteResult to embed TypedResult[T] for consistency
- Migrate fingers/ and examples/ from httputils.ReadRaw to types.ReadRaw
- Fix CI: add L2 module test steps, add replace directives for consumer build
- Fix go vet warnings in gogo/spray tests (context leak)
- Update deps: fingers, neutron/operators/full, proton, utils to master

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
VulnResult was misleading — it's the JSON-serializable form of any
neutron template execution, not just vulnerability findings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ExecuteResult now directly wraps TypedResult[*OperatorResult] with
events as a separate field. NeutronResult was an unnecessary
intermediate layer — OperatorResult already contains the full
template execution data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Context: rename all SetX → WithX across gogo/spray/zombie/proton
  for consistency with fingers engine convention
- Config: rename fingers.Config.SetEnableEngines → WithEnableEngines
- ExportFilter: move from pkg/types/ to pkg/cyberhub/ (sole consumer)
- finger types: remove internal-only aliases (FingerMapper, FingerFavicons,
  FingerContent, FingerRegexp, FingersMatchEngine, FingersLibEngine);
  keep extension points (FingerSender, FingerCallback)
- scan types: remove ZombieMod* constants (zombie engine has its own Mode*)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…eanup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@M09Ic M09Ic merged commit dcad862 into master Jul 8, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant