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:
2026-09-26 19:32:12 +02:00
co-authored by Claude Opus 5.5
parent 4d4bf57c9f
commit b24eb6c3e9
185 changed files with 418 additions and 1 deletions
+2
View File
@@ -6,6 +6,8 @@ namespace LIT\MCP\Admin;
use LIT\MCP\Access;
defined('ABSPATH') || exit;
/**
* Tab "Zugriff": roles allowed to use LIT MCP and the active OAuth connections
* with revocation (spec §8.4).
+2
View File
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace LIT\MCP\Admin;
defined('ABSPATH') || exit;
/**
* Admin notices for administrators (Etappe-0 follow-up d). Uses only cached check
* results so no HTTP request runs on ordinary admin page loads.
+2
View File
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace LIT\MCP\Admin;
defined('ABSPATH') || exit;
/**
* The frame of an admin-post.php handler of the settings page: only administrators
* (manage_options, else 403), and after the action a redirect back to the tab with a notice.
+2
View File
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace LIT\MCP\Admin;
defined('ABSPATH') || exit;
/**
* One tab of the settings page "Einstellungen → LIT MCP".
*/
+2
View File
@@ -6,6 +6,8 @@ namespace LIT\MCP\Admin;
use WPMedia\MCP\OAuth\Auth\TokenEndpoint;
defined('ABSPATH') || exit;
/**
* OAuth connections created by mcp-oauth (v1.1.2, TokenEndpoint): for every grant it
* creates one application password (name = client name, app_id = the CIMD client_id,
+2
View File
@@ -9,6 +9,8 @@ use WP\MCP\Core\McpAdapter;
use WPMedia\MCP\OAuth\Auth\Discovery\HealthCheck;
use WPMedia\MCP\OAuth\Context as OAuthContext;
defined('ABSPATH') || exit;
/**
* Connection checks for the settings page, admin notices and Site Health.
* Not final so notices and Site Health can be tested with a mock.
+2
View File
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace LIT\MCP\Admin;
defined('ABSPATH') || exit;
final class ConnectionTab implements AdminTab
{
public function __construct(private ConnectionStatus $status)
+2
View File
@@ -10,6 +10,8 @@ use WP_REST_Request;
use WPMedia\MCP\OAuth\Auth\JWT;
use WPMedia\MCP\OAuth\Auth\SecretManager;
defined('ABSPATH') || exit;
/**
* Records when an OAuth connection was last used, for "Zuletzt genutzt" in the tab "Zugriff".
*
+2
View File
@@ -6,6 +6,8 @@ namespace LIT\MCP\Admin;
use LIT\MCP\Limits;
defined('ABSPATH') || exit;
/**
* Tab "Limits": upload/download size and log retention (spec §8.4). The snapshot count is
* kept as a hidden field until the design system feature that uses it exists.
+2
View File
@@ -7,6 +7,8 @@ namespace LIT\MCP\Admin;
use LIT\MCP\ChangeLog\ChangeLog;
use WP_Post;
defined('ABSPATH') || exit;
// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- method names are defined by WP_List_Table.
/**
+2
View File
@@ -7,6 +7,8 @@ namespace LIT\MCP\Admin;
use WP_Post;
use WP_Term;
defined('ABSPATH') || exit;
/**
* Human names for the objects in the change log ("Seite: Kontakt" instead of "page 834"),
* linked to their edit screen where one exists and the current user may use it. prime()
+2
View File
@@ -8,6 +8,8 @@ use LIT\MCP\ChangeLog\ChangeLog;
use LIT\MCP\Integrations\IntegrationRegistry;
use LIT\MCP\Limits;
defined('ABSPATH') || exit;
/**
* Tab "Protokoll": filterable list of change log entries, links to revisions, and
* "Protokoll leeren" (spec §8.3). Page size and visible columns via WordPress'
+2
View File
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace LIT\MCP\Admin;
defined('ABSPATH') || exit;
/**
* Settings page "Einstellungen → LIT MCP" with tabs (spec §8.4). Settings API, no JS framework.
*/
+2
View File
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace LIT\MCP\Admin;
defined('ABSPATH') || exit;
/**
* Site Health test for our MCP endpoint (401 + WWW-Authenticate without a token).
* The discovery documents are covered by mcp-oauth's own Site Health test.
+2
View File
@@ -8,6 +8,8 @@ use LIT\MCP\Abilities\Ability;
use LIT\MCP\Abilities\ExposurePolicy;
use LIT\MCP\Integrations\IntegrationRegistry;
defined('ABSPATH') || exit;
/**
* Tab "Tools": direct/indirect/disabled exposure per ability (spec §8.4), grouped by the
* integration the ability comes from. Each group has its own mode (inherited by its tools)