feat(Production): Complete production deployment infrastructure

- Add comprehensive health check system with multiple endpoints
- Add Prometheus metrics endpoint
- Add production logging configurations (5 strategies)
- Add complete deployment documentation suite:
  * QUICKSTART.md - 30-minute deployment guide
  * DEPLOYMENT_CHECKLIST.md - Printable verification checklist
  * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle
  * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference
  * production-logging.md - Logging configuration guide
  * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation
  * README.md - Navigation hub
  * DEPLOYMENT_SUMMARY.md - Executive summary
- Add deployment scripts and automation
- Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment
- Update README with production-ready features

All production infrastructure is now complete and ready for deployment.
This commit is contained in:
2025-10-25 19:18:37 +02:00
parent caa85db796
commit fc3d7e6357
83016 changed files with 378904 additions and 20919 deletions

View File

@@ -7,8 +7,9 @@ namespace App\Framework\Waf\MachineLearning;
use App\Framework\Core\ValueObjects\Duration;
use App\Framework\Core\ValueObjects\Percentage;
use App\Framework\DateTime\Clock;
use App\Framework\Waf\MachineLearning\ValueObjects\BehaviorBaseline;
use App\Framework\Waf\MachineLearning\ValueObjects\BehaviorFeature;
use App\Framework\MachineLearning\ValueObjects\Baseline;
use App\Framework\MachineLearning\ValueObjects\Feature;
use App\Framework\MachineLearning\ValueObjects\FeatureType;
/**
* Manages behavioral baselines for anomaly detection
@@ -34,7 +35,7 @@ final class BaselineManager
/**
* Get baseline for a specific behavior type and feature
*/
public function getBaseline(BehaviorType $behaviorType, string $featureName = 'default'): ?BehaviorBaseline
public function getBaseline(FeatureType $behaviorType, string $featureName = 'default'): ?Baseline
{
$key = $this->generateBaselineKey($behaviorType, $featureName);
@@ -57,7 +58,7 @@ final class BaselineManager
/**
* Update baseline with new feature data
*/
public function updateBaseline(BehaviorFeature $feature): void
public function updateBaseline(Feature $feature): void
{
$key = $this->generateBaselineKey($feature->type, $feature->name);
@@ -92,7 +93,7 @@ final class BaselineManager
/**
* Update baseline incrementally with new feature
*/
public function updateBaselineIncremental(BehaviorFeature $feature): void
public function updateBaselineIncremental(Feature $feature): void
{
$key = $this->generateBaselineKey($feature->type, $feature->name);
$existingBaseline = $this->baselines[$key] ?? null;
@@ -116,7 +117,7 @@ final class BaselineManager
/**
* Get all baselines for a behavior type
*/
public function getBaselinesForBehaviorType(BehaviorType $behaviorType): array
public function getBaselinesForFeatureType(FeatureType $behaviorType): array
{
$baselines = [];
@@ -181,7 +182,7 @@ final class BaselineManager
'active_baselines' => $totalBaselines - $expiredBaselines,
'avg_sample_size' => $avgSampleSize,
'avg_age_seconds' => $avgAge,
'behavior_types' => $this->getBaselineBehaviorTypes(),
'behavior_types' => $this->getBaselineFeatureTypes(),
'feature_history_size' => array_sum(array_map('count', $this->featureHistory)),
];
}
@@ -189,9 +190,9 @@ final class BaselineManager
/**
* Create initial baseline from feature history
*/
private function createInitialBaseline(BehaviorType $behaviorType, string $featureName, array $featureHistory): BehaviorBaseline
private function createInitialBaseline(FeatureType $behaviorType, string $featureName, array $featureHistory): Baseline
{
$values = array_map(fn (BehaviorFeature $f) => $f->value, $featureHistory);
$values = array_map(fn (Feature $f) => $f->value, $featureHistory);
$stats = $this->calculateStatistics($values);
$confidence = $this->calculateBaselineConfidence($stats['sample_size']);
@@ -201,7 +202,7 @@ final class BaselineManager
$stats = $this->applySeasonalAdjustment($stats, $featureHistory);
}
return new BehaviorBaseline(
return new Baseline(
type: $behaviorType,
mean: $stats['mean'],
standardDeviation: $stats['std_dev'],
@@ -222,13 +223,13 @@ final class BaselineManager
/**
* Update existing baseline with new data
*/
private function updateExistingBaseline(BehaviorBaseline $existingBaseline, array $featureHistory): BehaviorBaseline
private function updateExistingBaseline(Baseline $existingBaseline, array $featureHistory): Baseline
{
if (! $this->enableAdaptiveBaselines) {
return $existingBaseline;
}
$values = array_map(fn (BehaviorFeature $f) => $f->value, $featureHistory);
$values = array_map(fn (Feature $f) => $f->value, $featureHistory);
$newStats = $this->calculateStatistics($values);
// Adaptive learning rate based on sample size and confidence
@@ -249,7 +250,7 @@ final class BaselineManager
$newSampleSize = min($existingBaseline->sampleSize + $newStats['sample_size'], $this->maxSamplesPerBaseline);
$confidence = $this->calculateBaselineConfidence($newSampleSize);
return new BehaviorBaseline(
return new Baseline(
type: $existingBaseline->type,
mean: $updatedMean,
standardDeviation: $updatedStdDev,
@@ -270,7 +271,7 @@ final class BaselineManager
/**
* Incremental update using exponential moving average
*/
private function incrementalUpdate(BehaviorBaseline $baseline, BehaviorFeature $newFeature): BehaviorBaseline
private function incrementalUpdate(Baseline $baseline, Feature $newFeature): Baseline
{
$learningRate = $this->calculateAdaptiveLearningRate($baseline, 1);
@@ -283,7 +284,7 @@ final class BaselineManager
$updatedVariance = $variance * (1 - $learningRate) + $delta * $delta2 * $learningRate;
$updatedStdDev = sqrt(max(0, $updatedVariance));
return new BehaviorBaseline(
return new Baseline(
type: $baseline->type,
mean: $updatedMean,
standardDeviation: $updatedStdDev,
@@ -357,7 +358,7 @@ final class BaselineManager
/**
* Calculate adaptive learning rate
*/
private function calculateAdaptiveLearningRate(BehaviorBaseline $baseline, int $newSamples): float
private function calculateAdaptiveLearningRate(Baseline $baseline, int $newSamples): float
{
// Decrease learning rate as confidence increases
$confidenceFactor = 1.0 - ($baseline->confidence->getValue() / 100.0);
@@ -421,7 +422,7 @@ final class BaselineManager
/**
* Record feature in history
*/
private function recordFeature(string $key, BehaviorFeature $feature): void
private function recordFeature(string $key, Feature $feature): void
{
if (! isset($this->featureHistory[$key])) {
$this->featureHistory[$key] = [];
@@ -454,7 +455,7 @@ final class BaselineManager
/**
* Check if baseline is expired
*/
private function isBaselineExpired(BehaviorBaseline $baseline): bool
private function isBaselineExpired(Baseline $baseline): bool
{
$age = $baseline->lastUpdated->diff($this->clock->time());
@@ -464,7 +465,7 @@ final class BaselineManager
/**
* Generate baseline key
*/
private function generateBaselineKey(BehaviorType $behaviorType, string $featureName): string
private function generateBaselineKey(FeatureType $behaviorType, string $featureName): string
{
return $behaviorType->value . ':' . $featureName;
}
@@ -472,7 +473,7 @@ final class BaselineManager
/**
* Get behavior types with baselines
*/
private function getBaselineBehaviorTypes(): array
private function getBaselineFeatureTypes(): array
{
$types = [];