<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class ASA_Aegisify_Correlation {

	public function run() {
		$plugins    = get_option( 'active_plugins', array() );
		$has_shield = false;
		$has_waf    = false;
		$has_spam   = false;
		foreach ( $plugins as $plugin ) {
			$haystack = strtolower( (string) $plugin );
			if ( false !== strpos( $haystack, 'shield' ) ) {
				$has_shield = true;
			}
			if ( false !== strpos( $haystack, 'waf' ) ) {
				$has_waf = true;
			}
			if ( false !== strpos( $haystack, 'spam' ) ) {
				$has_spam = true;
			}
		}

		$results = array();
		if ( $has_shield ) {
			$results[] = array( 'severity' => 'info', 'category' => 'shield', 'title' => 'Shield correlation', 'details' => 'A Shield-related plugin appears active for login/admin hardening correlation.' );
		}
		if ( $has_waf ) {
			$results[] = array( 'severity' => 'info', 'category' => 'waf', 'title' => 'WAF correlation', 'details' => 'A WAF-related plugin appears active for HTTP surface correlation.' );
		}
		if ( $has_spam ) {
			$results[] = array( 'severity' => 'info', 'category' => 'spam', 'title' => 'Spam correlation', 'details' => 'A Spam-related plugin appears active for abuse correlation.' );
		}

		return $results;
	}
}
