Upgrading to 6.0.15: the request shield
Exponential 6.0.15 brings the request shield, the extension exp_request_shield (request-shield 0.4.0, a small web
application firewall that decides every request before the kernel). This page says what changes for an existing
installation that moves to the 6.0.15 line, and what you have to do yourself.
Feature reference: The request shield · Guide: Setting up the request shield · Help: Request shield: start here
In short
- Nothing is filtered until the hook is in
config.php. An upgrade never edits the site'sconfig.php. The package arrives withcomposer.json, the administration shows Setup > Request shield, but every request reaches the site as before until you add the two hook lines. - The root
composer.jsonrequiresse7enxweb/exp_request_shield(~0.0.1.0).composer updateinstalls it inextension/exp_request_shield/. config.php-RECOMMENDEDhas a new section REQUEST SHIELD that loads the hook, above the HTTP cache's early exit. Aconfig.phpmade from it for a new installation is protected from the first request.- Activate the extension yourself on an existing installation (
ActiveExtensions[]=exp_request_shield); the 6.0.15 site packages do it for new installations. settings/menu.inilists Request shield in the Setup menu right after Log files; the link is shown only when the extension is active and the user holdsrequestshield/read.- Two new policies,
requestshield/readandrequestshield/manage. Only the Administrator role holds them. - Under Exponential Velocity,
index.phpnow runs the file named inEXP_REQUEST_PREPEND_FILE; that is how the shield reaches every Velocity request.
Contents
- What changes
- What to do
- The new Setup menu entry and policies
- Under Velocity
- If you do not want it
- Check after the upgrade
What changes
| Where | Before 6.0.15 | From 6.0.15 |
|---|---|---|
composer.json (root) | no request shield | requires se7enxweb/exp_request_shield ~0.0.1.0 |
config.php-RECOMMENDED | no shield | section REQUEST SHIELD: the hook, before the HTTP cache's early exit, with the constants EXP_REQUEST_SHIELD_RULES and EXP_REQUEST_SHIELD_DISABLED as comments |
The site's own config.php | unchanged | unchanged: the upgrade does not touch it |
settings/menu.ini | Links[request_shield]=requestshield/dashboard in the System group of the Setup menu, after logs | |
index.php | runs the file named in EXP_REQUEST_PREPEND_FILE at the start of every request (for Velocity) | |
Site packages sevenx_site, sevenx_multisite, cjw_multisite and their _clean variants | activate exp_request_shield in new installations | |
| The HTTP cache | a request the shield marks allow-uncached is answered and never stored (HTTP cache notes) |
composer create-project of the distributions resolves to v6.0.14 until a 6.0.15 release is tagged; such a new
installation gets none of this and can add the shield with composer require se7enxweb/exp_request_shield.
What to do
On an existing installation that moved to the 6.0.15 line:
Make sure the package is there (
extension/exp_request_shield/); otherwisecomposer require se7enxweb/exp_request_shield.Activate it in
settings/override/site.ini.append.php:[ExtensionSettings] ActiveExtensions[]=exp_request_shieldRegenerate the autoloads and clear the caches (
php bin/php/ezpgenerateautoloads.php -e,php bin/php/ezcache.php --clear-all), or./console exp:velocity deploy --packerwhere it exists.Give the site its own rule file and check it (guide, section 2): the shipped rules enforce. Keep
www.example.orgin a host line, so the shipped examples pass.Add the hook to
config.php, above the line that loadsezphttpcacheearlyexit.php:if ( is_file( __DIR__ . '/extension/exp_request_shield/bootstrap/hook.php' ) ) require __DIR__ . '/extension/exp_request_shield/bootstrap/hook.php';Compare your
config.phpwithconfig.php-RECOMMENDEDfor the comment that goes with it.Under Velocity,
./console exp:velocity restart.Read Setup > Request shield > Log in the first days and add exceptions for anything a real visitor or editor did; switch to monitor while you look.
The new Setup menu entry and policies
| Policy | Allows |
|---|---|
requestshield/read | the dashboard, the log and the rules page (Setup > Request shield) |
requestshield/manage | the switches on the dashboard: pause and switch on, enforce, monitor, off |
Only the Administrator role, which holds every policy, has them after the upgrade. Give them to another role in
Roles and policies if someone else should see or switch the shield. Users without requestshield/read do not
see the menu entry.
The pages exist in admin4 and admin4l, exp_adminui's adminui design and the classic admin design, light and dark.
Their stylesheet is packed by ezjscore: after the upgrade clear the ezjscore-packer and template-block caches
(part of --clear-all) so the pages are styled.
Under Velocity
- The shield needs the 6.0.15
index.php, which runsEXP_REQUEST_PREPEND_FILE. The hook defines that constant under Velocity; an olderindex.phpnever runs it, so Velocity's requests are then not filtered while PHP-FPM's are. - Restart Velocity after adding or removing the hook. Rule changes need no restart.
- With PHP-FPM and Velocity serving the same site,
set store filein the rule file lets both share the counters. - The answers are identical to PHP-FPM's.
EXP_REQUEST_PREPEND_FILEnames one file. The hook defines it only when it is not defined yet: if yourconfig.phpalready names a file of its own there, the shield does not run under Velocity. Then requireextension/exp_request_shield/bootstrap/prepend.phpat the start of your own file.
If you do not want it
Leave the hook out of config.php: nothing is filtered. To keep the code but hide the administration pages, do not
activate the extension. On an installation whose root composer.json requires the package, keep it installed rather
than removing the requirement, so the next composer update does not fight you.
To switch an installed shield off at once: create var/request-shield/PAUSED, or define
EXP_REQUEST_SHIELD_DISABLED as true before the hook line.
Check after the upgrade
- Setup > Request shield shows the mode, the main rule file and no notice "did not run for this page".
php extension/exp_request_shield/bin/request-shield check settings/request-shield/request-shield.rulesandtestpass, run as the web user.curl -sI https://<your host>/settings/site.inianswers 404, andvar/request-shield/log/shield.loghas the line.- The front page, the login and an edit in the administration work as before (the administration asks for the browser check once per pass).