Skip to content

Commit cd71e4f

Browse files
M09Icclaude
andcommitted
refactor: unify Context API to WithX, move ExportFilter, cleanup types
- 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>
1 parent c31c538 commit cd71e4f

29 files changed

Lines changed: 176 additions & 197 deletions

File tree

client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func WithResourceProvider(rp func(string) []byte) Option {
3636
}
3737

3838
// WithProxy 设置全局默认代理(支持多级代理链),应用于基础引擎和已注册扩展引擎。
39-
// 各引擎 Config.WithProxy 或 Context.SetProxy 可覆盖此默认值。
39+
// 各引擎 Config.WithProxy 或 Context.WithProxy 可覆盖此默认值。
4040
// 支持 proxyclient 的全部协议,例如:
4141
//
4242
// client.New(client.WithProxy("socks5://127.0.0.1:1080"))

examples/cases/cyberhub_provider/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func main() {
3535
return
3636
}
3737

38-
filter := types.NewExportFilter().
38+
filter := cyberhub.NewExportFilter().
3939
WithNames(splitCSV(*names)...).
4040
WithTags(splitCSV(*tags)...).
4141
WithSources(splitCSV(*sources)...).

examples/cases/filter/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func main() {
3232
}
3333

3434
func testExportFilter() {
35-
filter := types.NewExportFilter().
35+
filter := cyberhub.NewExportFilter().
3636
WithTags("cms", "framework").
3737
WithSources("github").
3838
WithLimit(100).
@@ -74,7 +74,7 @@ func testWithRealData(ctx context.Context, url, key string) {
7474

7575
engine2, err := fingers.NewEngine(fingers.NewConfig().
7676
WithProvider(cyberhub.NewProvider(url, key).
77-
WithFilter(types.NewExportFilter().WithTags("cms"))))
77+
WithFilter(cyberhub.NewExportFilter().WithTags("cms"))))
7878
if err != nil {
7979
fmt.Printf("Fingers filter failed: %v\n", err)
8080
return
@@ -92,7 +92,7 @@ func testWithRealData(ctx context.Context, url, key string) {
9292

9393
nEngine2, err := neutron.NewEngine(neutron.NewConfig().
9494
WithProvider(cyberhub.NewProvider(url, key).
95-
WithFilter(types.NewExportFilter().WithTags("rce"))))
95+
WithFilter(cyberhub.NewExportFilter().WithTags("rce"))))
9696
if err != nil {
9797
fmt.Printf("Neutron filter failed: %v\n", err)
9898
return

examples/cases/finger_to_poc/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func main() {
2626

2727
pocProvider := cyberhub.NewProvider(hubURL, apiKey)
2828
pocProvider.WithTimeout(300 * time.Second)
29-
pocProvider.WithFilter(types.NewExportFilter().WithDraft(true).WithReviewStatus(types.ReviewStatusPending))
29+
pocProvider.WithFilter(cyberhub.NewExportFilter().WithDraft(true).WithReviewStatus(cyberhub.ReviewStatusPending))
3030

3131
// 1. 指纹引擎
3232
engine, err := fingers.NewEngine(fingers.NewConfig().WithProvider(fingerProvider))

examples/cases/host_collision/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ func main() {
4747
// 配置上下文 - 关键:设置 Mod 为 "host"
4848
fmt.Println("⚙️ Configuring spray context...")
4949
ctx := spray.NewContext().
50-
SetThreads(100). // 并发线程数
51-
SetTimeout(5). // 超时时间
52-
SetMod("host") // 设置为 host 模式(关键!)
50+
WithThreads(100). // 并发线程数
51+
WithTimeout(5). // 超时时间
52+
WithMod("host") // 设置为 host 模式(关键!)
5353

5454
fmt.Printf(" Mode: host\n")
5555
fmt.Printf(" Threads: 100\n")

examples/cases/provider_filter/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func main() {
3737

3838
// 1. Remote ExportFilter: server-side filtering before download
3939
fmt.Println("=== Remote ExportFilter ===")
40-
filter := types.NewExportFilter().
40+
filter := cyberhub.NewExportFilter().
4141
WithTags(splitCSV(*tags)...).
4242
WithSources(splitCSV(*sources)...).
4343
WithSeverities(splitCSV(*severity)...).
@@ -79,7 +79,7 @@ func main() {
7979

8080
func testLocalFilter() {
8181
// ExportFilter construction (dry-run, no server call)
82-
filter := types.NewExportFilter().
82+
filter := cyberhub.NewExportFilter().
8383
WithTags("cms", "framework").
8484
WithSources("github").
8585
WithLimit(100).

examples/cases/proxy/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func main() {
5252
}
5353

5454
// 这次 check 使用专门的代理,不影响该引擎其它执行
55-
ctx := spray.NewContext().SetProxy("socks5://special-proxy:1080")
55+
ctx := spray.NewContext().WithProxy("socks5://special-proxy:1080")
5656
results, err := sprayEngine.Check(ctx, []string{"https://target.example.com"})
5757
if err != nil {
5858
panic(err)

examples/cases/spray_crawl_finger/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ func main() {
2929
opt := spray.NewDefaultOption()
3030
opt.Fuzzy = true
3131
ctx := spray.NewContext().
32-
SetOption(opt).
33-
SetThreads(4).
34-
SetTimeout(5).
35-
SetCrawlPlugin(true).
36-
SetFinger(true).
37-
SetCrawlDepth(2)
32+
WithOption(opt).
33+
WithThreads(4).
34+
WithTimeout(5).
35+
WithCrawlPlugin(true).
36+
WithFinger(true).
37+
WithCrawlDepth(2)
3838

3939
results, err := sprayEng.Brute(ctx, *target, []string{"/"})
4040
if err != nil {

examples/cases/spray_crawl_finger/spray_crawl_finger_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ func TestSprayCrawlAndDeepFinger(t *testing.T) {
6565
opt := spray.NewDefaultOption()
6666
opt.Fuzzy = true
6767
ctx := spray.NewContext().
68-
SetOption(opt).
69-
SetThreads(4).
70-
SetTimeout(2).
71-
SetCrawlPlugin(true).
72-
SetFinger(true).
73-
SetCrawlDepth(2)
68+
WithOption(opt).
69+
WithThreads(4).
70+
WithTimeout(2).
71+
WithCrawlPlugin(true).
72+
WithFinger(true).
73+
WithCrawlDepth(2)
7474

7575
results, err := sprayEng.Brute(ctx, srv.URL, []string{"/"})
7676
if err != nil {

examples/engines/gogo/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ func main() {
4949
}
5050

5151
ctx := gogo.NewContext().
52-
SetThreads(*threads).
53-
SetVersionLevel(*versionLevel)
52+
WithThreads(*threads).
53+
WithVersionLevel(*versionLevel)
5454

5555
results, err := engine.Scan(ctx, *target, *ports)
5656
if err != nil {

0 commit comments

Comments
 (0)