Redis management
tool_redis
Admin tool that adds a 'Redis management' page under Site administration > Server. It shows statistics (hit rate, memory, uptime, connections, persistence, per-database key counts and the raw INFO sections) for every Redis server Moodle uses as a cache store or session store, and lets site administrators flush individual Redis databases after a confirmation dialog.
No security, code-quality or compliance defects were found after reading every PHP, Mustache, CSS and Behat file in the plugin and checking the relevant core APIs.
- Access control: the only entry point,
index.php, callsadmin_externalpage_setup('tool_redis'). In core, that function callsrequire_login()and thenexternalpage::check_access(), which requires themoodle/site:configcapability registered insettings.php. - CSRF: the destructive flush action runs
require_sesskey(). Its parameters are typed (PARAM_INT,PARAM_ALPHA) and checked: the server index must exist and the database number must not be negative. The action uses POST throughsingle_button, shows a confirmation modal, and redirects afterwards so a reload cannot repeat the flush. - Output: all data from Redis (INFO keys and values, store names, hosts) goes through escaped Mustache variables. The only triple-brace outputs are HTML produced by core renderers (charts and
single_button). - Connection handling: the plugin does not open Redis connections itself. It subclasses
cachestore_redisand\core\session\redis, so it connects exactly as core does, with the same TLS, authentication and timeouts. The session handler subclass never callsinit(), so it does not replace the active session handler. - Privacy and libraries: a null privacy provider is present and accurate. No third-party libraries are bundled.
The Behat fixture that changes Redis state over GET can only run on a Behat site (BEHAT_SITE_RUNNING) and also requires an admin, so it cannot be reached on production sites.
tool_redis is a small admin tool of about 1,000 lines across 8 PHP files, one Mustache template and a Behat suite. It adds a Redis monitoring dashboard to Site administration and can flush individual Redis databases. It targets Moodle 5.3 only and requires cachestore_redis.
The security posture is strong. The page is protected by admin_externalpage_setup(), which in core runs require_login() and checks moodle/site:config. The flush action is a sesskey-protected POST with validated integer parameters, a confirmation modal, and a redirect afterwards. Values returned by Redis INFO are rendered only through escaped Mustache variables.
The plugin does not build its own Redis client. It subclasses the core Redis cache store and session handler to reuse their connection logic (TLS, auth, cluster mode, timeouts). After flushing a non-default database it carefully re-selects the original one, so the shared connection is left as it was.
No findings were raised; the notes below cover a few observations that are not defects.
Findings
Flush scope is the whole Redis database. server::flush_database() runs FLUSHDB, which deletes every key in the selected database. That includes keys of other Moodle sites or applications that share the server through a key prefix, not only this site's cache or sessions. This is deliberate, admin-only behaviour, and the confirmation modal plus the 'used by other clients' hint warn about it. Administrators of shared Redis instances should still know that flushing the session store's database logs out every user, including themselves.
Behat fixture changes state over GET. tests/behat/fixtures/redis_entry.php stores, checks or flushes Redis keys based on GET parameters, without a sesskey. It exits unless BEHAT_SITE_RUNNING is defined and also calls require_admin(), so it cannot be reached on a production site. This is the usual pattern for core test fixtures and is not reported as a defect.
Cluster-mode handling is careful. Flushing is refused for any database other than db0 on cluster nodes, because phpredis cannot select a database there. This avoids silently flushing db0 when a Valkey 9 cluster exposes several databases.