PHP code example of flowd / phirewall-preset-owasp-crs
1. Go to this page and download the library: Download flowd/phirewall-preset-owasp-crs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flowd / phirewall-preset-owasp-crs example snippets
use Flowd\Phirewall\Config;
use Flowd\PhirewallPresetOwaspCrs\ParanoiaLevel;
use Flowd\PhirewallPresetOwaspCrs\Presets;
$config = $config->with(
Presets::blocklist(ParanoiaLevel::Level1),
);
use Flowd\Phirewall\Config\Rule\BlocklistRule;
use Flowd\PhirewallPresetOwaspCrs\Engine\CoreRuleSetMatcher;
$coreRuleSet = Presets::coreRuleSet(ParanoiaLevel::Level2);
$coreRuleSet->disable(942430);
$config->blocklists->addRule(new BlocklistRule('my-crs-rule', new CoreRuleSetMatcher($coreRuleSet)));
$coreRuleSet = Presets::coreRuleSet(ParanoiaLevel::Level1)
->excludeTarget('ARGS:/^utm_/') // all rules ignore utm_* values
->excludeTarget('ARGS_NAMES:/^utm_/') // ... and the utm_* parameter names
->excludeTargetById(942431, 'ARGS:fbclid') // one rule ignores one parameter
->excludeTargetByTag('attack-sqli', 'ARGS:comment');