'automation', 2 => 'device consistency', 3 => 'behaviour', 4 => 'network', 5 => 'click farms', 6 => 'identity fraud', 7 => 'traffic source', 8 => 'ad abuse', ]; const INVALID_THRESHOLD = 60; const PILE_UP = 200; private static $signals = null; private static function server_signals() { return [ ['id' => 'f4.hosting_hostname', 'family' => 4, 'tier' => 'server', 'weight' => 70, 'label' => 'Address resolves to a hosting company\'s host name'], ['id' => 'f4.known_proxy_headers', 'family' => 4, 'tier' => 'server', 'weight' => 40, 'label' => 'Proxy headers present'], ['id' => 'f4.header_order_anomaly', 'family' => 4, 'tier' => 'server', 'weight' => 45, 'label' => 'Header order does not match the claimed browser'], ['id' => 'f4.missing_accept_language', 'family' => 4, 'tier' => 'server', 'weight' => 40, 'label' => 'No Accept-Language header'], ['id' => 'f4.missing_accept_encoding', 'family' => 4, 'tier' => 'server', 'weight' => 35, 'label' => 'No Accept-Encoding header'], ['id' => 'f4.accept_anomaly', 'family' => 4, 'tier' => 'server', 'weight' => 30, 'label' => 'Accept header does not match a browser navigation'], ['id' => 'f4.ua_missing', 'family' => 4, 'tier' => 'server', 'weight' => 60, 'label' => 'No User-Agent header'], ['id' => 'f4.ua_library', 'family' => 4, 'tier' => 'server', 'weight' => 90, 'label' => 'User-Agent is an HTTP library'], ['id' => 'f4.ua_inconsistent_sec_ch', 'family' => 4, 'tier' => 'server', 'weight' => 45, 'label' => 'Client hints contradict the User-Agent'], ['id' => 'f4.ip_version_mismatch', 'family' => 4, 'tier' => 'server', 'weight' => 20, 'label' => 'Forwarded address disagrees with the peer address'], ['id' => 'f4.ja3_known_bad', 'family' => 4, 'tier' => 'server', 'weight' => 60, 'label' => 'TLS fingerprint matches a known automation stack', 'optional' => true], ['id' => 'f7.referrer_spoofed', 'family' => 7, 'tier' => 'server', 'weight' => 55, 'label' => 'Referrer claims a search engine that does not link here'], ['id' => 'f7.referrer_self_loop', 'family' => 7, 'tier' => 'server', 'weight' => 25, 'label' => 'Referrer is this page itself'], ['id' => 'f7.utm_bot_pattern', 'family' => 7, 'tier' => 'server', 'weight' => 30, 'label' => 'Campaign parameters match a known bot template'], ['id' => 'f7.paid_source_mismatch', 'family' => 7, 'tier' => 'server', 'weight' => 15, 'label' => 'Claimed paid source with no matching click identifier'], ]; } public static function all() { if (self::$signals !== null) { return self::$signals; } $signals = []; $path = ADGHOST_PLUGIN_DIR . 'includes/ivt/signals.json'; if (file_exists($path)) { $data = json_decode(file_get_contents($path), true); if (is_array($data) && !empty($data['signals']) && is_array($data['signals'])) { foreach ($data['signals'] as $row) { if (!empty($row['id'])) { $signals[$row['id']] = [ 'id' => (string) $row['id'], 'family' => (int) ($row['family'] ?? 0), 'tier' => (string) ($row['tier'] ?? 'fast'), 'weight' => (int) ($row['weight'] ?? 0), 'label' => (string) ($row['label'] ?? $row['id']), ]; } } } } foreach (self::server_signals() as $row) { $signals[$row['id']] = $row + ['optional' => false, 'consent' => false]; } if (class_exists('AdGhost_Correlation')) { foreach (AdGhost_Correlation::signals() as $row) { $signals[$row['id']] = $row + ['optional' => false, 'consent' => false]; } } self::$signals = $signals; return $signals; } public static function consent_required() { return array_values(array_filter(self::all(), function ($s) { return !empty($s['consent']); })); } public static function get($id) { $all = self::all(); return $all[$id] ?? null; } public static function by_family($family) { return array_values(array_filter(self::all(), function ($s) use ($family) { return $s['family'] === (int) $family; })); } public static function by_tier($tier) { return array_values(array_filter(self::all(), function ($s) use ($tier) { return $s['tier'] === $tier; })); } public static function count() { return count(self::all()); } public static function family_counts() { $counts = array_fill_keys(array_keys(self::FAMILIES), 0); foreach (self::all() as $signal) { if (isset($counts[$signal['family']])) { $counts[$signal['family']]++; } } return $counts; } public static function score(array $fired) { $score = 0; $hard = false; $matched = []; $unknown = []; foreach (array_unique($fired) as $id) { $signal = self::get($id); if ($signal === null) { $unknown[] = (string) $id; continue; } $score += $signal['weight']; $matched[] = $signal; if ($signal['weight'] >= 100) { $hard = true; } } if (count($matched) >= 3 && $score >= self::PILE_UP) { $hard = true; } $score = min(100, $score); return [ 'score' => $score, 'hard' => $hard, 'verdict' => ($hard || $score >= self::INVALID_THRESHOLD) ? 'invalid' : 'clean', 'matched' => $matched, 'unknown' => $unknown, ]; } }