- Phinx миграции: network_ranges, scan_jobs, discovered_hosts, audit_log - Models: NetworkRange, ScanJob, DiscoveredHost - Repositories с CRUD для всех сущностей - NetworkScanner: ping sweep + TCP connect + ARP table + reverse DNS - PingScanner, TcpPortScanner (curl_multi для параллелизма), ArpTableReader - HostFingerprintService: vendor detection + confidence scoring - ScanJobRunner + CLI worker (bin/run-scan-worker.php) - Discovery UI: управление диапазонами, запуск скана, таблица находок - NetworkRangeController с валидацией CIDR - Обновлён public/index.php с DI конфигурацией для новых сервисов
35 lines
1.7 KiB
PHP
35 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Migration\AbstractMigration;
|
|
|
|
final class CreateDiscoveredHosts extends AbstractMigration
|
|
{
|
|
public function change(): void
|
|
{
|
|
$table = $this->table('discovered_hosts');
|
|
$table
|
|
->addColumn('scan_job_id', 'integer', ['null' => true])
|
|
->addColumn('ip_address', 'string', ['limit' => 45, 'null' => false])
|
|
->addColumn('mac_address', 'string', ['limit' => 17, 'null' => true])
|
|
->addColumn('hostname', 'string', ['limit' => 255, 'null' => true])
|
|
->addColumn('vendor', 'string', ['limit' => 255, 'null' => true])
|
|
->addColumn('detected_os', 'string', ['limit' => 255, 'null' => true])
|
|
->addColumn('open_ports_json', 'text', ['null' => true])
|
|
->addColumn('protocols_json', 'text', ['null' => true])
|
|
->addColumn('fingerprint_json', 'text', ['null' => true])
|
|
->addColumn('confidence', 'integer', ['null' => false, 'default' => 50])
|
|
->addColumn('status', 'string', ['limit' => 20, 'null' => false, 'default' => 'new'])
|
|
->addColumn('matched_device_id', 'integer', ['null' => true])
|
|
->addColumn('first_seen', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
|
|
->addColumn('last_seen', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
|
|
->addColumn('created_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
|
|
->addColumn('updated_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
|
|
->addIndex(['ip_address'])
|
|
->addIndex(['mac_address'])
|
|
->addIndex(['status'])
|
|
->create();
|
|
}
|
|
}
|