Skip to content

refactor: restructure engine, deduplicate OOB/Options/SDK logic#216

Open
wqnmlgb151 wants to merge 5 commits into
zan8in:mainfrom
wqnmlgb151:main
Open

refactor: restructure engine, deduplicate OOB/Options/SDK logic#216
wqnmlgb151 wants to merge 5 commits into
zan8in:mainfrom
wqnmlgb151:main

Conversation

@wqnmlgb151

Copy link
Copy Markdown
  • Split engine.go (2045→878 lines) into 7 focused files: webprobe, pedm, stage_fingerprint, filter, oob_coordinator, context, errors
  • Unify OOB token detection (ContainsOOBToken/PocUsesOOB exported)
  • Extract IsNetOnly() method on poc.Poc
  • Add RunnerOption pattern (WithSDKMode), delete createSDKRunner
  • Add sendOrDrop[T] generic channel helper, integrated at 6 call sites
  • Add Options.ApplyDefaults/ValidateRateLimitModes/TargetStrings helpers
  • Extract ScanContext for runtime callback separation
  • Delete MMutex, collectOrderedPocPaths, ~300 lines commented-out dead code
  • Fix ReadComplieOptions typo → ReadCompileOptions
  • Add 43 test cases across filter, context, poc, oob_coordinator, fingerprint
  • Add ProgressRenderer + GracefulShutdown types (pending main.go integration)
  • gofmt all files

- Split engine.go (2045→878 lines) into 7 focused files:
  webprobe, pedm, stage_fingerprint, filter, oob_coordinator, context, errors
- Unify OOB token detection (ContainsOOBToken/PocUsesOOB exported)
- Extract IsNetOnly() method on poc.Poc
- Add RunnerOption pattern (WithSDKMode), delete createSDKRunner
- Add sendOrDrop[T] generic channel helper, integrated at 6 call sites
- Add Options.ApplyDefaults/ValidateRateLimitModes/TargetStrings helpers
- Extract ScanContext for runtime callback separation
- Delete MMutex, collectOrderedPocPaths, ~300 lines commented-out dead code
- Fix ReadComplieOptions typo → ReadCompileOptions
- Add 43 test cases across filter, context, poc, oob_coordinator, fingerprint
- Add ProgressRenderer + GracefulShutdown types (pending main.go integration)
- gofmt all files
@zan8in

zan8in commented Jun 12, 2026

Copy link
Copy Markdown
Owner

这次改动范围较大,想确认一下是否已经做过充分的测试?另外,能否请您补充一下改动的动机,以及改动前后的主要区别?

@wqnmlgb151

Copy link
Copy Markdown
Author

改动已经过充分测试:

  • go build ./... 编译通过
  • go vet ./... 零告警
  • go test ./... 全部 12 个包通过
  • 编译的 exe 在多个真实目标上运行验证(afrog -t xJie.com 等),1663 任务 21 秒完成

改动动机:原 engine.go 2045 行包含了 Web 探测、指纹扫描、PEDM 监控、OOB 适配器初始化等全部逻辑,单文件难以维护。同时存在多处重复代码(OOB token 检测有两份、isNetOnlyPoc 闭包有两份、target 列表提取循环重复 4 次)。

改动前后主要区别

  • engine.go 2045→878 行,拆出 7 个职责文件(webprobe/pedm/stage_fingerprint/filter/oob_coordinator/context/errors)
  • 消除 230+ 行重复代码(OOB token 去重、SDK runner 统一、sendOrDrop 泛型、TargetStrings 提取)
  • 删除死代码 ~300 行(MMutex、collectOrderedPocPaths、注释代码)
  • 新增 43 个测试用例
  • 扫描逻辑零改动,所有 PoC 行为与原版完全一致

Delete 28 lines of commented-out regex functions in celprogram.go,
run gofmt across the entire repo, and add .editorconfig to prevent
future formatting drift. No behavior change.
@wqnmlgb151

Copy link
Copy Markdown
Author

🔧 Code Cleanup Update

This is a follow-up to address code quality issues identified in review:

Changes in this update:

  1. Removed dead code — Deleted 28 lines of commented-out regex functions in pkg/runner/celprogram.go (lines 1215-1226 and 1246-1262)
  2. Fixed gofmt violations — Ran gofmt -w . across the entire repo (144 files reformatted)
  3. Added .editorconfig — Prevents future formatting drift with consistent tab/LF/UTF-8 settings

Verification:

✅ go build ./...   — passes
✅ go vet ./...     — passes
✅ go test ./...    — all tests pass
✅ gofmt -l .       — returns empty (0 violations)

Files changed:

  • pkg/runner/celprogram.go — dead code removed
  • 144 .go files — gofmt formatting applied
  • .editorconfig — new file

No behavior changes. All changes are purely cosmetic/formatting.

…uidance

Add detailed scan flow, key packages table, PoC execution model,
refactoring notes from 4 rounds of engine splits, code style rules,
and common pitfalls for Windows Go development.
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.

2 participants