Add Security Monitoring System with Command, Model, and Service

- 🛡️ Introduce `SecurityMonitor` service for tampering and malicious activity detection.
- 🏷️ Add `SecurityAttempt` model and migration to log, categorize, and query security attempts.
- 🖥️ Create `SecurityAttemptsCommand` for filtering, statistics, and top IP analysis.
-  Add extensive tests to ensure the reliability of security monitoring and logging.
- 🔗 Integrate `SecurityMonitor` into the exception handling pipeline for real-time monitoring.
This commit is contained in:
HolgerHatGarKeineNode
2026-02-04 13:40:30 +01:00
parent 064ed68638
commit 5b814d631b
6 changed files with 664 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('security_attempts', function (Blueprint $table) {
$table->id();
$table->string('ip_address', 45)->index();
$table->string('user_agent', 500)->nullable();
$table->string('method', 10);
$table->string('url', 2000);
$table->string('route_name')->nullable();
$table->string('exception_class');
$table->string('exception_message', 1000);
$table->string('component_name')->nullable()->index();
$table->string('target_property')->nullable();
$table->json('payload')->nullable();
$table->string('severity')->default('medium')->index();
$table->timestamps();
$table->index('created_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('security_attempts');
}
};