fix(security): no direct HTTP access to plugin PHP files (audit L2, cheap part)
Every file under src/ exits outside WordPress (defined('ABSPATH') ||
exit; after the use block, so a direct request no longer prints a fatal
error with the server path); divi-convert-fixture.php gets the WP_CLI
guard the other integration scripts have. A unit test keeps both true;
PSR1 side-effects warning excluded for the guard.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -6,6 +6,8 @@ namespace LIT\MCP\Server;
|
||||
|
||||
use LIT\MCP\Access;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* Stops mcp-oauth's browser flow for logged-in users without lit_mcp_use (security audit L1).
|
||||
* mcp-oauth only checks is_user_logged_in() and offers no filter, so this runs on
|
||||
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Server;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* Keeps WordPress' canonical redirect away from mcp-oauth's two discovery documents.
|
||||
* With a pretty permalink structure ending in "/", WordPress 301-redirects
|
||||
|
||||
@@ -9,6 +9,8 @@ use WP_REST_Request;
|
||||
use WPMedia\MCP\OAuth\Auth\JWT;
|
||||
use WPMedia\MCP\OAuth\Auth\SecretManager;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* Tracks whether the current REST dispatch is serving our OAuth-protected MCP
|
||||
* server route (`/mcp/mcp-oauth-server`) and which OAuth client made it.
|
||||
|
||||
@@ -15,6 +15,8 @@ use WPMedia\MCP\OAuth\Context as OAuthContext;
|
||||
use WPMedia\MCP\OAuth\Transport\OAuthHttpTransport;
|
||||
use WPMedia\MCP\OAuth\Transport\ServerRegistrar as OAuthServerRegistrar;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* Registers the OAuth-protected MCP server with our own tool list.
|
||||
*
|
||||
|
||||
@@ -8,6 +8,8 @@ use LIT\MCP\Access;
|
||||
use WP\MCP\Core\McpServer;
|
||||
use WP\McpSchema\Common\Protocol\DTO\InitializeResult;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* Users who may connect (mcp-oauth) but are not allowed to use LIT MCP get neither
|
||||
* the tool list nor the site-specific instructions of our server. Execution is
|
||||
|
||||
Reference in New Issue
Block a user