Skip to content

fix: community rules follow-up — JA4 rules, tests, shadow logging#15

Merged
Crank-Git merged 1 commit into
mainfrom
fix/community-rules-review
Apr 14, 2026
Merged

fix: community rules follow-up — JA4 rules, tests, shadow logging#15
Crank-Git merged 1 commit into
mainfrom
fix/community-rules-review

Conversation

@Crank-Git
Copy link
Copy Markdown
Owner

Summary

Post-merge follow-up for PR #13 (community detection rule library), addressing findings from eng review:

  • 2 new JA4-specific rules in c2_malware.toml: new_ja4_burst (>20 distinct JA4 fingerprints from one src in 5m, sliding) and dga_cert_diversity (>40 distinct JA4x server cert fingerprints from one src in 5m, sliding). These are the only community rules that use JA4-specific fields — a NetFlow sensor cannot replicate them.
  • Description fix for ssh_connection_burst: rule uses count_distinct(dst_ip), measuring distinct destination hosts, not total connection count. Description corrected.
  • Shadow-merge visibility: logShadowedRules helper logs a warning when a user custom rule shadows a community rule by name. Called at startup and on SIGHUP. Previously silent.
  • 2 missing tests: TestMergeRules_BothNil (nil/nil edge case) and TestCommunityRules_FireThroughEvaluator (end-to-end integration test: LoadCommunityRules → NewCustomRules → Evaluate → alert fires for port_scan_detector).

Test Plan

  • go test ./internal/config/... — LoadCommunityRules loads 11 rules (was 9), NoDuplicateNames, MergeRules_* including BothNil
  • go test ./internal/anomaly/... — integration test fires port_scan_detector alert after 21 distinct dst_ports
  • CI green on all 11 packages

🤖 Generated with Claude Code

…scription fix

Addresses findings from post-merge eng review of PR #13:

- Add new_ja4_burst and dga_cert_diversity rules to c2_malware.toml.
  These two rules use JA4-specific fields (ja4, ja4x) that a NetFlow sensor
  cannot see — the actual differentiator vs. volumetric-only detection.
  Both include a note that they only fire on completed TLS handshakes.

- Fix ssh_connection_burst description: was "opened more than 20 SSH
  connections" but the rule uses count_distinct(dst_ip), which measures
  distinct destination hosts, not total connection count. Corrected to
  "connected to more than 20 distinct hosts via SSH".

- Add TestMergeRules_BothNil: guards against panic if both community and
  custom rule sets are nil (edge case, not reachable in normal operation).

- Add TestCommunityRules_FireThroughEvaluator (integration test): end-to-end
  verification that LoadCommunityRules → NewCustomRules → Evaluate fires an
  alert. Specifically triggers port_scan_detector with 21 distinct dst_ports.
  Guards against silent regression if the wiring in initPipeline breaks.

- Add logShadowedRules helper in main.go: logs a warning when a user custom
  rule shadows a community rule of the same name. Called at startup and on
  SIGHUP. Previously silent; helps operators debug unexpected detection gaps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Crank-Git Crank-Git merged commit 692f3d9 into main Apr 14, 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