Skip to content

fix(fingers): treat empty Protocol as http during engine init#18

Merged
wuchulonly merged 1 commit into
masterfrom
fix/fingers-protocol-nil-aliases
May 29, 2026
Merged

fix(fingers): treat empty Protocol as http during engine init#18
wuchulonly merged 1 commit into
masterfrom
fix/fingers-protocol-nil-aliases

Conversation

@wuchulonly
Copy link
Copy Markdown
Contributor

问题

从 JSON/Cyberhub 加载的 finger,Protocol 字段可能是空字符串(omitempty 省略)。Finger.Compile() 会把空 Protocol 默认成 "http",但 buildEngineFromFullFingers 在 Compile 之前就按 Protocol 分类。

旧逻辑只认 "http""tcp",Protocol 为空的 HTTP 指纹被直接丢弃,导致 httpFingers 为空 → fingersEngine.NewEngine() 返回 "fingers is nil" → 半初始化的 engine(Aliases == nil)被传到运行时 → MergeFrameworks 调用 Aliases.FindFramework() 时 panic。

修复

分类阶段把空 Protocol 按 "http" 处理,和 Finger.Compile() 的默认行为保持一致。

复现路径

spray/core/pool.(*BrutePool).handleBaseline
  → spray/core/baseline.(*Baseline).Collect
    → fingers.(*Engine).WebMatch
      → fingers.(*Engine).MergeFrameworks
        → fingers/alias.(*Aliases).FindFramework(0x0, ...)  ← panic

From JSON/Cyberhub, Finger.Protocol may be empty string due to
omitempty. Finger.Compile() defaults it to "http", but
buildEngineFromFullFingers classifies by Protocol before Compile runs.

Empty-protocol fingers were silently dropped, causing httpFingers to
be empty. Downstream fingersEngine.NewEngine() then returns "fingers
is nil", and the half-initialized engine (Aliases == nil) eventually
panics in MergeFrameworks -> FindFramework.

Fix: default empty Protocol to "http" at classification time,
consistent with Finger.Compile() behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wuchulonly wuchulonly merged commit 4741de3 into master May 29, 2026
2 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