PHP code example of bdsa / wafy

1. Go to this page and download the library: Download bdsa/wafy 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/ */

    

bdsa / wafy example snippets



use Bdsa\Wafy\Middleware\BlockBannedIp;
use Bdsa\Wafy\Middleware\DetectMaliciousRequests;

Route::group(['middleware' => ['block.banned.ip', 'detect.malicious.requests']], function () {
    Route::get('/', function () {
        return view('welcome');
    });
    
    // Your protected routes
});

   // app/Console/Kernel.php
   $schedule->command('wafy:prune')->daily();
   

'rate_limit' => [
    'enabled'      => env('WAFY_RATE_LIMIT_ENABLED', false), // opt-in
    'window'       => 60,   // seconds
    'max_requests' => 300,  // total requests / IP / window (0 = off)
    'max_404'      => 40,   // 404s / IP / window (0 = off)
],

return [
    'enabled' => env('WAFY_ENABLED', true),
    'score_threshold' => env('WAFY_SCORE_THRESHOLD', 4),
    'rules' => [
        ['id' => 'sqli.union_select', 'score' => 5, 'pattern' => '/(union(\s+all)?\s+select)/i'],
        ['id' => 'sqli.tautology',    'score' => 4, 'pattern' => '/\b(or|and)\s+([\'"`]?)(\w+)\2\s*(=|<>|!=|<|>|\blike\b)\s*([\'"`]?)\3\b/i'],
        ['id' => 'xss.script_tag',    'score' => 5, 'pattern' => '/(<script.*
bash
php artisan vendor:publish --provider="Bdsa\Wafy\WafyServiceProvider"
bash
php artisan migrate
bash
  php artisan wafy:ban {ip_address} [--reason="Your reason"]
  
bash
  php artisan wafy:unban {ip_address}
  
bash
  php artisan wafy:list
  
bash
  php artisan wafy:mode {enable|disable}
  
bash
  php artisan wafy:action {block|log}
  
bash
  php artisan wafy:test-notification            # all configured channels
  php artisan wafy:test-notification --channel=discord
  
bash
  php artisan wafy:prune                # delete expired temporary bans
  php artisan wafy:prune --days=90      # also delete bans older than 90 days
  
bash
  php artisan wafy:rule list
  php artisan wafy:rule disable sqli.union_select   # runtime, cache-backed
  php artisan wafy:rule enable  sqli.union_select
  
bash
  php artisan wafy:rules:import path/to/rules.php   # .php | .json | .txt (one regex/line)
  
bash
  php artisan wafy:stats --days=7 --top=10 [--json]