mirror of
https://github.com/Vyntral/god-eye.git
synced 2026-05-27 09:42:24 +02:00
3a4c230aa7
Complete architectural overhaul. Replaces the v0.1 monolithic scanner with an event-driven pipeline of auto-registered modules. Foundation (internal/): - eventbus: typed pub/sub, 20 event types, race-safe, drop counter - module: registry with phase-based selection - store: thread-safe host store with per-host locks + deep-copy reads - pipeline: coordinator with phase barriers + panic recovery - config: 5 scan profiles + 3 AI tiers + YAML loader + auto-discovery Modules (26 auto-registered across 6 phases): - Discovery: passive (26 sources), bruteforce, recursive, AXFR, GitHub dorks, CT streaming, permutation, reverse DNS, vhost, ASN, supply chain (npm + PyPI) - Enrichment: HTTP probe + tech fingerprint + TLS appliance ID, ports - Analysis: security checks, takeover (110+ sigs), cloud, JavaScript, GraphQL, JWT, headers (OWASP), HTTP smuggling, AI cascade, Nuclei - Reporting: TXT/JSON/CSV writer + AI scan brief AI layer (internal/ai/ + internal/modules/ai/): - Three profiles: lean (16 GB), balanced (32 GB MoE), heavy (64 GB) - Six event-driven handlers: CVE, JS file, HTTP response, secret filter, multi-agent vuln enrichment, anomaly + executive report - Content-hash cache dedups Ollama calls across hosts - Auto-pull of missing models via /api/pull with streaming progress - End-of-scan AI SCAN BRIEF in terminal with top chains + next actions Nuclei compat layer (internal/nucleitpl/): - Executes ~13k community templates (HTTP subset) - Auto-download of nuclei-templates ZIP to ~/.god-eye/nuclei-templates - Scope filter rejects off-host templates (eliminates OSINT FPs) Operations: - Interactive wizard (internal/wizard/) — zero-flag launch - LivePrinter (internal/tui/) — colorized event stream - Diff engine + scheduler (internal/diff, internal/scheduler) for continuous ASM monitoring with webhook alerts - Proxy support (internal/proxyconf/): http / https / socks5 / socks5h + basic auth Fixes #1 — native SOCKS5 / Tor compatibility via --proxy flag. 185 unit tests across 15 packages, all race-detector clean.
79 lines
2.1 KiB
Go
79 lines
2.1 KiB
Go
package scheduler
|
|
|
|
import (
|
|
"context"
|
|
"sync/atomic"
|
|
"testing"
|
|
"time"
|
|
|
|
"god-eye/internal/diff"
|
|
"god-eye/internal/store"
|
|
)
|
|
|
|
type spyAlerter struct{ called atomic.Int32 }
|
|
|
|
func (s *spyAlerter) Name() string { return "spy" }
|
|
func (s *spyAlerter) Notify(_ context.Context, _ *diff.Report) error {
|
|
s.called.Add(1)
|
|
return nil
|
|
}
|
|
|
|
func TestScheduler_RunsAndDiffsBetweenScans(t *testing.T) {
|
|
var callCount atomic.Int32
|
|
scan := ScanRun(func(_ context.Context) ([]*store.Host, error) {
|
|
n := callCount.Add(1)
|
|
if n == 1 {
|
|
return []*store.Host{{Subdomain: "a.example.com"}}, nil
|
|
}
|
|
// Second scan adds a new host — meaningful diff.
|
|
return []*store.Host{
|
|
{Subdomain: "a.example.com"},
|
|
{Subdomain: "b.example.com"},
|
|
}, nil
|
|
})
|
|
|
|
s := New("example.com", 100*time.Millisecond, scan)
|
|
alerter := &spyAlerter{}
|
|
s.AddAlerter(alerter)
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 300*time.Millisecond)
|
|
defer cancel()
|
|
_ = s.Start(ctx)
|
|
|
|
if callCount.Load() < 2 {
|
|
t.Errorf("scan should have run at least twice, got %d", callCount.Load())
|
|
}
|
|
if alerter.called.Load() == 0 {
|
|
t.Error("alerter should have been called on the second run")
|
|
}
|
|
}
|
|
|
|
func TestScheduler_NoAlertOnIdenticalScans(t *testing.T) {
|
|
scan := ScanRun(func(_ context.Context) ([]*store.Host, error) {
|
|
return []*store.Host{{Subdomain: "a.example.com"}}, nil
|
|
})
|
|
s := New("example.com", 50*time.Millisecond, scan)
|
|
alerter := &spyAlerter{}
|
|
s.AddAlerter(alerter)
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 200*time.Millisecond)
|
|
defer cancel()
|
|
_ = s.Start(ctx)
|
|
|
|
if alerter.called.Load() != 0 {
|
|
t.Errorf("alerter should not have been called on unchanged scans, got %d", alerter.called.Load())
|
|
}
|
|
}
|
|
|
|
func TestScheduler_RejectsBadParams(t *testing.T) {
|
|
s := &Scheduler{Target: "x", Interval: 0}
|
|
if err := s.Start(context.Background()); err == nil {
|
|
t.Error("expected error for zero interval")
|
|
}
|
|
|
|
s2 := &Scheduler{Target: "x", Interval: time.Second, Run: nil}
|
|
if err := s2.Start(context.Background()); err == nil {
|
|
t.Error("expected error for nil Run")
|
|
}
|
|
}
|