argument('paths')); $top = max(1, (int) $this->option('top')); $report = $analyzer->analyze($paths, $top); $this->info('Legacy-API-Access-Log-Auswertung'); $this->newLine(); $this->line("Dateien: {$report['summary']['files']}"); $this->line("Log-Zeilen: {$report['summary']['total_lines']}"); $this->line("Legacy-API-Requests: {$report['summary']['matched_requests']}"); $this->line("Requests mit api_key: {$report['summary']['legacy_key_requests']}"); $this->line("Eindeutige Client-IPs: {$report['summary']['unique_client_ips']}"); $this->line("Eindeutige API-Key-Fingerprints: {$report['summary']['unique_api_key_fingerprints']}"); if ($report['missing_paths'] !== []) { $this->newLine(); $this->warn('Nicht lesbare Pfade:'); foreach ($report['missing_paths'] as $path) { $this->line(" - {$path}"); } } $this->renderTopTable('Top Endpoints', $report['endpoints']); $this->renderTopTable('Top Client-IPs', $report['client_ips']); $this->renderTopTable('Statuscodes', $report['status_codes']); if (! (bool) $this->option('no-report')) { $path = 'migration/legacy-api-access-'.now()->format('Ymd-His').'.json'; Storage::disk('local')->put($path, json_encode($report, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); $this->newLine(); $this->line("Report geschrieben: storage/app/private/{$path}"); } return self::SUCCESS; } /** * @param array $rows */ private function renderTopTable(string $title, array $rows): void { if ($rows === []) { return; } $this->newLine(); $this->line($title); $this->table( ['Wert', 'Requests'], collect($rows) ->map(fn (int $count, string $value): array => [$value, $count]) ->values() ->all() ); } }