mirror of
https://github.com/Vyntral/god-eye.git
synced 2026-06-09 07:44:00 +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.
175 lines
4.2 KiB
Go
175 lines
4.2 KiB
Go
package dns
|
|
|
|
import "testing"
|
|
|
|
func TestAllEqual(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
in []string
|
|
want bool
|
|
}{
|
|
{"empty", nil, true},
|
|
{"single", []string{"a"}, true},
|
|
{"all same", []string{"a", "a", "a"}, true},
|
|
{"one different", []string{"a", "a", "b"}, false},
|
|
{"all different", []string{"a", "b", "c"}, false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := allEqual(tt.in); got != tt.want {
|
|
t.Errorf("allEqual(%v) = %v, want %v", tt.in, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestAllEqualInts(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
in []int
|
|
want bool
|
|
}{
|
|
{"empty", nil, true},
|
|
{"single", []int{200}, true},
|
|
{"all same", []int{200, 200, 200}, true},
|
|
{"one different", []int{200, 200, 404}, false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := allEqualInts(tt.in); got != tt.want {
|
|
t.Errorf("allEqualInts(%v) = %v, want %v", tt.in, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestSimilarSizes(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
in []int64
|
|
want bool
|
|
}{
|
|
{"empty", nil, true},
|
|
{"single", []int64{1000}, true},
|
|
{"identical", []int64{1000, 1000, 1000}, true},
|
|
{"within 20%", []int64{1000, 1100, 1200}, true},
|
|
{"exactly 20%", []int64{1000, 1200}, true},
|
|
{"over 20%", []int64{1000, 1300}, false},
|
|
{"big variance", []int64{100, 10000}, false},
|
|
{"all zero", []int64{0, 0}, true},
|
|
{"zero and small", []int64{0, 50}, true},
|
|
{"zero and big", []int64{0, 200}, false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := similarSizes(tt.in); got != tt.want {
|
|
t.Errorf("similarSizes(%v) = %v, want %v", tt.in, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestIsWildcardIP(t *testing.T) {
|
|
wd := &WildcardDetector{}
|
|
info := &WildcardInfo{
|
|
IsWildcard: true,
|
|
WildcardIPs: []string{"1.2.3.4", "5.6.7.8"},
|
|
}
|
|
|
|
if !wd.IsWildcardIP("1.2.3.4", info) {
|
|
t.Error("expected 1.2.3.4 to be wildcard IP")
|
|
}
|
|
if wd.IsWildcardIP("9.9.9.9", info) {
|
|
t.Error("expected 9.9.9.9 NOT to be wildcard IP")
|
|
}
|
|
|
|
// nil and non-wildcard cases
|
|
if wd.IsWildcardIP("1.2.3.4", nil) {
|
|
t.Error("nil info should return false")
|
|
}
|
|
nonWild := &WildcardInfo{IsWildcard: false, WildcardIPs: []string{"1.2.3.4"}}
|
|
if wd.IsWildcardIP("1.2.3.4", nonWild) {
|
|
t.Error("non-wildcard info should return false even if IP matches list")
|
|
}
|
|
}
|
|
|
|
func TestIsWildcardResponse(t *testing.T) {
|
|
wd := &WildcardDetector{}
|
|
info := &WildcardInfo{
|
|
IsWildcard: true,
|
|
HTTPStatusCode: 200,
|
|
HTTPBodySize: 1000,
|
|
}
|
|
|
|
tests := []struct {
|
|
name string
|
|
statusCode int
|
|
bodySize int64
|
|
want bool
|
|
}{
|
|
{"exact match", 200, 1000, true},
|
|
{"within 10% body", 200, 1050, true},
|
|
{"within 10% body below", 200, 950, true},
|
|
{"over 10% body", 200, 1200, false},
|
|
{"different status", 404, 1000, false},
|
|
{"both different", 301, 500, false},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := wd.IsWildcardResponse(tt.statusCode, tt.bodySize, info); got != tt.want {
|
|
t.Errorf("IsWildcardResponse(%d, %d) = %v, want %v", tt.statusCode, tt.bodySize, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
|
|
if wd.IsWildcardResponse(200, 1000, nil) {
|
|
t.Error("nil info should return false")
|
|
}
|
|
}
|
|
|
|
func TestGenerateTestSubdomains(t *testing.T) {
|
|
subs := generateTestSubdomains()
|
|
if len(subs) < 3 {
|
|
t.Errorf("expected at least 3 test subdomains, got %d", len(subs))
|
|
}
|
|
seen := make(map[string]bool)
|
|
for _, s := range subs {
|
|
if s == "" {
|
|
t.Error("empty test subdomain generated")
|
|
}
|
|
if seen[s] {
|
|
t.Errorf("duplicate test subdomain: %s", s)
|
|
}
|
|
seen[s] = true
|
|
}
|
|
}
|
|
|
|
func TestWildcardInfo_GetSummary_NotWildcard(t *testing.T) {
|
|
info := &WildcardInfo{IsWildcard: false}
|
|
got := info.GetSummary()
|
|
if got == "" {
|
|
t.Error("GetSummary returned empty string")
|
|
}
|
|
}
|
|
|
|
func TestNewWildcardDetector(t *testing.T) {
|
|
resolvers := []string{"8.8.8.8:53"}
|
|
wd := NewWildcardDetector(resolvers, 5)
|
|
if wd == nil {
|
|
t.Fatal("NewWildcardDetector returned nil")
|
|
}
|
|
if wd.timeout != 5 {
|
|
t.Errorf("timeout = %d, want 5", wd.timeout)
|
|
}
|
|
if len(wd.resolvers) != 1 || wd.resolvers[0] != "8.8.8.8:53" {
|
|
t.Errorf("resolvers = %v", wd.resolvers)
|
|
}
|
|
if wd.httpClient == nil {
|
|
t.Error("httpClient is nil")
|
|
}
|
|
if len(wd.testSubdomains) == 0 {
|
|
t.Error("testSubdomains is empty")
|
|
}
|
|
}
|