|null $adapters Adapters; the launch set by default. */ public function __construct( private readonly ?array $adapters = null ) { } /** * {@inheritDoc} */ public function id(): string { return self::ID; } /** * {@inheritDoc} */ public function label(): string { return __( 'MCP plugins on the store', 'agentic-daisy-ai-agent-firewall-for-woocommerce' ); } /** * {@inheritDoc} * * @return list */ public function run(): array { $adapters = $this->adapters ?? Adapters::all(); $findings = array(); $covered = array(); foreach ( $adapters as $adapter ) { $covered[] = dirname( $adapter->plugin_file() ); if ( Adapters::UNTESTED !== Adapters::status( $adapter ) ) { continue; } list( $lowest, $beyond ) = $adapter->tested(); $findings[] = new Finding( self::ID, Severity::ATTENTION, __( 'An MCP plugin version the firewall was not tested with', 'agentic-daisy-ai-agent-firewall-for-woocommerce' ), sprintf( /* translators: 1: lowest tested version, 2: first untested version. */ __( 'Agents connecting through this plugin are not identified, so what they write is not governed: it is refused only when Agent Firewall refuses unclaimed credentials. The adapter was tested with versions from %1$s up to, not including, %2$s. Update Agent Firewall for WooCommerce, or use a tested version.', 'agentic-daisy-ai-agent-firewall-for-woocommerce' ), $lowest, $beyond ), $adapter->name() . ' ' . (string) Adapters::version( $adapter ), null, self::ID . ':untested:' . $adapter->id() ); } foreach ( self::active_plugins() as $file ) { $slug = strtolower( dirname( $file ) ); if ( in_array( $slug, $covered, true ) || in_array( $slug, self::GOVERNED, true ) || ! self::is_mcp( $slug ) ) { continue; } $findings[] = new Finding( self::ID, Severity::ATTENTION, __( 'An MCP plugin the firewall cannot see through', 'agentic-daisy-ai-agent-firewall-for-woocommerce' ), __( 'This plugin appears to let AI agents connect with its own credentials and act through its own code. Agent Firewall has no adapter for it, so those agents are not identified and what they write is not governed. Deactivate it if no agent needs it, or connect agents through WooCommerce REST API keys or application passwords bound to agents instead.', 'agentic-daisy-ai-agent-firewall-for-woocommerce' ), self::name( $file ), null, self::ID . ':no_adapter:' . $slug ); } return $findings; } /** * Whether a slug names an in-site MCP plugin. * * @param string $slug Plugin directory. */ private static function is_mcp( string $slug ): bool { if ( 1 === preg_match( '/(^|[^a-z])mcp([^a-z]|$)/', $slug ) ) { return true; } foreach ( self::KNOWN as $known ) { if ( str_contains( $slug, $known ) ) { return true; } } return false; } /** * Every active plugin's main file, site and network. * * @return list */ private static function active_plugins(): array { $active = array_map( 'strval', (array) get_option( 'active_plugins', array() ) ); if ( is_multisite() ) { $active = array_merge( $active, array_map( 'strval', array_keys( (array) get_site_option( 'active_sitewide_plugins', array() ) ) ) ); } return array_values( array_unique( $active ) ); } /** * A plugin's name from its header, or its file. * * @param string $file Main file, relative to the plugins directory. */ private static function name( string $file ): string { $path = WP_PLUGIN_DIR . '/' . $file; $name = is_readable( $path ) ? get_file_data( $path, array( 'name' => 'Plugin Name' ) )['name'] : ''; return '' === $name ? $file : $name; } }