Skip to content

Analyzer service: fix window-prune flush-at-cap, stream keying, penalty-metadata trust - #74

Closed
Tumult1337 wants to merge 2 commits into
awlx:mainfrom
Tumult1337:pr/analyzer-service-fixes
Closed

Analyzer service: fix window-prune flush-at-cap, stream keying, penalty-metadata trust#74
Tumult1337 wants to merge 2 commits into
awlx:mainfrom
Tumult1337:pr/analyzer-service-fixes

Conversation

@Tumult1337

Copy link
Copy Markdown
Contributor

Analyzer service-layer fixes.

Commits

  • Fix window prune flushing the whole event buffer once past the cap (the off-by-one that zeroed scanner-detection tallies).
  • Fix collector stream keying, penalty-metadata trust, and the handshake pattern feed.

Merge note: pr/http-server-timeouts also touches pkg/analyzer/service.go and should merge after this.

Validation: go build ./... clean; go test ./pkg/analyzer passes.

The prune loops in updatePathEntropy and trackHTTPErrors break on
"len(events) <= maxEvents", but the slice is only re-sliced after the
loop, so len is constant per call. Once a window exceeds the cap the
break condition can never hold and every event is pruned, zeroing the
accumulated path-entropy counts and 404/403 tallies. A scanner
sustaining more than maxEvents in-window periodically resets its own
tracking. Compare the remaining count (len(events)-i) instead, and add
boundary tests for both windows.
…ttern feed

- Key each collector stream by peer address plus a monotonic sequence
  instead of the never-set ctx.Value("collector-id") constant, so
  Broadcast reaches every connected collector and a disconnect no longer
  evicts a still-live sibling's stream.
- Hoist the per-IP block-command dedup out of the per-collector send so a
  broadcast is deduped once per block decision, not suppressed for every
  collector after the first.
- Stop honoring penalty_key/penalty_type from wire metadata: the signal
  plane is unauthenticated gRPC, so an arbitrary target let any peer
  poison a third party's reputation. Penalty requests now only penalize
  the signal's own source IP and are dropped (fail closed) when the
  signal carries no source IP.
- Feed IsIncompleteHandshake to the pattern tracker from
  SIGNAL_INCOMPLETE_HANDSHAKE and document (SIMPLIFIED) which pattern
  detectors remain inert because TCPContext lacks the proto fields.
awlx added a commit that referenced this pull request Aug 8, 2026
@awlx

awlx commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Superseded by and merged through #77, which preserves this contribution and includes the follow-up fixes. Thanks for the contribution!

@awlx awlx closed this Aug 8, 2026
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