31 lines
788 B
Python
31 lines
788 B
Python
from __future__ import annotations
|
|
from dataclasses import dataclass, field
|
|
from typing import List, Optional
|
|
|
|
|
|
@dataclass
|
|
class PortFinding:
|
|
"""
|
|
A single discovered port on a host.
|
|
protocol: 'tcp' or 'udp'
|
|
state: 'open', 'closed', 'filtered', 'open|filtered', etc.
|
|
service: optional nmap-reported service name (e.g., 'ssh', 'http')
|
|
"""
|
|
port: int
|
|
protocol: str
|
|
state: str
|
|
service: Optional[str] = None
|
|
|
|
|
|
@dataclass
|
|
class HostResult:
|
|
"""
|
|
Results for a single host.
|
|
address: IP address (e.g., '192.0.2.10')
|
|
host: primary hostname if reported by nmap (may be None)
|
|
ports: list of PortFinding instances for this host
|
|
"""
|
|
address: str
|
|
host: Optional[str] = None
|
|
ports: List[PortFinding] = field(default_factory=list)
|