Documentation
¶
Overview ¶
Package handlers provides HTTP request handlers for the Scanorama API. This file implements the AdminHandler type and its HTTP handler methods for configuration endpoints.
Package handlers - admin configuration retrieval and extraction.
Package handlers provides HTTP request handlers for the Scanorama API. This file implements the AdminHandler log retrieval endpoint backed by the in-memory ring buffer.
Package handlers - admin API types and request/response structures.
Package handlers - admin configuration validation.
Package handlers provides HTTP request handlers for the Scanorama API. This file implements worker management handler methods for the AdminHandler type.
Package handlers provides HTTP request handlers for the Scanorama API. This file implements TLS certificate endpoints.
Package handlers provides HTTP request handlers for the Scanorama API. This file contains common utilities shared across all handlers to reduce code duplication and provide consistent patterns.
Package handlers — device identity endpoints.
Package handlers provides HTTP request handlers for the Scanorama API. This file implements discovery job management endpoints including CRUD operations, discovery execution control, and results retrieval.
Package handlers — host group endpoints.
Package handlers provides HTTP request handlers for the Scanorama API. This file implements health check and system status endpoints.
Package handlers provides HTTP request handlers for the Scanorama API. This file implements host management endpoints including CRUD operations and host-related scan retrieval.
Package handlers provides HTTP request handlers for the Scanorama API. This file defines the narrow interfaces that each handler depends on, allowing unit tests to inject mocks without a live database.
Package handlers provides HTTP request handlers for the Scanorama API. This package implements REST endpoint handlers for scanning, discovery, host management, and administrative operations.
Package handlers provides HTTP request handlers for the Scanorama API. This file implements port definition lookup and browsing endpoints.
Package handlers provides HTTP request handlers for the Scanorama API. This file implements scan profile management endpoints including CRUD operations and profile configurations for different scan types.
Package handlers provides HTTP request handlers for the Scanorama API. This file implements scan management endpoints including CRUD operations, scan execution control, and result retrieval.
Validation and lifecycle business rules live in services.ScanService; this handler is a thin HTTP adapter (parse → call service → write response).
Package handlers provides HTTP request handlers for the Scanorama API. This file implements schedule management endpoints including CRUD operations and schedule activation/deactivation.
Package handlers - Smart Scan HTTP adapter. Thin HTTP layer over services.SmartScanService.
Package handlers - SNMP credential management endpoints.
Package handlers provides HTTP request handlers for the Scanorama API. This file implements the StatsHandler for summary statistics endpoints.
Package handlers — tag management endpoints. These methods are added to HostHandler since tags are a property of hosts.
Package handlers provides HTTP request handlers for the Scanorama API. This file implements WebSocket endpoints for real-time updates on scan and discovery job progress, status changes, and results.
Index ¶
- Constants
- func CreateEntity[T any, I any](w http.ResponseWriter, r *http.Request, entityType string, logger *slog.Logger, ...)
- func SetBuildInfo(v, c, bt string)
- func UpdateEntity[T any, I any](w http.ResponseWriter, r *http.Request, entityType string, logger *slog.Logger, ...)
- type APIConfigUpdate
- type AdminHandler
- func (h *AdminHandler) GetConfig(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) GetLogs(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) GetWorkerStatus(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) StopWorker(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) UpdateConfig(w http.ResponseWriter, r *http.Request)
- func (h *AdminHandler) WithRingBuffer(rb *logging.RingBuffer) *AdminHandler
- func (h *AdminHandler) WithScanQueue(q *scanning.ScanQueue) *AdminHandler
- type BaseHandler
- type BulkDeleteHostsRequest
- type BulkDeleteHostsResponse
- type CRUDMetrics
- type CRUDOperation
- type CertificateHandler
- type ConfigResponse
- type ConfigUpdateData
- type ConfigUpdateRequest
- type ContextKey
- type CreateExclusionRequest
- type CreateNetworkRequest
- type CustomNameRequest
- type DaemonConfigUpdate
- type DatabaseConfigUpdate
- type DatabaseInfo
- type DatabasePinger
- type DeviceHandler
- func (h *DeviceHandler) AcceptSuggestion(w http.ResponseWriter, r *http.Request)
- func (h *DeviceHandler) AttachHost(w http.ResponseWriter, r *http.Request)
- func (h *DeviceHandler) CreateDevice(w http.ResponseWriter, r *http.Request)
- func (h *DeviceHandler) DeleteDevice(w http.ResponseWriter, r *http.Request)
- func (h *DeviceHandler) DetachHost(w http.ResponseWriter, r *http.Request)
- func (h *DeviceHandler) DismissSuggestion(w http.ResponseWriter, r *http.Request)
- func (h *DeviceHandler) GetDevice(w http.ResponseWriter, r *http.Request)
- func (h *DeviceHandler) ListDevices(w http.ResponseWriter, r *http.Request)
- func (h *DeviceHandler) UpdateDevice(w http.ResponseWriter, r *http.Request)
- type DeviceServicer
- type DiscoveryHandler
- func (h *DiscoveryHandler) CreateDiscoveryJob(w http.ResponseWriter, r *http.Request)
- func (h *DiscoveryHandler) DeleteDiscoveryJob(w http.ResponseWriter, r *http.Request)
- func (h *DiscoveryHandler) GetDiscoveryCompare(w http.ResponseWriter, r *http.Request)
- func (h *DiscoveryHandler) GetDiscoveryDiff(w http.ResponseWriter, r *http.Request)
- func (h *DiscoveryHandler) GetDiscoveryJob(w http.ResponseWriter, r *http.Request)
- func (h *DiscoveryHandler) ListDiscoveryJobs(w http.ResponseWriter, r *http.Request)
- func (h *DiscoveryHandler) StartDiscovery(w http.ResponseWriter, r *http.Request)
- func (h *DiscoveryHandler) StopDiscovery(w http.ResponseWriter, r *http.Request)
- func (h *DiscoveryHandler) UpdateDiscoveryJob(w http.ResponseWriter, r *http.Request)
- func (h *DiscoveryHandler) WithEngine(e *discovery.Engine) *DiscoveryHandler
- func (h *DiscoveryHandler) WithScanQueue(q *scanning.ScanQueue) *DiscoveryHandler
- func (h *DiscoveryHandler) WithWebSocket(ws *WebSocketHandler) *DiscoveryHandler
- type DiscoveryRequest
- type DiscoveryResponse
- type DiscoveryResult
- type DiscoveryResultsResponse
- type DiscoveryStore
- type DiscoveryUpdateMessage
- type Duration
- type ErrorResponse
- type GroupHandler
- func (h *GroupHandler) AddGroupMembers(w http.ResponseWriter, r *http.Request)
- func (h *GroupHandler) CreateGroup(w http.ResponseWriter, r *http.Request)
- func (h *GroupHandler) DeleteGroup(w http.ResponseWriter, r *http.Request)
- func (h *GroupHandler) GetGroup(w http.ResponseWriter, r *http.Request)
- func (h *GroupHandler) ListGroupMembers(w http.ResponseWriter, r *http.Request)
- func (h *GroupHandler) ListGroups(w http.ResponseWriter, r *http.Request)
- func (h *GroupHandler) RemoveGroupMembers(w http.ResponseWriter, r *http.Request)
- func (h *GroupHandler) UpdateGroup(w http.ResponseWriter, r *http.Request)
- type GroupMembershipRequest
- type GroupRequest
- type GroupServicer
- type HandlerManager
- func (hm *HandlerManager) CloneProfile(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) CreateDiscoveryJob(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) CreateHost(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) CreateProfile(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) CreateScan(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) CreateSchedule(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) DeleteDiscoveryJob(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) DeleteHost(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) DeleteProfile(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) DeleteScan(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) DeleteSchedule(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) DisableSchedule(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) DiscoveryWebSocket(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) EnableSchedule(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GeneralWebSocket(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GetConfig(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GetDatabase() *db.DB
- func (hm *HandlerManager) GetDiscoveryJob(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GetHost(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GetHostScans(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GetLogger() *slog.Logger
- func (hm *HandlerManager) GetLogs(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GetMetrics() *metrics.Registry
- func (hm *HandlerManager) GetProfile(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GetScan(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GetScanResults(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GetSchedule(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GetScheduleNextRun(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) GetWorkerStatus(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) Health(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) ListDiscoveryJobs(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) ListHosts(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) ListProfiles(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) ListScans(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) ListSchedules(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) LogsWebSocket(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) Metrics(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) ScanWebSocket(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) SetScanQueue(q *scanning.ScanQueue)
- func (hm *HandlerManager) StartDiscovery(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) StartScan(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) Status(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) StopDiscovery(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) StopScan(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) StopWorker(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) UpdateConfig(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) UpdateDiscoveryJob(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) UpdateHost(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) UpdateProfile(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) UpdateScan(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) UpdateSchedule(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) Version(w http.ResponseWriter, r *http.Request)
- func (hm *HandlerManager) WithRingBuffer(rb *logging.RingBuffer) *HandlerManager
- type HealthHandler
- func (h *HealthHandler) Health(w http.ResponseWriter, r *http.Request)
- func (h *HealthHandler) Liveness(w http.ResponseWriter, r *http.Request)
- func (h *HealthHandler) Metrics(w http.ResponseWriter, r *http.Request)
- func (h *HealthHandler) SetScanQueue(q *scanning.ScanQueue)
- func (h *HealthHandler) Status(w http.ResponseWriter, r *http.Request)
- func (h *HealthHandler) Version(w http.ResponseWriter, r *http.Request)
- type HealthResponse
- type HostHandler
- func (h *HostHandler) AddHostTags(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) BulkDeleteHosts(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) BulkUpdateTags(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) CreateHost(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) DeleteHost(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) DeleteHostTags(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) GetHost(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) GetHostNetworks(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) GetHostScans(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) ListHosts(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) ListTags(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) ReplaceHostTags(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) UpdateCustomName(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) UpdateHost(w http.ResponseWriter, r *http.Request)
- func (h *HostHandler) WithBannerRepository(repo *db.BannerRepository) *HostHandler
- func (h *HostHandler) WithDNSRepository(repo *db.DNSRepository) *HostHandler
- func (h *HostHandler) WithSNMPRepository(repo *db.SNMPRepository) *HostHandler
- type HostRequest
- type HostResponse
- type HostScanResponse
- type HostServicer
- type JobControlOperation
- type JobInfo
- type KnowledgeScoreDistribution
- type ListOperation
- type LivenessResponse
- type LoggingConfigUpdate
- type LogsResponse
- type MemoryInfo
- type MetricsInfo
- type NameCandidateResponse
- type NetworkHandler
- func (h *NetworkHandler) CreateGlobalExclusion(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) CreateNetwork(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) CreateNetworkExclusion(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) DeleteExclusion(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) DeleteNetwork(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) DisableNetwork(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) EnableNetwork(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) GetNetwork(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) GetNetworkStats(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) ListGlobalExclusions(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) ListNetworkDiscoveryJobs(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) ListNetworkExclusions(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) ListNetworks(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) RenameNetwork(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) StartNetworkDiscovery(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) StartNetworkScan(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) UpdateNetwork(w http.ResponseWriter, r *http.Request)
- func (h *NetworkHandler) WithDiscovery(store DiscoveryStore, engine *discovery.Engine) *NetworkHandler
- func (h *NetworkHandler) WithHostService(svc HostServicer) *NetworkHandler
- func (h *NetworkHandler) WithScanQueue(q *scanning.ScanQueue) *NetworkHandler
- func (h *NetworkHandler) WithScanService(svc ScanServicer) *NetworkHandler
- type NetworkServicer
- type NetworkStatsResponse
- type OSFamilyCount
- type PaginatedResponse
- type PaginationMeta
- type PaginationParams
- type PortCount
- type PortHandler
- func (h *PortHandler) GetPort(w http.ResponseWriter, r *http.Request)
- func (h *PortHandler) ListPortCategories(w http.ResponseWriter, r *http.Request)
- func (h *PortHandler) ListPortHostCounts(w http.ResponseWriter, r *http.Request)
- func (h *PortHandler) ListPorts(w http.ResponseWriter, r *http.Request)
- type ProfileHandler
- func (h *ProfileHandler) CloneProfile(w http.ResponseWriter, r *http.Request)
- func (h *ProfileHandler) CreateProfile(w http.ResponseWriter, r *http.Request)
- func (h *ProfileHandler) DeleteProfile(w http.ResponseWriter, r *http.Request)
- func (h *ProfileHandler) GetProfile(w http.ResponseWriter, r *http.Request)
- func (h *ProfileHandler) GetProfileStats(w http.ResponseWriter, r *http.Request)
- func (h *ProfileHandler) ListProfiles(w http.ResponseWriter, r *http.Request)
- func (h *ProfileHandler) UpdateProfile(w http.ResponseWriter, r *http.Request)
- type ProfileRequest
- type ProfileResponse
- type ProfileServicer
- type ProfileStatsResponse
- type RenameNetworkRequest
- type SNMPCredentialsHandler
- type ScanHandler
- func (h *ScanHandler) CreateScan(w http.ResponseWriter, r *http.Request)
- func (h *ScanHandler) DeleteScan(w http.ResponseWriter, r *http.Request)
- func (h *ScanHandler) GetScan(w http.ResponseWriter, r *http.Request)
- func (h *ScanHandler) GetScanResults(w http.ResponseWriter, r *http.Request)
- func (h *ScanHandler) ListScans(w http.ResponseWriter, r *http.Request)
- func (h *ScanHandler) SetScanQueue(q *scanning.ScanQueue)
- func (h *ScanHandler) StartScan(w http.ResponseWriter, r *http.Request)
- func (h *ScanHandler) StopScan(w http.ResponseWriter, r *http.Request)
- func (h *ScanHandler) UpdateScan(w http.ResponseWriter, r *http.Request)
- func (h *ScanHandler) WithScanMode(mode string) *ScanHandler
- type ScanQueueInfo
- type ScanRequest
- type ScanResponse
- type ScanResult
- type ScanResultsResponse
- type ScanServicer
- type ScanUpdateMessage
- type ScanningConfigUpdate
- type ScheduleHandler
- func (h *ScheduleHandler) CreateSchedule(w http.ResponseWriter, r *http.Request)
- func (h *ScheduleHandler) CreateSmartScanSchedule(w http.ResponseWriter, r *http.Request)
- func (h *ScheduleHandler) DeleteSchedule(w http.ResponseWriter, r *http.Request)
- func (h *ScheduleHandler) DisableSchedule(w http.ResponseWriter, r *http.Request)
- func (h *ScheduleHandler) EnableSchedule(w http.ResponseWriter, r *http.Request)
- func (h *ScheduleHandler) GetSchedule(w http.ResponseWriter, r *http.Request)
- func (h *ScheduleHandler) GetScheduleNextRun(w http.ResponseWriter, r *http.Request)
- func (h *ScheduleHandler) ListSchedules(w http.ResponseWriter, r *http.Request)
- func (h *ScheduleHandler) UpdateSchedule(w http.ResponseWriter, r *http.Request)
- type ScheduleRequest
- type ScheduleResponse
- type ScheduleServicer
- type ServiceInfo
- type SettingsHandler
- type SmartScanHandler
- func (h *SmartScanHandler) EvaluateHost(w http.ResponseWriter, r *http.Request)
- func (h *SmartScanHandler) GetProfileRecommendations(w http.ResponseWriter, r *http.Request)
- func (h *SmartScanHandler) GetSuggestions(w http.ResponseWriter, r *http.Request)
- func (h *SmartScanHandler) RefreshIdentity(w http.ResponseWriter, r *http.Request)
- func (h *SmartScanHandler) TriggerBatch(w http.ResponseWriter, r *http.Request)
- func (h *SmartScanHandler) TriggerHost(w http.ResponseWriter, r *http.Request)
- type SmartScanScheduleRequest
- type StatsHandler
- type StatsSummaryResponse
- type StatusResponse
- type SystemInfo
- type TimingProfile
- type UpdateNetworkRequest
- type VersionResponse
- type WebSocketHandler
- func (h *WebSocketHandler) BroadcastDiscoveryUpdate(update *DiscoveryUpdateMessage) error
- func (h *WebSocketHandler) BroadcastScanUpdate(update *ScanUpdateMessage) error
- func (h *WebSocketHandler) BroadcastSystemMessage(messageType, content string) error
- func (h *WebSocketHandler) Close() error
- func (h *WebSocketHandler) DiscoveryWebSocket(w http.ResponseWriter, r *http.Request)
- func (h *WebSocketHandler) GeneralWebSocket(w http.ResponseWriter, r *http.Request)
- func (h *WebSocketHandler) GetConnectedClients() map[string]int
- func (h *WebSocketHandler) LogsWebSocket(w http.ResponseWriter, r *http.Request)
- func (h *WebSocketHandler) ScanWebSocket(w http.ResponseWriter, r *http.Request)
- func (h *WebSocketHandler) Shutdown()
- func (h *WebSocketHandler) WithRingBuffer(rb *logging.RingBuffer) *WebSocketHandler
- type WebSocketMessage
- type WorkerInfo
- type WorkerStatusResponse
Constants ¶
const ( StatusHealthy = "healthy" StatusUnhealthy = "unhealthy" StatusNotConfigured = "not configured" )
Status constants.
Variables ¶
This section is empty.
Functions ¶
func CreateEntity ¶
func CreateEntity[T any, I any]( w http.ResponseWriter, r *http.Request, entityType string, logger *slog.Logger, metricsRegistry metrics.MetricsRegistry, parseAndConvert func(*http.Request) (I, error), createInDB func(context.Context, I) (*T, error), toResponse func(*T) interface{}, metricName string, )
CreateEntity is a generic helper to eliminate duplication in create operations. The type parameter I is the typed input struct passed to createInDB (e.g. db.CreateScanInput).
func SetBuildInfo ¶
func SetBuildInfo(v, c, bt string)
SetBuildInfo sets build information (called by main package).
func UpdateEntity ¶
func UpdateEntity[T any, I any]( w http.ResponseWriter, r *http.Request, entityType string, logger *slog.Logger, metricsRegistry metrics.MetricsRegistry, parseAndConvert func(*http.Request) (I, error), updateInDB func(context.Context, uuid.UUID, I) (*T, error), toResponse func(*T) interface{}, metricName string, )
UpdateEntity is a generic helper to eliminate duplication in update operations. The type parameter I is the typed input struct passed to updateInDB (e.g. db.UpdateScanInput).
Types ¶
type APIConfigUpdate ¶
type APIConfigUpdate struct {
Enabled *bool `json:"enabled,omitempty"`
Host *string `json:"host,omitempty"`
Port *int `json:"port,omitempty" validate:"omitempty,min=1,max=65535"`
ReadTimeout *string `json:"read_timeout,omitempty"`
WriteTimeout *string `json:"write_timeout,omitempty"`
IdleTimeout *string `json:"idle_timeout,omitempty"`
MaxHeaderBytes *int `json:"max_header_bytes,omitempty" validate:"omitempty,min=1024,max=1048576"`
EnableCORS *bool `json:"enable_cors,omitempty"`
CORSOrigins []string `json:"cors_origins,omitempty"`
AuthEnabled *bool `json:"auth_enabled,omitempty"`
RateLimitEnabled *bool `json:"rate_limit_enabled,omitempty"`
RateLimitRequests *int `json:"rate_limit_requests,omitempty" validate:"omitempty,min=1,max=10000"`
RateLimitWindow *string `json:"rate_limit_window,omitempty"`
RequestTimeout *string `json:"request_timeout,omitempty"`
MaxRequestSize *int `json:"max_request_size,omitempty" validate:"omitempty,min=1,max=104857600"`
}
APIConfigUpdate represents updatable API configuration fields.
type AdminHandler ¶
type AdminHandler struct {
// contains filtered or unexported fields
}
AdminHandler handles administrative API endpoints.
func NewAdminHandler ¶
func NewAdminHandler(logger *slog.Logger, metricsManager *metrics.Registry) *AdminHandler
NewAdminHandler creates a new admin handler.
func (*AdminHandler) GetConfig ¶
func (h *AdminHandler) GetConfig(w http.ResponseWriter, r *http.Request)
GetConfig handles GET /api/v1/admin/config - get current configuration.
func (*AdminHandler) GetLogs ¶
func (h *AdminHandler) GetLogs(w http.ResponseWriter, r *http.Request)
GetLogs handles GET /api/v1/admin/logs – retrieve system logs.
Supported query parameters:
level – minimum log level: debug | info | warn | error component – exact component name filter search – case-insensitive substring match on the log message since – RFC 3339 timestamp; omit entries before this time until – RFC 3339 timestamp; omit entries after this time page – 1-based page number (default 1) page_size – entries per page (default 50, max 100)
func (*AdminHandler) GetWorkerStatus ¶
func (h *AdminHandler) GetWorkerStatus(w http.ResponseWriter, r *http.Request)
GetWorkerStatus handles GET /api/v1/admin/workers - get worker pool status.
func (*AdminHandler) StopWorker ¶
func (h *AdminHandler) StopWorker(w http.ResponseWriter, r *http.Request)
StopWorker handles POST /api/v1/admin/workers/{id}/stop - stop a specific worker.
func (*AdminHandler) UpdateConfig ¶
func (h *AdminHandler) UpdateConfig(w http.ResponseWriter, r *http.Request)
UpdateConfig handles PUT /api/v1/admin/config - update configuration.
func (*AdminHandler) WithRingBuffer ¶ added in v0.22.0
func (h *AdminHandler) WithRingBuffer(rb *logging.RingBuffer) *AdminHandler
WithRingBuffer sets the ring buffer used by log-related endpoints and returns the handler for method chaining.
func (*AdminHandler) WithScanQueue ¶ added in v0.22.0
func (h *AdminHandler) WithScanQueue(q *scanning.ScanQueue) *AdminHandler
WithScanQueue sets the scan queue used by worker-status endpoints and returns the handler for method chaining.
type BaseHandler ¶
type BaseHandler struct {
// contains filtered or unexported fields
}
BaseHandler provides common functionality for all handlers.
func NewBaseHandler ¶
func NewBaseHandler(logger *slog.Logger, metricsRegistry metrics.MetricsRegistry) *BaseHandler
NewBaseHandler creates a new base handler.
type BulkDeleteHostsRequest ¶ added in v0.23.0
type BulkDeleteHostsRequest struct {
IDs []string `json:"ids"`
}
BulkDeleteHostsRequest is the body for the bulk-delete endpoint.
type BulkDeleteHostsResponse ¶ added in v0.23.0
type BulkDeleteHostsResponse struct {
Deleted int64 `json:"deleted"`
}
BulkDeleteHostsResponse reports how many hosts were removed.
type CRUDMetrics ¶
type CRUDMetrics struct {
Listed string
Created string
Retrieved string
Updated string
Deleted string
Started string
Stopped string
}
CRUDMetrics holds metric names for CRUD operations.
type CRUDOperation ¶
type CRUDOperation[T any] struct { EntityType string Logger *slog.Logger Metrics metrics.MetricsRegistry }
CRUDOperation is a generic CRUD operation pattern.
func (*CRUDOperation[T]) ExecuteDelete ¶
func (op *CRUDOperation[T]) ExecuteDelete( w http.ResponseWriter, r *http.Request, id uuid.UUID, deleteFromDB func(context.Context, uuid.UUID) error, metricName string, )
ExecuteDelete performs a generic delete operation.
func (*CRUDOperation[T]) ExecuteGet ¶
func (op *CRUDOperation[T]) ExecuteGet( w http.ResponseWriter, r *http.Request, id uuid.UUID, getFromDB func(context.Context, uuid.UUID) (*T, error), toResponse func(*T) interface{}, metricName string, )
ExecuteGet performs a generic get operation.
func (*CRUDOperation[T]) ExecuteUpdate ¶
func (op *CRUDOperation[T]) ExecuteUpdate( w http.ResponseWriter, r *http.Request, id uuid.UUID, parseRequest func(*http.Request) (interface{}, error), validateRequest func(interface{}) error, updateInDB func(context.Context, uuid.UUID, interface{}) (*T, error), toResponse func(*T) interface{}, metricName string, )
ExecuteUpdate performs a generic update operation.
type CertificateHandler ¶ added in v0.25.0
type CertificateHandler struct {
// contains filtered or unexported fields
}
CertificateHandler handles TLS certificate endpoints.
func NewCertificateHandler ¶ added in v0.25.0
func NewCertificateHandler(repo *db.BannerRepository, logger *slog.Logger, m *metrics.Registry) *CertificateHandler
NewCertificateHandler creates a new CertificateHandler.
func (*CertificateHandler) GetExpiringCertificates ¶ added in v0.25.0
func (h *CertificateHandler) GetExpiringCertificates(w http.ResponseWriter, r *http.Request)
GetExpiringCertificates handles GET /api/v1/certificates/expiring
@Summary List expiring TLS certificates
@Description Returns TLS certificates expiring within the specified number of days (default 30, max 90).
@Description Certificates are joined with their host to include the host IP and hostname.
@Tags certificates
@Produce json
@Param days query int false "Lookahead window in days (1–90, default 30)"
@Success 200 {object} db.ExpiringCertificatesResponse
@Failure 400 {object} ErrorResponse
@Failure 500 {object} ErrorResponse
@Router /certificates/expiring [get]
type ConfigResponse ¶
type ConfigResponse struct {
API interface{} `json:"api"`
Database interface{} `json:"database"`
Scanning interface{} `json:"scanning"`
Logging interface{} `json:"logging"`
Daemon interface{} `json:"daemon"`
}
ConfigResponse represents configuration information.
type ConfigUpdateData ¶
type ConfigUpdateData struct {
API *APIConfigUpdate `json:"api,omitempty"`
Database *DatabaseConfigUpdate `json:"database,omitempty"`
Scanning *ScanningConfigUpdate `json:"scanning,omitempty"`
Logging *LoggingConfigUpdate `json:"logging,omitempty"`
Daemon *DaemonConfigUpdate `json:"daemon,omitempty"`
}
ConfigUpdateData represents the configuration data for updates.
type ConfigUpdateRequest ¶
type ConfigUpdateRequest struct {
Section string `json:"section" validate:"required,oneof=api database scanning logging daemon"`
Config ConfigUpdateData `json:"config" validate:"required"`
}
ConfigUpdateRequest represents a request to update configuration.
type CreateExclusionRequest ¶ added in v0.8.0
type CreateExclusionRequest struct {
ExcludedCIDR string `json:"excluded_cidr" validate:"required,cidr"`
Reason *string `json:"reason,omitempty"`
}
CreateExclusionRequest represents the request body for creating a network exclusion.
type CreateNetworkRequest ¶ added in v0.8.0
type CreateNetworkRequest struct {
Name string `json:"name" validate:"required,min=1,max=100"`
CIDR string `json:"cidr" validate:"required,cidr"`
Description *string `json:"description,omitempty"`
DiscoveryMethod string `json:"discovery_method" validate:"required,oneof=ping tcp arp"`
IsActive *bool `json:"is_active,omitempty"`
ScanEnabled *bool `json:"scan_enabled,omitempty"`
}
CreateNetworkRequest represents the request body for creating a network.
type CustomNameRequest ¶ added in v0.26.0
type CustomNameRequest struct {
CustomName *string `json:"custom_name"`
}
CustomNameRequest is the body of PATCH /hosts/{id}/custom-name. Nil CustomName clears the override; non-nil (after trim) sets it.
type DaemonConfigUpdate ¶
type DaemonConfigUpdate struct {
PIDFile *string `json:"pid_file,omitempty" validate:"omitempty,min=1,max=255"`
WorkDir *string `json:"work_dir,omitempty" validate:"omitempty,min=1,max=255"`
User *string `json:"user,omitempty" validate:"omitempty,min=1,max=32"`
Group *string `json:"group,omitempty" validate:"omitempty,min=1,max=32"`
Daemonize *bool `json:"daemonize,omitempty"`
ShutdownTimeout *string `json:"shutdown_timeout,omitempty"`
}
DaemonConfigUpdate represents updatable daemon configuration fields.
type DatabaseConfigUpdate ¶
type DatabaseConfigUpdate struct {
Host *string `json:"host,omitempty"`
Port *int `json:"port,omitempty" validate:"omitempty,min=1,max=65535"`
Database *string `json:"database,omitempty" validate:"omitempty,min=1,max=63"`
Username *string `json:"username,omitempty" validate:"omitempty,min=1,max=63"`
SSLMode *string `json:"ssl_mode,omitempty" validate:"omitempty,oneof=disable require verify-ca verify-full"`
MaxOpenConns *int `json:"max_open_conns,omitempty" validate:"omitempty,min=1,max=100"`
MaxIdleConns *int `json:"max_idle_conns,omitempty" validate:"omitempty,min=1,max=100"`
ConnMaxLifetime *string `json:"conn_max_lifetime,omitempty"`
ConnMaxIdleTime *string `json:"conn_max_idle_time,omitempty"`
}
DatabaseConfigUpdate represents updatable database configuration fields.
type DatabaseInfo ¶
type DatabaseInfo struct {
Connected bool `json:"connected"`
Driver string `json:"driver"`
Host string `json:"host"`
Database string `json:"database"`
LastPing time.Time `json:"last_ping"`
ResponseTime time.Duration `json:"response_time_ms"`
Error string `json:"error,omitempty"`
}
DatabaseInfo contains database connection information.
type DatabasePinger ¶
DatabasePinger defines the interface for database health checking.
type DeviceHandler ¶ added in v0.26.0
type DeviceHandler struct {
// contains filtered or unexported fields
}
DeviceHandler handles HTTP requests for device identity management.
func NewDeviceHandler ¶ added in v0.26.0
func NewDeviceHandler(svc DeviceServicer, logger *slog.Logger, m *metrics.Registry) *DeviceHandler
NewDeviceHandler creates a DeviceHandler.
func (*DeviceHandler) AcceptSuggestion ¶ added in v0.26.0
func (h *DeviceHandler) AcceptSuggestion(w http.ResponseWriter, r *http.Request)
AcceptSuggestion handles POST /api/v1/devices/suggestions/{id}/accept.
@Summary Accept a device suggestion (attaches the host)
@Tags devices
@Param id path string true "Suggestion UUID"
@Success 204
@Failure 404 {object} map[string]any
@Failure 500 {object} map[string]any
@Router /devices/suggestions/{id}/accept [post]
func (*DeviceHandler) AttachHost ¶ added in v0.26.0
func (h *DeviceHandler) AttachHost(w http.ResponseWriter, r *http.Request)
AttachHost handles POST /api/v1/devices/{id}/hosts/{host_id}.
@Summary Attach a host to a device
@Tags devices
@Param id path string true "Device UUID"
@Param host_id path string true "Host UUID"
@Success 204
@Failure 400 {object} map[string]any
@Failure 404 {object} map[string]any
@Failure 500 {object} map[string]any
@Router /devices/{id}/hosts/{host_id} [post]
func (*DeviceHandler) CreateDevice ¶ added in v0.26.0
func (h *DeviceHandler) CreateDevice(w http.ResponseWriter, r *http.Request)
CreateDevice handles POST /api/v1/devices.
@Summary Create a device
@Tags devices
@Accept json
@Produce json
@Param body body db.CreateDeviceInput true "Device input"
@Success 201 {object} db.Device
@Failure 400 {object} map[string]any
@Failure 500 {object} map[string]any
@Router /devices [post]
func (*DeviceHandler) DeleteDevice ¶ added in v0.26.0
func (h *DeviceHandler) DeleteDevice(w http.ResponseWriter, r *http.Request)
DeleteDevice handles DELETE /api/v1/devices/{id}.
@Summary Delete a device
@Tags devices
@Param id path string true "Device UUID"
@Success 204
@Failure 404 {object} map[string]any
@Failure 500 {object} map[string]any
@Router /devices/{id} [delete]
func (*DeviceHandler) DetachHost ¶ added in v0.26.0
func (h *DeviceHandler) DetachHost(w http.ResponseWriter, r *http.Request)
DetachHost handles DELETE /api/v1/devices/{id}/hosts/{host_id}.
@Summary Detach a host from a device
@Tags devices
@Param id path string true "Device UUID"
@Param host_id path string true "Host UUID"
@Success 204
@Failure 400 {object} map[string]any
@Failure 404 {object} map[string]any
@Failure 500 {object} map[string]any
@Router /devices/{id}/hosts/{host_id} [delete]
func (*DeviceHandler) DismissSuggestion ¶ added in v0.26.0
func (h *DeviceHandler) DismissSuggestion(w http.ResponseWriter, r *http.Request)
DismissSuggestion handles POST /api/v1/devices/suggestions/{id}/dismiss.
@Summary Dismiss a device suggestion
@Tags devices
@Param id path string true "Suggestion UUID"
@Success 204
@Failure 404 {object} map[string]any
@Failure 500 {object} map[string]any
@Router /devices/suggestions/{id}/dismiss [post]
func (*DeviceHandler) GetDevice ¶ added in v0.26.0
func (h *DeviceHandler) GetDevice(w http.ResponseWriter, r *http.Request)
GetDevice handles GET /api/v1/devices/{id}.
@Summary Get device detail
@Tags devices
@Produce json
@Param id path string true "Device UUID"
@Success 200 {object} db.DeviceDetail
@Failure 404 {object} map[string]any
@Failure 500 {object} map[string]any
@Router /devices/{id} [get]
func (*DeviceHandler) ListDevices ¶ added in v0.26.0
func (h *DeviceHandler) ListDevices(w http.ResponseWriter, r *http.Request)
ListDevices handles GET /api/v1/devices.
@Summary List devices
@Tags devices
@Produce json
@Success 200 {object} map[string]any
@Failure 500 {object} map[string]any
@Router /devices [get]
func (*DeviceHandler) UpdateDevice ¶ added in v0.26.0
func (h *DeviceHandler) UpdateDevice(w http.ResponseWriter, r *http.Request)
UpdateDevice handles PUT /api/v1/devices/{id}.
@Summary Update device name / notes
@Tags devices
@Accept json
@Produce json
@Param id path string true "Device UUID"
@Param body body db.UpdateDeviceInput true "Update fields"
@Success 200 {object} db.Device
@Failure 400 {object} map[string]any
@Failure 404 {object} map[string]any
@Failure 500 {object} map[string]any
@Router /devices/{id} [put]
type DeviceServicer ¶ added in v0.26.0
type DeviceServicer interface {
ListDevices(ctx context.Context) ([]db.DeviceSummary, error)
CreateDevice(ctx context.Context, input db.CreateDeviceInput) (*db.Device, error)
GetDeviceDetail(ctx context.Context, id uuid.UUID) (*db.DeviceDetail, error)
UpdateDevice(ctx context.Context, id uuid.UUID, input db.UpdateDeviceInput) (*db.Device, error)
DeleteDevice(ctx context.Context, id uuid.UUID) error
AttachHost(ctx context.Context, deviceID, hostID uuid.UUID) error
DetachHost(ctx context.Context, deviceID, hostID uuid.UUID) error
AcceptSuggestion(ctx context.Context, suggestionID uuid.UUID) error
DismissSuggestion(ctx context.Context, suggestionID uuid.UUID) error
}
DeviceServicer is the service-level interface consumed by DeviceHandler.
type DiscoveryHandler ¶
type DiscoveryHandler struct {
// contains filtered or unexported fields
}
DiscoveryHandler handles discovery-related API endpoints.
func NewDiscoveryHandler ¶
func NewDiscoveryHandler( database DiscoveryStore, logger *slog.Logger, metricsManager *metrics.Registry, ) *DiscoveryHandler
NewDiscoveryHandler creates a new discovery handler.
func (*DiscoveryHandler) CreateDiscoveryJob ¶
func (h *DiscoveryHandler) CreateDiscoveryJob(w http.ResponseWriter, r *http.Request)
CreateDiscoveryJob handles POST /api/v1/discovery - create a new discovery job.
func (*DiscoveryHandler) DeleteDiscoveryJob ¶
func (h *DiscoveryHandler) DeleteDiscoveryJob(w http.ResponseWriter, r *http.Request)
DeleteDiscoveryJob handles DELETE /api/v1/discovery/{id} - delete a discovery job.
func (*DiscoveryHandler) GetDiscoveryCompare ¶ added in v0.23.0
func (h *DiscoveryHandler) GetDiscoveryCompare(w http.ResponseWriter, r *http.Request)
GetDiscoveryCompare handles GET /api/v1/discovery/compare?run_a={id}&run_b={id} It compares two discovery runs and returns which hosts are new, gone, or changed.
func (*DiscoveryHandler) GetDiscoveryDiff ¶ added in v0.23.0
func (h *DiscoveryHandler) GetDiscoveryDiff(w http.ResponseWriter, r *http.Request)
GetDiscoveryDiff handles GET /api/v1/discovery/{id}/diff
func (*DiscoveryHandler) GetDiscoveryJob ¶
func (h *DiscoveryHandler) GetDiscoveryJob(w http.ResponseWriter, r *http.Request)
GetDiscoveryJob handles GET /api/v1/discovery/{id} - get a discovery job.
func (*DiscoveryHandler) ListDiscoveryJobs ¶
func (h *DiscoveryHandler) ListDiscoveryJobs(w http.ResponseWriter, r *http.Request)
ListDiscoveryJobs handles GET /api/v1/discovery - list discovery jobs with filtering and pagination.
func (*DiscoveryHandler) StartDiscovery ¶
func (h *DiscoveryHandler) StartDiscovery(w http.ResponseWriter, r *http.Request)
StartDiscovery handles POST /api/v1/discovery/{id}/start - start a discovery job.
func (*DiscoveryHandler) StopDiscovery ¶
func (h *DiscoveryHandler) StopDiscovery(w http.ResponseWriter, r *http.Request)
StopDiscovery handles POST /api/v1/discovery/{id}/stop - stop a running discovery job.
func (*DiscoveryHandler) UpdateDiscoveryJob ¶
func (h *DiscoveryHandler) UpdateDiscoveryJob(w http.ResponseWriter, r *http.Request)
UpdateDiscoveryJob handles PUT /api/v1/discovery/{id} - update an existing discovery job.
func (*DiscoveryHandler) WithEngine ¶ added in v0.14.0
func (h *DiscoveryHandler) WithEngine(e *discovery.Engine) *DiscoveryHandler
WithEngine sets the discovery engine used to actually execute nmap scans when a job is started via the API. Without an engine, StartDiscovery only flips the DB status row and no scan is performed.
func (*DiscoveryHandler) WithScanQueue ¶ added in v0.22.0
func (h *DiscoveryHandler) WithScanQueue(q *scanning.ScanQueue) *DiscoveryHandler
WithScanQueue sets the worker pool used to execute discovery jobs. When set, StartDiscovery submits a discoveryJob to the queue instead of spawning an unbounded goroutine.
func (*DiscoveryHandler) WithWebSocket ¶ added in v0.23.0
func (h *DiscoveryHandler) WithWebSocket(ws *WebSocketHandler) *DiscoveryHandler
WithWebSocket attaches a WebSocketHandler so that completed discovery jobs broadcast a diff summary to all connected discovery clients.
type DiscoveryRequest ¶
type DiscoveryRequest struct {
Name string `json:"name" validate:"required,min=1,max=255"`
Description string `json:"description,omitempty"`
Networks []string `json:"networks" validate:"required,min=1"`
Method string `json:"method" validate:"required,oneof=ping arp icmp tcp_connect dns"`
Ports string `json:"ports,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
Retries int `json:"retries,omitempty"`
Options map[string]string `json:"options,omitempty"`
ScheduleID *int64 `json:"schedule_id,omitempty"`
Tags []string `json:"tags,omitempty"`
Enabled bool `json:"enabled"`
NetworkID *uuid.UUID `json:"network_id,omitempty"`
}
DiscoveryRequest represents a discovery job creation/update request.
type DiscoveryResponse ¶
type DiscoveryResponse struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Networks []string `json:"networks"`
Method string `json:"method"`
Ports string `json:"ports,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
Retries int `json:"retries,omitempty"`
Options map[string]string `json:"options,omitempty"`
ScheduleID *int64 `json:"schedule_id,omitempty"`
Tags []string `json:"tags,omitempty"`
Enabled bool `json:"enabled"`
Status string `json:"status"`
Progress float64 `json:"progress"`
HostsFound int `json:"hosts_found"`
StartedAt *time.Time `json:"started_at,omitempty"`
NextRun *time.Time `json:"next_run,omitempty"`
RunCount int `json:"run_count"`
ErrorCount int `json:"error_count"`
LastError string `json:"last_error,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy string `json:"created_by,omitempty"`
}
DiscoveryResponse represents a discovery job response.
type DiscoveryResult ¶
type DiscoveryResult struct {
ID int64 `json:"id"`
HostIP string `json:"host_ip"`
Hostname string `json:"hostname,omitempty"`
MACAddress string `json:"mac_address,omitempty"`
ResponseTime float64 `json:"response_time_ms"`
Method string `json:"method"`
IsNew bool `json:"is_new"`
FirstSeen time.Time `json:"first_seen"`
LastSeen time.Time `json:"last_seen"`
}
DiscoveryResult represents an individual discovery result.
type DiscoveryResultsResponse ¶
type DiscoveryResultsResponse struct {
JobID int64 `json:"job_id"`
TotalHosts int `json:"total_hosts"`
NewHosts int `json:"new_hosts"`
UpdatedAt time.Time `json:"updated_at"`
Results []DiscoveryResult `json:"results"`
Summary map[string]interface{} `json:"summary"`
GeneratedAt time.Time `json:"generated_at"`
}
DiscoveryResultsResponse represents discovery results.
type DiscoveryStore ¶ added in v0.13.0
type DiscoveryStore interface {
ListDiscoveryJobs(ctx context.Context, filters db.DiscoveryFilters, offset, limit int) (
[]*db.DiscoveryJob, int64, error)
ListDiscoveryJobsByNetwork(ctx context.Context, networkID uuid.UUID, offset, limit int) (
[]*db.DiscoveryJob, int64, error)
CreateDiscoveryJob(ctx context.Context, input db.CreateDiscoveryJobInput) (*db.DiscoveryJob, error)
GetDiscoveryJob(ctx context.Context, id uuid.UUID) (*db.DiscoveryJob, error)
UpdateDiscoveryJob(ctx context.Context, id uuid.UUID, input db.UpdateDiscoveryJobInput) (*db.DiscoveryJob, error)
DeleteDiscoveryJob(ctx context.Context, id uuid.UUID) error
StartDiscoveryJob(ctx context.Context, id uuid.UUID) error
StopDiscoveryJob(ctx context.Context, id uuid.UUID) error
GetDiscoveryDiff(ctx context.Context, jobID uuid.UUID) (*db.DiscoveryDiff, error)
CompareDiscoveryRuns(ctx context.Context, jobA, jobB uuid.UUID) (*db.DiscoveryCompareDiff, error)
}
DiscoveryStore is the subset of *db.DB used by DiscoveryHandler.
type DiscoveryUpdateMessage ¶
type DiscoveryUpdateMessage struct {
JobID string `json:"job_id"`
Status string `json:"status"`
Progress float64 `json:"progress"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
HostsFound int `json:"hosts_found,omitempty"`
NewHosts int `json:"new_hosts,omitempty"`
GoneHosts int `json:"gone_hosts,omitempty"`
ChangedHosts int `json:"changed_hosts,omitempty"`
}
DiscoveryUpdateMessage represents a discovery job status update.
type Duration ¶
Duration is a custom type that can unmarshal duration strings from JSON
func NewDuration ¶
NewDuration creates a Duration from time.Duration
func (Duration) MarshalJSON ¶
MarshalJSON implements json.Marshaler for Duration
func (Duration) ToDuration ¶
ToDuration converts custom Duration to time.Duration
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for Duration
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
Message string `json:"message"`
Timestamp time.Time `json:"timestamp"`
RequestID string `json:"request_id,omitempty"`
}
ErrorResponse represents an API error response.
type GroupHandler ¶ added in v0.24.0
type GroupHandler struct {
// contains filtered or unexported fields
}
GroupHandler handles group-related API endpoints.
func NewGroupHandler ¶ added in v0.24.0
func NewGroupHandler(service GroupServicer, logger *slog.Logger, m *metrics.Registry) *GroupHandler
NewGroupHandler creates a new GroupHandler.
func (*GroupHandler) AddGroupMembers ¶ added in v0.24.0
func (h *GroupHandler) AddGroupMembers(w http.ResponseWriter, r *http.Request)
AddGroupMembers handles POST /api/v1/groups/{id}/hosts. Adds one or more hosts to the group.
func (*GroupHandler) CreateGroup ¶ added in v0.24.0
func (h *GroupHandler) CreateGroup(w http.ResponseWriter, r *http.Request)
CreateGroup handles POST /api/v1/groups. Creates a new host group and returns 201 with the created group.
func (*GroupHandler) DeleteGroup ¶ added in v0.24.0
func (h *GroupHandler) DeleteGroup(w http.ResponseWriter, r *http.Request)
DeleteGroup handles DELETE /api/v1/groups/{id}. Removes a host group and returns 204 No Content.
func (*GroupHandler) GetGroup ¶ added in v0.24.0
func (h *GroupHandler) GetGroup(w http.ResponseWriter, r *http.Request)
GetGroup handles GET /api/v1/groups/{id}. Returns a single group by its UUID.
func (*GroupHandler) ListGroupMembers ¶ added in v0.24.0
func (h *GroupHandler) ListGroupMembers(w http.ResponseWriter, r *http.Request)
ListGroupMembers handles GET /api/v1/groups/{id}/hosts. Returns a paginated list of hosts belonging to the group.
func (*GroupHandler) ListGroups ¶ added in v0.24.0
func (h *GroupHandler) ListGroups(w http.ResponseWriter, r *http.Request)
ListGroups handles GET /api/v1/groups. Returns all host groups with a total count.
func (*GroupHandler) RemoveGroupMembers ¶ added in v0.24.0
func (h *GroupHandler) RemoveGroupMembers(w http.ResponseWriter, r *http.Request)
RemoveGroupMembers handles DELETE /api/v1/groups/{id}/hosts. Removes one or more hosts from the group.
func (*GroupHandler) UpdateGroup ¶ added in v0.24.0
func (h *GroupHandler) UpdateGroup(w http.ResponseWriter, r *http.Request)
UpdateGroup handles PUT /api/v1/groups/{id}. Applies a partial update to an existing group.
type GroupMembershipRequest ¶ added in v0.24.0
type GroupMembershipRequest struct {
HostIDs []string `json:"host_ids"`
}
GroupMembershipRequest is the body for add/remove hosts from group endpoints.
type GroupRequest ¶ added in v0.24.0
type GroupRequest struct {
Name string `json:"name"`
Description string `json:"description"`
Color string `json:"color"`
}
GroupRequest is the body for create/update group endpoints.
type GroupServicer ¶ added in v0.24.0
type GroupServicer interface {
ListGroups(ctx context.Context) ([]*db.HostGroup, error)
CreateGroup(ctx context.Context, input db.CreateGroupInput) (*db.HostGroup, error)
GetGroup(ctx context.Context, id uuid.UUID) (*db.HostGroup, error)
UpdateGroup(ctx context.Context, id uuid.UUID, input db.UpdateGroupInput) (*db.HostGroup, error)
DeleteGroup(ctx context.Context, id uuid.UUID) error
AddHostsToGroup(ctx context.Context, groupID uuid.UUID, hostIDs []uuid.UUID) error
RemoveHostsFromGroup(ctx context.Context, groupID uuid.UUID, hostIDs []uuid.UUID) error
GetGroupMembers(ctx context.Context, groupID uuid.UUID, offset, limit int) ([]*db.Host, int64, error)
}
GroupServicer is the service-level interface consumed by GroupHandler.
type HandlerManager ¶
type HandlerManager struct {
// contains filtered or unexported fields
}
HandlerManager manages all API handlers and their dependencies.
func (*HandlerManager) CloneProfile ¶ added in v0.19.1
func (hm *HandlerManager) CloneProfile(w http.ResponseWriter, r *http.Request)
CloneProfile handles POST /api/v1/profiles/{id}/clone — clone a profile.
func (*HandlerManager) CreateDiscoveryJob ¶
func (hm *HandlerManager) CreateDiscoveryJob(w http.ResponseWriter, r *http.Request)
CreateDiscoveryJob handles POST /api/v1/discovery - create a new discovery job.
func (*HandlerManager) CreateHost ¶
func (hm *HandlerManager) CreateHost(w http.ResponseWriter, r *http.Request)
CreateHost handles POST /api/v1/hosts - create a new host.
func (*HandlerManager) CreateProfile ¶
func (hm *HandlerManager) CreateProfile(w http.ResponseWriter, r *http.Request)
CreateProfile handles POST /api/v1/profiles - create a new profile.
func (*HandlerManager) CreateScan ¶
func (hm *HandlerManager) CreateScan(w http.ResponseWriter, r *http.Request)
CreateScan handles POST /api/v1/scans - create a new scan.
func (*HandlerManager) CreateSchedule ¶
func (hm *HandlerManager) CreateSchedule(w http.ResponseWriter, r *http.Request)
CreateSchedule handles POST /api/v1/schedules - create a new schedule.
func (*HandlerManager) DeleteDiscoveryJob ¶
func (hm *HandlerManager) DeleteDiscoveryJob(w http.ResponseWriter, r *http.Request)
DeleteDiscoveryJob handles DELETE /api/v1/discovery/{id} - delete a discovery job.
func (*HandlerManager) DeleteHost ¶
func (hm *HandlerManager) DeleteHost(w http.ResponseWriter, r *http.Request)
DeleteHost handles DELETE /api/v1/hosts/{id} - delete a host.
func (*HandlerManager) DeleteProfile ¶
func (hm *HandlerManager) DeleteProfile(w http.ResponseWriter, r *http.Request)
DeleteProfile handles DELETE /api/v1/profiles/{id} - delete a profile.
func (*HandlerManager) DeleteScan ¶
func (hm *HandlerManager) DeleteScan(w http.ResponseWriter, r *http.Request)
DeleteScan handles DELETE /api/v1/scans/{id} - delete a scan.
func (*HandlerManager) DeleteSchedule ¶
func (hm *HandlerManager) DeleteSchedule(w http.ResponseWriter, r *http.Request)
DeleteSchedule handles DELETE /api/v1/schedules/{id} - delete a schedule.
func (*HandlerManager) DisableSchedule ¶
func (hm *HandlerManager) DisableSchedule(w http.ResponseWriter, r *http.Request)
DisableSchedule handles POST /api/v1/schedules/{id}/disable - disable a schedule.
func (*HandlerManager) DiscoveryWebSocket ¶
func (hm *HandlerManager) DiscoveryWebSocket(w http.ResponseWriter, r *http.Request)
DiscoveryWebSocket handles WebSocket connections for discovery updates.
func (*HandlerManager) EnableSchedule ¶
func (hm *HandlerManager) EnableSchedule(w http.ResponseWriter, r *http.Request)
EnableSchedule handles POST /api/v1/schedules/{id}/enable - enable a schedule.
func (*HandlerManager) GeneralWebSocket ¶ added in v0.12.0
func (hm *HandlerManager) GeneralWebSocket(w http.ResponseWriter, r *http.Request)
GeneralWebSocket handles general WebSocket connections for all updates.
func (*HandlerManager) GetConfig ¶
func (hm *HandlerManager) GetConfig(w http.ResponseWriter, r *http.Request)
GetConfig retrieves the current configuration.
func (*HandlerManager) GetDatabase ¶
func (hm *HandlerManager) GetDatabase() *db.DB
GetDatabase returns the database instance.
func (*HandlerManager) GetDiscoveryJob ¶
func (hm *HandlerManager) GetDiscoveryJob(w http.ResponseWriter, r *http.Request)
GetDiscoveryJob handles GET /api/v1/discovery/{id} - get a specific discovery job.
func (*HandlerManager) GetHost ¶
func (hm *HandlerManager) GetHost(w http.ResponseWriter, r *http.Request)
GetHost handles GET /api/v1/hosts/{id} - get a specific host.
func (*HandlerManager) GetHostScans ¶
func (hm *HandlerManager) GetHostScans(w http.ResponseWriter, r *http.Request)
GetHostScans handles GET /api/v1/hosts/{id}/scans - get scans for a host.
func (*HandlerManager) GetLogger ¶
func (hm *HandlerManager) GetLogger() *slog.Logger
GetLogger returns the logger instance.
func (*HandlerManager) GetLogs ¶
func (hm *HandlerManager) GetLogs(w http.ResponseWriter, r *http.Request)
GetLogs retrieves system logs.
func (*HandlerManager) GetMetrics ¶
func (hm *HandlerManager) GetMetrics() *metrics.Registry
GetMetrics returns the metrics manager.
func (*HandlerManager) GetProfile ¶
func (hm *HandlerManager) GetProfile(w http.ResponseWriter, r *http.Request)
GetProfile handles GET /api/v1/profiles/{id} - get a specific profile.
func (*HandlerManager) GetScan ¶
func (hm *HandlerManager) GetScan(w http.ResponseWriter, r *http.Request)
GetScan handles GET /api/v1/scans/{id} - get a specific scan.
func (*HandlerManager) GetScanResults ¶
func (hm *HandlerManager) GetScanResults(w http.ResponseWriter, r *http.Request)
GetScanResults handles GET /api/v1/scans/{id}/results - get scan results.
func (*HandlerManager) GetSchedule ¶
func (hm *HandlerManager) GetSchedule(w http.ResponseWriter, r *http.Request)
GetSchedule handles GET /api/v1/schedules/{id} - get a specific schedule.
func (*HandlerManager) GetScheduleNextRun ¶ added in v0.19.1
func (hm *HandlerManager) GetScheduleNextRun(w http.ResponseWriter, r *http.Request)
GetScheduleNextRun handles GET /api/v1/schedules/{id}/next-run — get next run time.
func (*HandlerManager) GetWorkerStatus ¶
func (hm *HandlerManager) GetWorkerStatus(w http.ResponseWriter, r *http.Request)
GetWorkerStatus retrieves the status of workers.
func (*HandlerManager) Health ¶
func (hm *HandlerManager) Health(w http.ResponseWriter, r *http.Request)
Health and status endpoints.
func (*HandlerManager) ListDiscoveryJobs ¶
func (hm *HandlerManager) ListDiscoveryJobs(w http.ResponseWriter, r *http.Request)
ListDiscoveryJobs handles GET /api/v1/discovery - list all discovery jobs.
func (*HandlerManager) ListHosts ¶
func (hm *HandlerManager) ListHosts(w http.ResponseWriter, r *http.Request)
ListHosts handles GET /api/v1/hosts - list all hosts.
func (*HandlerManager) ListProfiles ¶
func (hm *HandlerManager) ListProfiles(w http.ResponseWriter, r *http.Request)
ListProfiles handles GET /api/v1/profiles - list all profiles.
func (*HandlerManager) ListScans ¶
func (hm *HandlerManager) ListScans(w http.ResponseWriter, r *http.Request)
ListScans handles GET /api/v1/scans - list all scans.
func (*HandlerManager) ListSchedules ¶
func (hm *HandlerManager) ListSchedules(w http.ResponseWriter, r *http.Request)
ListSchedules handles GET /api/v1/schedules - list all schedules.
func (*HandlerManager) LogsWebSocket ¶ added in v0.22.0
func (hm *HandlerManager) LogsWebSocket(w http.ResponseWriter, r *http.Request)
LogsWebSocket handles WebSocket connections for real-time log streaming.
func (*HandlerManager) Metrics ¶
func (hm *HandlerManager) Metrics(w http.ResponseWriter, r *http.Request)
Metrics handles GET /metrics - get application metrics.
func (*HandlerManager) ScanWebSocket ¶
func (hm *HandlerManager) ScanWebSocket(w http.ResponseWriter, r *http.Request)
ScanWebSocket handles WebSocket connections for scan updates.
func (*HandlerManager) SetScanQueue ¶ added in v0.13.0
func (hm *HandlerManager) SetScanQueue(q *scanning.ScanQueue)
SetScanQueue configures the scan execution queue and propagates it to the scan handler (for API-triggered scans) and the health handler (for status reporting). Pass nil to revert to the default fire-and-forget behavior.
func (*HandlerManager) StartDiscovery ¶
func (hm *HandlerManager) StartDiscovery(w http.ResponseWriter, r *http.Request)
StartDiscovery handles POST /api/v1/discovery/{id}/start - start discovery.
func (*HandlerManager) StartScan ¶
func (hm *HandlerManager) StartScan(w http.ResponseWriter, r *http.Request)
StartScan handles POST /api/v1/scans/{id}/start - start a scan.
func (*HandlerManager) Status ¶
func (hm *HandlerManager) Status(w http.ResponseWriter, r *http.Request)
Status handles GET /status - get system status.
func (*HandlerManager) StopDiscovery ¶
func (hm *HandlerManager) StopDiscovery(w http.ResponseWriter, r *http.Request)
StopDiscovery handles POST /api/v1/discovery/{id}/stop - stop discovery.
func (*HandlerManager) StopScan ¶
func (hm *HandlerManager) StopScan(w http.ResponseWriter, r *http.Request)
StopScan handles POST /api/v1/scans/{id}/stop - stop a scan.
func (*HandlerManager) StopWorker ¶
func (hm *HandlerManager) StopWorker(w http.ResponseWriter, r *http.Request)
StopWorker stops a specific worker.
func (*HandlerManager) UpdateConfig ¶
func (hm *HandlerManager) UpdateConfig(w http.ResponseWriter, r *http.Request)
UpdateConfig updates the configuration.
func (*HandlerManager) UpdateDiscoveryJob ¶
func (hm *HandlerManager) UpdateDiscoveryJob(w http.ResponseWriter, r *http.Request)
UpdateDiscoveryJob handles PUT /api/v1/discovery/{id} - update an existing discovery job.
func (*HandlerManager) UpdateHost ¶
func (hm *HandlerManager) UpdateHost(w http.ResponseWriter, r *http.Request)
UpdateHost handles PUT /api/v1/hosts/{id} - update an existing host.
func (*HandlerManager) UpdateProfile ¶
func (hm *HandlerManager) UpdateProfile(w http.ResponseWriter, r *http.Request)
UpdateProfile handles PUT /api/v1/profiles/{id} - update an existing profile.
func (*HandlerManager) UpdateScan ¶
func (hm *HandlerManager) UpdateScan(w http.ResponseWriter, r *http.Request)
UpdateScan handles PUT /api/v1/scans/{id} - update an existing scan.
func (*HandlerManager) UpdateSchedule ¶
func (hm *HandlerManager) UpdateSchedule(w http.ResponseWriter, r *http.Request)
UpdateSchedule handles PUT /api/v1/schedules/{id} - update an existing schedule.
func (*HandlerManager) Version ¶
func (hm *HandlerManager) Version(w http.ResponseWriter, r *http.Request)
Version handles GET /version - get version information.
func (*HandlerManager) WithRingBuffer ¶ added in v0.22.0
func (hm *HandlerManager) WithRingBuffer(rb *logging.RingBuffer) *HandlerManager
WithRingBuffer sets the ring buffer for log access on both the admin and websocket handlers and returns the HandlerManager for method chaining.
type HealthHandler ¶
type HealthHandler struct {
// contains filtered or unexported fields
}
HealthHandler handles health check and status endpoints.
func NewHealthHandler ¶
func NewHealthHandler( database DatabasePinger, logger *slog.Logger, metricsManager metrics.MetricsRegistry, ) *HealthHandler
NewHealthHandler creates a new health handler.
func (*HealthHandler) Health ¶
func (h *HealthHandler) Health(w http.ResponseWriter, r *http.Request)
Health performs a basic health check.
func (*HealthHandler) Liveness ¶
func (h *HealthHandler) Liveness(w http.ResponseWriter, r *http.Request)
Liveness performs a simple liveness check without dependencies.
func (*HealthHandler) Metrics ¶
func (h *HealthHandler) Metrics(w http.ResponseWriter, r *http.Request)
Metrics provides metrics endpoint (Prometheus format).
func (*HealthHandler) SetScanQueue ¶ added in v0.13.0
func (h *HealthHandler) SetScanQueue(q *scanning.ScanQueue)
SetScanQueue sets the scan queue for health monitoring.
func (*HealthHandler) Status ¶
func (h *HealthHandler) Status(w http.ResponseWriter, r *http.Request)
Status provides detailed system status information.
func (*HealthHandler) Version ¶
func (h *HealthHandler) Version(w http.ResponseWriter, r *http.Request)
Version provides version information.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
Timestamp time.Time `json:"timestamp"`
Uptime string `json:"uptime"`
Checks map[string]string `json:"checks"`
}
HealthResponse represents a health check response.
type HostHandler ¶
type HostHandler struct {
// contains filtered or unexported fields
}
HostHandler handles host-related API endpoints.
func NewHostHandler ¶
func NewHostHandler(service HostServicer, logger *slog.Logger, metricsManager *metrics.Registry) *HostHandler
NewHostHandler creates a new host handler.
func (*HostHandler) AddHostTags ¶ added in v0.24.0
func (h *HostHandler) AddHostTags(w http.ResponseWriter, r *http.Request)
AddHostTags handles POST /api/v1/hosts/{id}/tags. Appends tags to the host's tag list (deduplicating the result).
func (*HostHandler) BulkDeleteHosts ¶ added in v0.23.0
func (h *HostHandler) BulkDeleteHosts(w http.ResponseWriter, r *http.Request)
BulkDeleteHosts handles DELETE /api/v1/hosts - delete multiple hosts in one call. The request body must contain a JSON object with an "ids" array of UUID strings. IDs that do not exist are silently skipped; only genuine DB errors are returned.
func (*HostHandler) BulkUpdateTags ¶ added in v0.24.0
func (h *HostHandler) BulkUpdateTags(w http.ResponseWriter, r *http.Request)
BulkUpdateTags handles POST /api/v1/hosts/bulk/tags. Applies an add/remove/set tag operation to multiple hosts at once.
func (*HostHandler) CreateHost ¶
func (h *HostHandler) CreateHost(w http.ResponseWriter, r *http.Request)
CreateHost handles POST /api/v1/hosts - create a new host.
func (*HostHandler) DeleteHost ¶
func (h *HostHandler) DeleteHost(w http.ResponseWriter, r *http.Request)
DeleteHost handles DELETE /api/v1/hosts/{id} - delete a host.
func (*HostHandler) DeleteHostTags ¶ added in v0.24.0
func (h *HostHandler) DeleteHostTags(w http.ResponseWriter, r *http.Request)
DeleteHostTags handles DELETE /api/v1/hosts/{id}/tags. Removes the specified tags from the host's tag list.
func (*HostHandler) GetHost ¶
func (h *HostHandler) GetHost(w http.ResponseWriter, r *http.Request)
GetHost handles GET /api/v1/hosts/{id} - get a specific host.
func (*HostHandler) GetHostNetworks ¶ added in v0.26.0
func (h *HostHandler) GetHostNetworks(w http.ResponseWriter, r *http.Request)
GetHostNetworks handles GET /api/v1/hosts/{id}/networks - list the registered networks containing this host, ordered by longest prefix first. Membership is derived from the host_network_memberships view via CIDR containment; no row is persisted. Empty results encode as "[]" (never "null") for wire stability.
func (*HostHandler) GetHostScans ¶
func (h *HostHandler) GetHostScans(w http.ResponseWriter, r *http.Request)
GetHostScans handles GET /api/v1/hosts/{id}/scans - get scans for a specific host.
func (*HostHandler) ListHosts ¶
func (h *HostHandler) ListHosts(w http.ResponseWriter, r *http.Request)
ListHosts handles GET /api/v1/hosts - list all hosts with pagination.
func (*HostHandler) ListTags ¶ added in v0.24.0
func (h *HostHandler) ListTags(w http.ResponseWriter, r *http.Request)
ListTags handles GET /api/v1/tags. Returns a deduplicated, sorted list of all tags in use across all hosts.
func (*HostHandler) ReplaceHostTags ¶ added in v0.24.0
func (h *HostHandler) ReplaceHostTags(w http.ResponseWriter, r *http.Request)
ReplaceHostTags handles PUT /api/v1/hosts/{id}/tags. Replaces the host's entire tag list.
func (*HostHandler) UpdateCustomName ¶ added in v0.26.0
func (h *HostHandler) UpdateCustomName(w http.ResponseWriter, r *http.Request)
UpdateCustomName handles PATCH /api/v1/hosts/{id}/custom-name. Sets or clears the user-defined display-name override for a host. Pass null or an empty/whitespace-only string to clear.
@Summary Set or clear a host's custom display name
@Description PATCH the user-defined display-name override. Pass {"custom_name": null} or empty string to clear.
@Tags hosts
@Accept json
@Produce json
@Param id path string true "Host UUID"
@Param body body CustomNameRequest true "Custom name payload"
@Success 200 {object} HostResponse
@Failure 400 {object} ErrorResponse
@Failure 404 {object} ErrorResponse
@Failure 500 {object} ErrorResponse
@Router /hosts/{id}/custom-name [patch]
func (*HostHandler) UpdateHost ¶
func (h *HostHandler) UpdateHost(w http.ResponseWriter, r *http.Request)
UpdateHost handles PUT /api/v1/hosts/{id} - update a host.
func (*HostHandler) WithBannerRepository ¶ added in v0.25.0
func (h *HostHandler) WithBannerRepository(repo *db.BannerRepository) *HostHandler
WithBannerRepository sets an optional banner/certificate repository for enriched host detail responses. Safe to call with nil.
func (*HostHandler) WithDNSRepository ¶ added in v0.25.0
func (h *HostHandler) WithDNSRepository(repo *db.DNSRepository) *HostHandler
WithDNSRepository attaches a DNS repository so that GetHost includes the host's DNS records in its response. Returns the handler for chaining.
func (*HostHandler) WithSNMPRepository ¶ added in v0.25.0
func (h *HostHandler) WithSNMPRepository(repo *db.SNMPRepository) *HostHandler
WithSNMPRepository attaches a SNMPRepository for enriching host detail responses.
type HostRequest ¶
type HostRequest struct {
IP string `json:"ip_address" validate:"required,ip"`
Hostname string `json:"hostname,omitempty"`
Description string `json:"description,omitempty"`
OS string `json:"os,omitempty"`
OSVersion string `json:"os_version,omitempty"`
Tags []string `json:"tags,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Active bool `json:"active"`
}
HostRequest represents a host creation/update request.
type HostResponse ¶
type HostResponse struct {
ID string `json:"id"`
IPAddress string `json:"ip_address"`
Hostname string `json:"hostname,omitempty"`
Description string `json:"description,omitempty"`
// Deprecated: use OSFamily instead.
OS string `json:"os,omitempty"`
// Deprecated: use OSName / OSVersion instead.
OSVersionLegacy string `json:"os_version,omitempty"`
// OSFamily is the broad OS family detected by nmap (e.g. "Linux", "Windows").
OSFamily string `json:"os_family,omitempty"`
// OSName is the full OS name returned by nmap (e.g. "Linux 5.15").
OSName string `json:"os_name,omitempty"`
// OSVersion is the OS generation / version string returned by nmap.
OSVersion string `json:"os_version_detail,omitempty"`
// OSConfidence is the nmap detection confidence percentage (0–100).
OSConfidence *int `json:"os_confidence,omitempty"`
Tags []string `json:"tags,omitempty"`
Groups []db.HostGroupSummary `json:"groups,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Status string `json:"status"`
MACAddress string `json:"mac_address,omitempty"`
Ports []db.PortInfo `json:"ports,omitempty"`
FirstSeen time.Time `json:"first_seen"`
LastSeen *time.Time `json:"last_seen,omitempty"`
LastScanID *int64 `json:"last_scan_id,omitempty"`
ScanCount int `json:"scan_count"`
TotalPorts int `json:"total_ports"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DiscoveredBy string `json:"discovered_by,omitempty"`
StatusChangedAt *time.Time `json:"status_changed_at,omitempty"`
PreviousStatus string `json:"previous_status,omitempty"`
Vendor string `json:"vendor,omitempty"`
ResponseTimeMS *int `json:"response_time_ms,omitempty"`
ResponseTimeMinMS *int `json:"response_time_min_ms,omitempty"`
ResponseTimeMaxMS *int `json:"response_time_max_ms,omitempty"`
ResponseTimeAvgMS *int `json:"response_time_avg_ms,omitempty"`
TimeoutCount int `json:"timeout_count"`
DNSRecords []db.DNSRecord `json:"dns_records,omitempty"`
Banners []*db.PortBanner `json:"banners"`
Certificates []*db.Certificate `json:"certificates"`
SNMPData *db.HostSNMPData `json:"snmp_data"`
KnowledgeScore int `json:"knowledge_score"`
// DisplayName is the winning name chosen by the identity resolver.
// Always set — falls back to IPAddress when no source produced a usable name.
DisplayName string `json:"display_name"`
// DisplayNameSource tags where DisplayName came from:
// custom|mdns|snmp|ptr|cert|ip.
DisplayNameSource string `json:"display_name_source"`
// CustomName is the user-defined override (nil when unset).
CustomName *string `json:"custom_name,omitempty"`
// HostnameSource is the provenance tag for Hostname: manual|ptr|mdns|snmp|cert.
HostnameSource *string `json:"hostname_source,omitempty"`
// NameCandidates is every automatic name candidate (usable or not) observed
// for this host. Always present — make([]..., 0) rather than nil so it
// serializes as [] not null. Empty on list responses (computed only on
// GET /hosts/{id} where the related tables are joined).
NameCandidates []NameCandidateResponse `json:"name_candidates"`
}
HostResponse represents a host response.
type HostScanResponse ¶
type HostScanResponse struct {
ID string `json:"id"`
Name string `json:"name"`
ScanType string `json:"scan_type"`
Ports string `json:"ports,omitempty"`
Targets []string `json:"targets,omitempty"`
Status string `json:"status"`
Progress float64 `json:"progress"`
StartTime *time.Time `json:"start_time,omitempty"`
EndTime *time.Time `json:"end_time,omitempty"`
Duration *string `json:"duration,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
HostScanResponse represents a scan associated with a host.
type HostServicer ¶ added in v0.19.1
type HostServicer interface {
ListHosts(ctx context.Context, filters *db.HostFilters, offset, limit int) ([]*db.Host, int64, error)
CreateHost(ctx context.Context, input db.CreateHostInput) (*db.Host, error)
GetHost(ctx context.Context, id uuid.UUID) (*db.Host, error)
UpdateHost(ctx context.Context, id uuid.UUID, input db.UpdateHostInput) (*db.Host, error)
UpdateCustomName(ctx context.Context, id uuid.UUID, name *string) (*db.Host, error)
DeleteHost(ctx context.Context, id uuid.UUID) error
BulkDeleteHosts(ctx context.Context, ids []uuid.UUID) (int64, error)
GetHostScans(ctx context.Context, hostID uuid.UUID, offset, limit int) ([]*db.Scan, int64, error)
ListTags(ctx context.Context) ([]string, error)
UpdateHostTags(ctx context.Context, id uuid.UUID, tags []string) error
AddHostTags(ctx context.Context, id uuid.UUID, tags []string) error
RemoveHostTags(ctx context.Context, id uuid.UUID, tags []string) error
BulkUpdateTags(ctx context.Context, ids []uuid.UUID, tags []string, action string) error
GetHostGroups(ctx context.Context, hostID uuid.UUID) ([]db.HostGroupSummary, error)
GetHostNetworks(ctx context.Context, hostID uuid.UUID) ([]*db.Network, error)
}
HostServicer is the service-level interface consumed by HostHandler.
type JobControlOperation ¶
type JobControlOperation struct {
EntityType string
Logger *slog.Logger
Metrics metrics.MetricsRegistry
}
JobControlOperation is a job control operation pattern for start/stop operations.
func (*JobControlOperation) ExecuteStart ¶
func (op *JobControlOperation) ExecuteStart( w http.ResponseWriter, r *http.Request, id uuid.UUID, startInDB func(context.Context, uuid.UUID) error, getFromDB func(context.Context, uuid.UUID) (interface{}, error), toResponse func(interface{}) interface{}, metricName string, )
ExecuteStart performs a generic start operation.
func (*JobControlOperation) ExecuteStop ¶
func (op *JobControlOperation) ExecuteStop( w http.ResponseWriter, r *http.Request, id uuid.UUID, stopInDB func(context.Context, uuid.UUID) error, metricName string, )
ExecuteStop performs a generic stop operation.
type JobInfo ¶
type JobInfo struct {
ID string `json:"id"`
Type string `json:"type"`
Target string `json:"target,omitempty"`
StartTime time.Time `json:"start_time"`
Duration time.Duration `json:"duration"`
Progress float64 `json:"progress"`
}
JobInfo represents current job information.
type KnowledgeScoreDistribution ¶ added in v0.25.0
type KnowledgeScoreDistribution struct {
Band0to25 int `json:"0_25"`
Band25to50 int `json:"25_50"`
Band50to75 int `json:"50_75"`
Band75to100 int `json:"75_100"`
}
KnowledgeScoreDistribution holds host counts across four score bands.
type ListOperation ¶
type ListOperation[T any, F any] struct { EntityType string MetricName string Logger *slog.Logger Metrics metrics.MetricsRegistry GetFilters func(*http.Request) F ListFromDB func(context.Context, F, int, int) ([]T, int64, error) ToResponse func(T) interface{} }
ListOperation is a generic list operation pattern.
func (*ListOperation[T, F]) Execute ¶
func (op *ListOperation[T, F]) Execute(w http.ResponseWriter, r *http.Request)
Execute performs a generic list operation.
type LivenessResponse ¶
type LivenessResponse struct {
Status string `json:"status"`
Timestamp time.Time `json:"timestamp"`
Uptime string `json:"uptime"`
}
LivenessResponse represents a simple liveness check response.
type LoggingConfigUpdate ¶
type LoggingConfigUpdate struct {
Level *string `json:"level,omitempty" validate:"omitempty,oneof=debug info warn error"`
Format *string `json:"format,omitempty" validate:"omitempty,oneof=text json"`
Output *string `json:"output,omitempty" validate:"omitempty,min=1,max=255"`
Structured *bool `json:"structured,omitempty"`
RequestLogging *bool `json:"request_logging,omitempty"`
}
LoggingConfigUpdate represents updatable logging configuration fields.
type LogsResponse ¶
type LogsResponse struct {
Data []logging.LogEntry `json:"data"`
Pagination PaginationMeta `json:"pagination"`
}
LogsResponse is the JSON envelope returned by GET /api/v1/admin/logs.
type MemoryInfo ¶
type MemoryInfo struct {
Allocated uint64 `json:"allocated_bytes"`
TotalAlloc uint64 `json:"total_alloc_bytes"`
System uint64 `json:"system_bytes"`
GCCycles uint32 `json:"gc_cycles"`
LastGC string `json:"last_gc"`
HeapObjects uint64 `json:"heap_objects"`
}
MemoryInfo contains memory usage information.
type MetricsInfo ¶
type MetricsInfo struct {
Enabled bool `json:"enabled"`
TotalCounters int `json:"total_counters"`
TotalGauges int `json:"total_gauges"`
TotalHistos int `json:"total_histograms"`
LastUpdated time.Time `json:"last_updated"`
Summary map[string]interface{} `json:"summary,omitempty"`
}
MetricsInfo contains metrics system information.
type NameCandidateResponse ¶ added in v0.26.0
type NameCandidateResponse struct {
Name string `json:"name"`
Source string `json:"source"`
Usable bool `json:"usable"`
NotUsableReason string `json:"not_usable_reason,omitempty"`
ObservedAt *time.Time `json:"observed_at,omitempty"`
}
NameCandidateResponse is one entry in HostResponse.NameCandidates — a single name value from an auto-discovery source, tagged with whether it was deemed usable and why not (when applicable).
type NetworkHandler ¶ added in v0.8.0
type NetworkHandler struct {
*BaseHandler
// contains filtered or unexported fields
}
NetworkHandler handles network-related API requests.
func NewNetworkHandler ¶ added in v0.8.0
func NewNetworkHandler( service NetworkServicer, logger *slog.Logger, metricsRegistry metrics.MetricsRegistry, ) *NetworkHandler
NewNetworkHandler creates a new network handler.
func (*NetworkHandler) CreateGlobalExclusion ¶ added in v0.8.0
func (h *NetworkHandler) CreateGlobalExclusion(w http.ResponseWriter, r *http.Request)
CreateGlobalExclusion handles POST /api/v1/exclusions.
func (*NetworkHandler) CreateNetwork ¶ added in v0.8.0
func (h *NetworkHandler) CreateNetwork(w http.ResponseWriter, r *http.Request)
CreateNetwork handles POST /api/v1/networks.
func (*NetworkHandler) CreateNetworkExclusion ¶ added in v0.8.0
func (h *NetworkHandler) CreateNetworkExclusion(w http.ResponseWriter, r *http.Request)
CreateNetworkExclusion handles POST /api/v1/networks/{id}/exclusions.
func (*NetworkHandler) DeleteExclusion ¶ added in v0.8.0
func (h *NetworkHandler) DeleteExclusion(w http.ResponseWriter, r *http.Request)
func (*NetworkHandler) DeleteNetwork ¶ added in v0.8.0
func (h *NetworkHandler) DeleteNetwork(w http.ResponseWriter, r *http.Request)
DeleteNetwork handles DELETE /api/v1/networks/{id}.
func (*NetworkHandler) DisableNetwork ¶ added in v0.8.0
func (h *NetworkHandler) DisableNetwork(w http.ResponseWriter, r *http.Request)
DisableNetwork handles POST /api/v1/networks/{id}/disable.
func (*NetworkHandler) EnableNetwork ¶ added in v0.8.0
func (h *NetworkHandler) EnableNetwork(w http.ResponseWriter, r *http.Request)
EnableNetwork handles POST /api/v1/networks/{id}/enable.
func (*NetworkHandler) GetNetwork ¶ added in v0.8.0
func (h *NetworkHandler) GetNetwork(w http.ResponseWriter, r *http.Request)
GetNetwork handles GET /api/v1/networks/{id}.
func (*NetworkHandler) GetNetworkStats ¶ added in v0.8.0
func (h *NetworkHandler) GetNetworkStats(w http.ResponseWriter, r *http.Request)
GetNetworkStats handles GET /api/v1/networks/stats.
func (*NetworkHandler) ListGlobalExclusions ¶ added in v0.8.0
func (h *NetworkHandler) ListGlobalExclusions(w http.ResponseWriter, r *http.Request)
ListGlobalExclusions handles GET /api/v1/exclusions.
func (*NetworkHandler) ListNetworkDiscoveryJobs ¶ added in v0.20.0
func (h *NetworkHandler) ListNetworkDiscoveryJobs(w http.ResponseWriter, r *http.Request)
ListNetworkDiscoveryJobs handles GET /api/v1/networks/{id}/discovery. Returns a paginated list of discovery jobs linked to the specified network, ordered most-recent first.
@Summary List discovery jobs for a network
@Description Returns paginated history of discovery runs linked to the network.
@Tags networks
@Produce json
@Param id path string true "Network UUID"
@Param page query int false "Page number (default 1)"
@Param page_size query int false "Page size (default 50, max 100)"
@Success 200 {object} PaginatedResponse
@Failure 400 {object} ErrorResponse
@Failure 503 {object} ErrorResponse
@Router /networks/{id}/discovery [get]
func (*NetworkHandler) ListNetworkExclusions ¶ added in v0.8.0
func (h *NetworkHandler) ListNetworkExclusions(w http.ResponseWriter, r *http.Request)
ListNetworkExclusions handles GET /api/v1/networks/{id}/exclusions.
func (*NetworkHandler) ListNetworks ¶ added in v0.8.0
func (h *NetworkHandler) ListNetworks(w http.ResponseWriter, r *http.Request)
ListNetworks handles GET /api/v1/networks.
func (*NetworkHandler) RenameNetwork ¶ added in v0.8.0
func (h *NetworkHandler) RenameNetwork(w http.ResponseWriter, r *http.Request)
RenameNetwork handles PUT /api/v1/networks/{id}/rename.
func (*NetworkHandler) StartNetworkDiscovery ¶ added in v0.20.0
func (h *NetworkHandler) StartNetworkDiscovery(w http.ResponseWriter, r *http.Request)
StartNetworkDiscovery handles POST /api/v1/networks/{id}/discover. It creates a discovery job from the network's own CIDR and discovery_method, immediately starts it, and returns the running job.
@Summary Start a discovery run for a network
@Description Creates a discovery job linked to the network, immediately transitions it to running,
@Description and returns the job. If a discovery engine is configured the scan executes asynchronously.
@Tags networks
@Produce json
@Param id path string true "Network UUID"
@Success 202 {object} DiscoveryResponse
@Failure 400 {object} ErrorResponse
@Failure 404 {object} ErrorResponse
@Failure 500 {object} ErrorResponse
@Failure 503 {object} ErrorResponse
@Router /networks/{id}/discover [post]
func (*NetworkHandler) StartNetworkScan ¶ added in v0.23.0
func (h *NetworkHandler) StartNetworkScan(w http.ResponseWriter, r *http.Request)
StartNetworkScan handles POST /api/v1/networks/{id}/scan. Lists all active (status=up) hosts in the network's CIDR, creates a pending scan job targeting those hosts, and returns it ready to be started.
@Summary Scan all active hosts in a network
@Description Creates a pending scan targeting every active host discovered in the network's CIDR.
@Tags networks
@Accept json
@Produce json
@Param id path string true "Network UUID"
@Param body body networkScanRequest false "Scan options"
@Success 201 {object} ScanResponse
@Failure 400 {object} ErrorResponse
@Failure 404 {object} ErrorResponse
@Failure 503 {object} ErrorResponse
@Router /networks/{id}/scan [post]
func (*NetworkHandler) UpdateNetwork ¶ added in v0.8.0
func (h *NetworkHandler) UpdateNetwork(w http.ResponseWriter, r *http.Request)
UpdateNetwork handles PUT /api/v1/networks/{id}.
func (*NetworkHandler) WithDiscovery ¶ added in v0.20.0
func (h *NetworkHandler) WithDiscovery(store DiscoveryStore, engine *discovery.Engine) *NetworkHandler
WithDiscovery injects the discovery store and engine so that POST /networks/{id}/discover can create and immediately run a discovery job.
func (*NetworkHandler) WithHostService ¶ added in v0.23.0
func (h *NetworkHandler) WithHostService(svc HostServicer) *NetworkHandler
WithHostService wires the host service into the handler.
func (*NetworkHandler) WithScanQueue ¶ added in v0.22.0
func (h *NetworkHandler) WithScanQueue(q *scanning.ScanQueue) *NetworkHandler
WithScanQueue sets the worker pool used to execute network discovery jobs. When set, StartNetworkDiscovery submits a discoveryJob to the queue instead of spawning an unbounded goroutine.
func (*NetworkHandler) WithScanService ¶ added in v0.23.0
func (h *NetworkHandler) WithScanService(svc ScanServicer) *NetworkHandler
WithScanService wires the scan service into the handler.
type NetworkServicer ¶ added in v0.13.0
type NetworkServicer interface {
ListNetworks(ctx context.Context, activeOnly bool) ([]*db.Network, error)
GetNetworkByID(ctx context.Context, id uuid.UUID) (*services.NetworkWithExclusions, error)
CreateNetwork(
ctx context.Context, name, cidr, description, method string, active, scanEnabled bool,
) (*db.Network, error)
UpdateNetwork(
ctx context.Context, id uuid.UUID, name, cidr, description, method string, active bool,
) (*db.Network, error)
DeleteNetwork(ctx context.Context, id uuid.UUID) error
AddExclusion(ctx context.Context, networkID *uuid.UUID, cidr, reason string) (*db.NetworkExclusion, error)
RemoveExclusion(ctx context.Context, exclusionID uuid.UUID) error
GetNetworkExclusions(ctx context.Context, networkID uuid.UUID) ([]*db.NetworkExclusion, error)
GetGlobalExclusions(ctx context.Context) ([]*db.NetworkExclusion, error)
GetNetworkStats(ctx context.Context) (map[string]interface{}, error)
}
NetworkServicer is the subset of *services.NetworkService used by NetworkHandler.
type NetworkStatsResponse ¶ added in v0.8.0
type NetworkStatsResponse struct {
Networks map[string]interface{} `json:"networks"`
Hosts map[string]interface{} `json:"hosts"`
Exclusions map[string]interface{} `json:"exclusions"`
}
NetworkStatsResponse is the response body for network statistics.
type OSFamilyCount ¶ added in v0.24.0
OSFamilyCount holds a count for a given OS family.
type PaginatedResponse ¶
type PaginatedResponse struct {
Data interface{} `json:"data"`
Pagination struct {
Page int `json:"page"`
PageSize int `json:"page_size"`
TotalItems int64 `json:"total_items"`
TotalPages int `json:"total_pages"`
} `json:"pagination"`
}
PaginatedResponse represents a paginated API response.
type PaginationMeta ¶ added in v0.22.0
type PaginationMeta struct {
Page int `json:"page"`
PageSize int `json:"page_size"`
TotalItems int `json:"total_items"`
TotalPages int `json:"total_pages"`
}
PaginationMeta carries the pagination summary in a LogsResponse.
type PaginationParams ¶
type PaginationParams struct {
Page int `json:"page"`
PageSize int `json:"page_size"`
Offset int `json:"offset"`
}
PaginationParams holds pagination parameters.
type PortHandler ¶ added in v0.25.0
type PortHandler struct {
// contains filtered or unexported fields
}
PortHandler handles port definition endpoints.
func NewPortHandler ¶ added in v0.25.0
func NewPortHandler(repo *db.PortRepository, logger *slog.Logger, m *metrics.Registry) *PortHandler
NewPortHandler creates a new PortHandler.
func (*PortHandler) GetPort ¶ added in v0.25.0
func (h *PortHandler) GetPort(w http.ResponseWriter, r *http.Request)
GetPort handles GET /api/v1/ports/{port} — look up a single port definition.
@Summary Get port definition
@Description Returns the service definition for a specific port number.
@Description Use ?protocol=tcp (default) or ?protocol=udp.
@Tags ports
@Produce json
@Param port path int true "Port number"
@Param protocol query string false "Protocol (tcp or udp, default tcp)"
@Success 200 {object} db.PortDefinition
@Failure 404 {object} docs.ErrorResponse
@Router /ports/{port} [get]
func (*PortHandler) ListPortCategories ¶ added in v0.25.0
func (h *PortHandler) ListPortCategories(w http.ResponseWriter, r *http.Request)
ListPortCategories handles GET /api/v1/ports/categories — list distinct categories.
@Summary List port categories
@Description Returns the distinct category values used in the port definition database.
@Tags ports
@Produce json
@Success 200 {object} docs.StringListResponse
@Router /ports/categories [get]
func (*PortHandler) ListPortHostCounts ¶ added in v0.25.0
func (h *PortHandler) ListPortHostCounts(w http.ResponseWriter, r *http.Request)
ListPortHostCounts handles GET /api/v1/ports/host-counts — returns per-port open host counts.
@Summary List port host counts
@Description Returns the number of distinct hosts with each port open, ordered by host count descending.
@Tags ports
@Produce json
@Success 200 {array} docs.PortHostCountResponse
@Router /ports/host-counts [get]
@Security BearerAuth
func (*PortHandler) ListPorts ¶ added in v0.25.0
func (h *PortHandler) ListPorts(w http.ResponseWriter, r *http.Request)
ListPorts handles GET /api/v1/ports — list/search port definitions with pagination.
@Summary List port definitions
@Description Returns a paginated list of well-known port/service definitions.
@Description Supports filtering by search query, category, and protocol.
@Tags ports
@Produce json
@Param search query string false "Search by port number, service name, or description"
@Param category query string false "Filter by category (web, database, windows, etc.)"
@Param protocol query string false "Filter by protocol (tcp or udp)"
@Param sort_by query string false "Sort field (port, service, category)"
@Param sort_order query string false "Sort direction (asc or desc)"
@Param page query int false "Page number"
@Param page_size query int false "Results per page"
@Success 200 {object} docs.PortListResponse
@Router /ports [get]
type ProfileHandler ¶
type ProfileHandler struct {
// contains filtered or unexported fields
}
ProfileHandler handles profile-related API endpoints.
func NewProfileHandler ¶
func NewProfileHandler(service ProfileServicer, logger *slog.Logger, metricsManager *metrics.Registry) *ProfileHandler
NewProfileHandler creates a new profile handler.
func (*ProfileHandler) CloneProfile ¶ added in v0.19.1
func (h *ProfileHandler) CloneProfile(w http.ResponseWriter, r *http.Request)
CloneProfile handles POST /api/v1/profiles/{id}/clone — create a copy of an existing profile. The JSON body must contain {"name": "<new name>"}.
func (*ProfileHandler) CreateProfile ¶
func (h *ProfileHandler) CreateProfile(w http.ResponseWriter, r *http.Request)
CreateProfile handles POST /api/v1/profiles - create a new profile.
func (*ProfileHandler) DeleteProfile ¶
func (h *ProfileHandler) DeleteProfile(w http.ResponseWriter, r *http.Request)
DeleteProfile handles DELETE /api/v1/profiles/{id} - delete a profile.
func (*ProfileHandler) GetProfile ¶
func (h *ProfileHandler) GetProfile(w http.ResponseWriter, r *http.Request)
GetProfile handles GET /api/v1/profiles/{id} - get a specific profile.
func (*ProfileHandler) GetProfileStats ¶ added in v0.25.0
func (h *ProfileHandler) GetProfileStats(w http.ResponseWriter, r *http.Request)
GetProfileStats handles GET /api/v1/profiles/{id}/stats — scan effectiveness stats.
func (*ProfileHandler) ListProfiles ¶
func (h *ProfileHandler) ListProfiles(w http.ResponseWriter, r *http.Request)
ListProfiles handles GET /api/v1/profiles - list all profiles with pagination.
func (*ProfileHandler) UpdateProfile ¶
func (h *ProfileHandler) UpdateProfile(w http.ResponseWriter, r *http.Request)
UpdateProfile handles PUT /api/v1/profiles/{id} - update a profile.
type ProfileRequest ¶
type ProfileRequest struct {
Name string `json:"name" validate:"required,min=1,max=255"`
Description string `json:"description,omitempty"`
// ScanType supports: connect, syn, ack, aggressive, comprehensive
ScanType string `json:"scan_type" validate:"required"`
Ports string `json:"ports,omitempty"`
Options map[string]string `json:"options,omitempty"`
Timing TimingProfile `json:"timing,omitempty"`
ServiceDetection bool `json:"service_detection"`
OSDetection bool `json:"os_detection"`
ScriptScan bool `json:"script_scan"`
UDPScan bool `json:"udp_scan"`
MaxRetries int `json:"max_retries,omitempty"`
HostTimeout Duration `json:"host_timeout,omitempty"`
ScanDelay Duration `json:"scan_delay,omitempty"`
MaxRatePPS int `json:"max_rate_pps,omitempty"`
MaxHostGroupSize int `json:"max_host_group_size,omitempty"`
MinHostGroupSize int `json:"min_host_group_size,omitempty"`
Tags []string `json:"tags,omitempty"`
Default bool `json:"default"`
}
ProfileRequest represents a profile creation/update request.
type ProfileResponse ¶
type ProfileResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
ScanType string `json:"scan_type"`
Ports string `json:"ports,omitempty"`
Options map[string]string `json:"options,omitempty"`
Timing TimingProfile `json:"timing,omitempty"`
ServiceDetection bool `json:"service_detection"`
OSDetection bool `json:"os_detection"`
ScriptScan bool `json:"script_scan"`
UDPScan bool `json:"udp_scan"`
MaxRetries int `json:"max_retries,omitempty"`
HostTimeout time.Duration `json:"host_timeout,omitempty"`
ScanDelay time.Duration `json:"scan_delay,omitempty"`
MaxRatePPS int `json:"max_rate_pps,omitempty"`
MaxHostGroupSize int `json:"max_host_group_size,omitempty"`
MinHostGroupSize int `json:"min_host_group_size,omitempty"`
Tags []string `json:"tags,omitempty"`
Default bool `json:"default"`
UsageCount int `json:"usage_count"`
LastUsed *time.Time `json:"last_used,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy string `json:"created_by,omitempty"`
}
ProfileResponse represents a profile response.
type ProfileServicer ¶ added in v0.19.1
type ProfileServicer interface {
ListProfiles(ctx context.Context, filters db.ProfileFilters, offset, limit int) ([]*db.ScanProfile, int64, error)
CreateProfile(ctx context.Context, input db.CreateProfileInput) (*db.ScanProfile, error)
GetProfile(ctx context.Context, id string) (*db.ScanProfile, error)
UpdateProfile(ctx context.Context, id string, input db.UpdateProfileInput) (*db.ScanProfile, error)
DeleteProfile(ctx context.Context, id string) error
// CloneProfile creates a new user-owned profile that is a copy of the source
// profile identified by fromID, assigned the given newName.
CloneProfile(ctx context.Context, fromID string, newName string) (*db.ScanProfile, error)
// GetProfileStats returns scan effectiveness statistics for a profile.
GetProfileStats(ctx context.Context, id string) (*db.ProfileStats, error)
}
ProfileServicer is the service-level interface consumed by ProfileHandler. It extends the basic CRUD contract with a CloneProfile operation.
type ProfileStatsResponse ¶ added in v0.25.0
type ProfileStatsResponse struct {
ProfileID string `json:"profile_id"`
TotalScans int `json:"total_scans"`
UniqueHosts int `json:"unique_hosts"`
LastUsed *time.Time `json:"last_used"`
AvgHostsFound *float64 `json:"avg_hosts_found"`
}
ProfileStatsResponse represents effectiveness statistics for a scan profile.
type RenameNetworkRequest ¶ added in v0.8.0
type RenameNetworkRequest struct {
NewName string `json:"new_name" validate:"required,min=1,max=100"`
}
RenameNetworkRequest represents the request body for renaming a network.
type SNMPCredentialsHandler ¶ added in v0.25.0
type SNMPCredentialsHandler struct {
// contains filtered or unexported fields
}
SNMPCredentialsHandler handles the /api/v1/admin/snmp/credentials endpoints.
func NewSNMPCredentialsHandler ¶ added in v0.25.0
func NewSNMPCredentialsHandler(repo *db.SNMPCredentialsRepository, logger *slog.Logger) *SNMPCredentialsHandler
NewSNMPCredentialsHandler creates a new SNMPCredentialsHandler.
func (*SNMPCredentialsHandler) DeleteSNMPCredential ¶ added in v0.25.0
func (h *SNMPCredentialsHandler) DeleteSNMPCredential(w http.ResponseWriter, r *http.Request)
DeleteSNMPCredential handles DELETE /api/v1/admin/snmp/credentials/{id}.
func (*SNMPCredentialsHandler) ListSNMPCredentials ¶ added in v0.25.0
func (h *SNMPCredentialsHandler) ListSNMPCredentials(w http.ResponseWriter, r *http.Request)
ListSNMPCredentials handles GET /api/v1/admin/snmp/credentials. Secrets are redacted in the response.
func (*SNMPCredentialsHandler) UpsertSNMPCredential ¶ added in v0.25.0
func (h *SNMPCredentialsHandler) UpsertSNMPCredential(w http.ResponseWriter, r *http.Request)
UpsertSNMPCredential handles PUT /api/v1/admin/snmp/credentials. Creates or replaces the credential set for the given network/version scope.
type ScanHandler ¶
type ScanHandler struct {
// contains filtered or unexported fields
}
ScanHandler handles scan-related API endpoints.
func NewScanHandler ¶
func NewScanHandler(service ScanServicer, logger *slog.Logger, metricsManager *metrics.Registry) *ScanHandler
NewScanHandler creates a new scan handler.
func (*ScanHandler) CreateScan ¶
func (h *ScanHandler) CreateScan(w http.ResponseWriter, r *http.Request)
CreateScan handles POST /api/v1/scans — create a new scan. Input validation (name, targets, scan type, ports, profile existence) is performed by the service; validation errors are returned as HTTP 400.
func (*ScanHandler) DeleteScan ¶
func (h *ScanHandler) DeleteScan(w http.ResponseWriter, r *http.Request)
DeleteScan handles DELETE /api/v1/scans/{id} — delete a scan.
func (*ScanHandler) GetScan ¶
func (h *ScanHandler) GetScan(w http.ResponseWriter, r *http.Request)
GetScan handles GET /api/v1/scans/{id} — get a specific scan.
func (*ScanHandler) GetScanResults ¶
func (h *ScanHandler) GetScanResults(w http.ResponseWriter, r *http.Request)
GetScanResults handles GET /api/v1/scans/{id}/results - get scan results.
func (*ScanHandler) ListScans ¶
func (h *ScanHandler) ListScans(w http.ResponseWriter, r *http.Request)
ListScans handles GET /api/v1/scans - list all scans with pagination. ListScans handles GET /api/v1/scans - list scans with filtering and pagination.
func (*ScanHandler) SetScanQueue ¶ added in v0.13.0
func (h *ScanHandler) SetScanQueue(q *scanning.ScanQueue)
SetScanQueue configures an optional scan execution queue. When set, StartScan submits work to the queue instead of spawning an unbounded goroutine. SetScanQueue injects an execution queue for API-triggered scans. Pass nil to revert to fire-and-forget goroutine mode.
func (*ScanHandler) StartScan ¶
func (h *ScanHandler) StartScan(w http.ResponseWriter, r *http.Request)
StartScan handles POST /api/v1/scans/{id}/start — start scan execution. State-machine checks (already running / already completed) are enforced by the service; this handler is responsible only for queue submission.
func (*ScanHandler) StopScan ¶
func (h *ScanHandler) StopScan(w http.ResponseWriter, r *http.Request)
StopScan handles POST /api/v1/scans/{id}/stop — stop scan execution.
func (*ScanHandler) UpdateScan ¶
func (h *ScanHandler) UpdateScan(w http.ResponseWriter, r *http.Request)
UpdateScan handles PUT /api/v1/scans/{id} — update a scan.
func (*ScanHandler) WithScanMode ¶ added in v0.14.0
func (h *ScanHandler) WithScanMode(mode string) *ScanHandler
WithScanMode sets the fallback scan mode used when a scan record does not carry an explicit ScanType. The sentinel default "connect" is applied last so callers may pass an empty string safely. WithScanMode overrides the default scan mode used when the scan record has no explicit scan_type set.
type ScanQueueInfo ¶ added in v0.13.0
type ScanQueueInfo struct {
Configured bool `json:"configured"`
QueueDepth int `json:"queue_depth"`
ActiveScans int `json:"active_scans"`
MaxConcurrent int `json:"max_concurrent"`
MaxQueueSize int `json:"max_queue_size"`
TotalSubmitted int64 `json:"total_submitted"`
TotalCompleted int64 `json:"total_completed"`
TotalRejected int64 `json:"total_rejected"`
TotalFailed int64 `json:"total_failed"`
}
ScanQueueInfo contains scan queue status information.
type ScanRequest ¶
type ScanRequest struct {
Name string `json:"name" validate:"required,min=1,max=255"`
Description string `json:"description,omitempty"`
Targets []string `json:"targets" validate:"required,min=1"`
ScanType string `json:"scan_type" validate:"required,oneof=connect syn ack udp aggressive comprehensive"` //nolint:lll
OSDetection bool `json:"os_detection,omitempty"`
Ports string `json:"ports,omitempty"`
ProfileID *string `json:"profile_id,omitempty"`
Options map[string]string `json:"options,omitempty"`
ScheduleID *int64 `json:"schedule_id,omitempty"`
Tags []string `json:"tags,omitempty"`
}
ScanRequest represents a scan creation/update request.
type ScanResponse ¶
type ScanResponse struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Targets []string `json:"targets"`
ScanType string `json:"scan_type"`
Ports string `json:"ports,omitempty"`
ProfileID *string `json:"profile_id,omitempty"`
Options map[string]string `json:"options,omitempty"`
ScheduleID *int64 `json:"schedule_id,omitempty"`
Tags []string `json:"tags,omitempty"`
Status string `json:"status"`
Progress float64 `json:"progress"`
StartTime *time.Time `json:"started_at,omitempty"`
EndTime *time.Time `json:"completed_at,omitempty"`
Duration *string `json:"duration,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy string `json:"created_by,omitempty"`
ErrorMessage *string `json:"error_message,omitempty"`
PortsScanned *string `json:"ports_scanned,omitempty"`
}
ScanResponse represents a scan response.
type ScanResult ¶
type ScanResult struct {
ID uuid.UUID `json:"id"`
HostIP string `json:"host_ip"`
Hostname string `json:"hostname,omitempty"`
Port int `json:"port"`
Protocol string `json:"protocol"`
State string `json:"state"`
Service string `json:"service,omitempty"`
Version string `json:"version,omitempty"`
Banner string `json:"banner,omitempty"`
ScanTime time.Time `json:"scan_time"`
OSName string `json:"os_name,omitempty"`
OSFamily string `json:"os_family,omitempty"`
OSVersion string `json:"os_version,omitempty"`
OSConfidence *int `json:"os_confidence,omitempty"`
}
ScanResult represents an individual scan result.
type ScanResultsResponse ¶
type ScanResultsResponse struct {
ScanID uuid.UUID `json:"scan_id"`
TotalHosts int `json:"total_hosts"`
TotalPorts int `json:"total_ports"`
OpenPorts int `json:"open_ports"`
ClosedPorts int `json:"closed_ports"`
Results []ScanResult `json:"results"`
Summary *db.ScanSummary `json:"summary"`
GeneratedAt time.Time `json:"generated_at"`
}
ScanResultsResponse represents scan results.
type ScanServicer ¶ added in v0.19.1
type ScanServicer interface {
ListScans(ctx context.Context, filters db.ScanFilters, offset, limit int) ([]*db.Scan, int64, error)
CreateScan(ctx context.Context, input db.CreateScanInput) (*db.Scan, error)
GetScan(ctx context.Context, id uuid.UUID) (*db.Scan, error)
UpdateScan(ctx context.Context, id uuid.UUID, input db.UpdateScanInput) (*db.Scan, error)
DeleteScan(ctx context.Context, id uuid.UUID) error
// StartScan validates the scan is in a startable state, marks it running,
// and returns the refreshed scan record — saving the caller an extra GetScan call.
StartScan(ctx context.Context, id uuid.UUID) (*db.Scan, error)
StopScan(ctx context.Context, id uuid.UUID, errMsg ...string) error
CompleteScan(ctx context.Context, id uuid.UUID) error
GetScanResults(ctx context.Context, scanID uuid.UUID, offset, limit int) ([]*db.ScanResult, int64, error)
GetScanSummary(ctx context.Context, scanID uuid.UUID) (*db.ScanSummary, error)
GetProfile(ctx context.Context, id string) (*db.ScanProfile, error)
}
ScanServicer is the service-level interface consumed by ScanHandler. It extends the basic CRUD contract with a lifecycle-aware StartScan that enforces the state machine and returns the updated scan in one round-trip.
type ScanUpdateMessage ¶
type ScanUpdateMessage struct {
ScanID int64 `json:"scan_id"`
Status string `json:"status"`
Progress float64 `json:"progress"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
StartTime *time.Time `json:"start_time,omitempty"`
EndTime *time.Time `json:"end_time,omitempty"`
ResultsCount int `json:"results_count,omitempty"`
}
ScanUpdateMessage represents a scan status update.
type ScanningConfigUpdate ¶
type ScanningConfigUpdate struct {
WorkerPoolSize *int `json:"worker_pool_size,omitempty" validate:"omitempty,min=1,max=1000"`
DefaultInterval *string `json:"default_interval,omitempty"`
MaxScanTimeout *string `json:"max_scan_timeout,omitempty"`
DefaultPorts *string `json:"default_ports,omitempty" validate:"omitempty,max=1000"`
ScanMode *string `json:"scan_mode,omitempty" validate:"omitempty,oneof=connect syn ack udp aggressive comprehensive"` //nolint:lll
MaxConcurrentTargets *int `json:"max_concurrent_targets,omitempty" validate:"omitempty,min=1,max=10000"`
EnableServiceDetection *bool `json:"enable_service_detection,omitempty"`
EnableOSDetection *bool `json:"enable_os_detection,omitempty"`
}
ScanningConfigUpdate represents updatable scanning configuration fields.
type ScheduleHandler ¶
type ScheduleHandler struct {
// contains filtered or unexported fields
}
ScheduleHandler handles schedule-related API endpoints.
func NewScheduleHandler ¶
func NewScheduleHandler( service ScheduleServicer, logger *slog.Logger, metricsManager *metrics.Registry, ) *ScheduleHandler
NewScheduleHandler creates a new schedule handler.
func (*ScheduleHandler) CreateSchedule ¶
func (h *ScheduleHandler) CreateSchedule(w http.ResponseWriter, r *http.Request)
CreateSchedule handles POST /api/v1/schedules - create a new schedule.
func (*ScheduleHandler) CreateSmartScanSchedule ¶ added in v0.25.0
func (h *ScheduleHandler) CreateSmartScanSchedule(w http.ResponseWriter, r *http.Request)
CreateSmartScanSchedule handles POST /api/v1/schedules/smart-scan — creates a recurring smart-scan job that re-queues hosts with knowledge gaps on a cron schedule.
@Summary Create a scheduled Smart Scan
@Description Creates a recurring cron job that calls QueueBatch on each fire.
@Tags schedules
@Accept json
@Produce json
@Param body body SmartScanScheduleRequest true "Smart scan schedule config"
@Success 201 {object} ScheduleResponse
@Failure 400 {object} ErrorResponse
@Failure 500 {object} ErrorResponse
@Router /schedules/smart-scan [post]
func (*ScheduleHandler) DeleteSchedule ¶
func (h *ScheduleHandler) DeleteSchedule(w http.ResponseWriter, r *http.Request)
DeleteSchedule handles DELETE /api/v1/schedules/{id} - delete a schedule.
func (*ScheduleHandler) DisableSchedule ¶
func (h *ScheduleHandler) DisableSchedule(w http.ResponseWriter, r *http.Request)
DisableSchedule handles POST /api/v1/schedules/{id}/disable - disable a schedule.
func (*ScheduleHandler) EnableSchedule ¶
func (h *ScheduleHandler) EnableSchedule(w http.ResponseWriter, r *http.Request)
EnableSchedule handles POST /api/v1/schedules/{id}/enable - enable a schedule.
func (*ScheduleHandler) GetSchedule ¶
func (h *ScheduleHandler) GetSchedule(w http.ResponseWriter, r *http.Request)
GetSchedule handles GET /api/v1/schedules/{id} - get a specific schedule.
func (*ScheduleHandler) GetScheduleNextRun ¶ added in v0.19.1
func (h *ScheduleHandler) GetScheduleNextRun(w http.ResponseWriter, r *http.Request)
GetScheduleNextRun handles GET /api/v1/schedules/{id}/next-run — return the next scheduled execution time.
func (*ScheduleHandler) ListSchedules ¶
func (h *ScheduleHandler) ListSchedules(w http.ResponseWriter, r *http.Request)
ListSchedules handles GET /api/v1/schedules - list all schedules with pagination.
func (*ScheduleHandler) UpdateSchedule ¶
func (h *ScheduleHandler) UpdateSchedule(w http.ResponseWriter, r *http.Request)
UpdateSchedule handles PUT /api/v1/schedules/{id} - update a schedule.
type ScheduleRequest ¶
type ScheduleRequest struct {
Name string `json:"name" validate:"required,min=1,max=255"`
Description string `json:"description,omitempty"`
CronExpr string `json:"cron_expr" validate:"required"`
Type string `json:"type" validate:"required,oneof=scan discovery"`
NetworkID uuid.UUID `json:"network_id" validate:"required"`
Enabled bool `json:"enabled"`
MaxRunTime time.Duration `json:"max_run_time,omitempty"`
RetryOnError bool `json:"retry_on_error"`
MaxRetries int `json:"max_retries,omitempty"`
RetryDelay time.Duration `json:"retry_delay,omitempty"`
Options map[string]string `json:"options,omitempty"`
Tags []string `json:"tags,omitempty"`
NotifyOnFail bool `json:"notify_on_fail"`
NotifyEmails []string `json:"notify_emails,omitempty"`
}
ScheduleRequest represents a schedule creation/update request.
type ScheduleResponse ¶
type ScheduleResponse struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
CronExpr string `json:"cron_expr"`
Type string `json:"type"`
NetworkID string `json:"network_id,omitempty"`
NetworkName string `json:"network_name,omitempty"`
Enabled bool `json:"enabled"`
MaxRunTime time.Duration `json:"max_run_time,omitempty"`
RetryOnError bool `json:"retry_on_error"`
MaxRetries int `json:"max_retries,omitempty"`
RetryDelay time.Duration `json:"retry_delay,omitempty"`
Options map[string]string `json:"options,omitempty"`
Tags []string `json:"tags,omitempty"`
NotifyOnFail bool `json:"notify_on_fail"`
NotifyEmails []string `json:"notify_emails,omitempty"`
Status string `json:"status"`
LastRun *time.Time `json:"last_run,omitempty"`
NextRun *time.Time `json:"next_run,omitempty"`
RunCount int `json:"run_count"`
SuccessCount int `json:"success_count"`
ErrorCount int `json:"error_count"`
LastError string `json:"last_error,omitempty"`
LastDuration *time.Duration `json:"last_duration,omitempty"`
AvgDuration *time.Duration `json:"avg_duration,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy string `json:"created_by,omitempty"`
}
ScheduleResponse represents a schedule response.
type ScheduleServicer ¶ added in v0.19.1
type ScheduleServicer interface {
ListSchedules(ctx context.Context, filters db.ScheduleFilters, offset, limit int) ([]*db.Schedule, int64, error)
CreateSchedule(ctx context.Context, input db.CreateScheduleInput) (*db.Schedule, error)
GetSchedule(ctx context.Context, id uuid.UUID) (*db.Schedule, error)
UpdateSchedule(ctx context.Context, id uuid.UUID, input db.UpdateScheduleInput) (*db.Schedule, error)
DeleteSchedule(ctx context.Context, id uuid.UUID) error
EnableSchedule(ctx context.Context, id uuid.UUID) error
DisableSchedule(ctx context.Context, id uuid.UUID) error
// NextRun computes the next scheduled execution time for the given schedule.
NextRun(ctx context.Context, id uuid.UUID) (time.Time, error)
}
ScheduleServicer is the service-level interface consumed by ScheduleHandler. It adds cron-expression validation (enforced inside CreateSchedule/UpdateSchedule) and a NextRun helper on top of the standard CRUD operations.
type ServiceInfo ¶
type ServiceInfo struct {
Name string `json:"name"`
Version string `json:"version"`
StartTime time.Time `json:"start_time"`
Uptime string `json:"uptime"`
PID int `json:"pid"`
}
ServiceInfo contains service-related information.
type SettingsHandler ¶ added in v0.24.0
type SettingsHandler struct {
// contains filtered or unexported fields
}
SettingsHandler handles the /api/v1/admin/settings endpoints.
func NewSettingsHandler ¶ added in v0.24.0
func NewSettingsHandler(repo *db.SettingsRepository, logger *slog.Logger) *SettingsHandler
NewSettingsHandler creates a new SettingsHandler.
func (*SettingsHandler) GetSettings ¶ added in v0.24.0
func (h *SettingsHandler) GetSettings(w http.ResponseWriter, r *http.Request)
GetSettings handles GET /api/v1/admin/settings.
func (*SettingsHandler) UpdateSettings ¶ added in v0.24.0
func (h *SettingsHandler) UpdateSettings(w http.ResponseWriter, r *http.Request)
UpdateSettings handles PUT /api/v1/admin/settings.
type SmartScanHandler ¶ added in v0.25.0
type SmartScanHandler struct {
// contains filtered or unexported fields
}
SmartScanHandler handles Smart Scan API endpoints.
func NewSmartScanHandler ¶ added in v0.25.0
func NewSmartScanHandler(svc *services.SmartScanService, logger *slog.Logger) *SmartScanHandler
NewSmartScanHandler creates a new SmartScanHandler.
func (*SmartScanHandler) EvaluateHost ¶ added in v0.25.0
func (h *SmartScanHandler) EvaluateHost(w http.ResponseWriter, r *http.Request)
EvaluateHost handles GET /api/v1/smart-scan/hosts/{id}/stage.
@Summary Evaluate next scan stage for a host
@Description Returns the recommended next scan stage for the specified host.
@Tags smart-scan
@Produce json
@Param id path string true "Host UUID"
@Success 200 {object} services.ScanStage
@Failure 400 {object} ErrorResponse
@Failure 404 {object} ErrorResponse
@Failure 500 {object} ErrorResponse
@Router /smart-scan/hosts/{id}/stage [get]
func (*SmartScanHandler) GetProfileRecommendations ¶ added in v0.25.0
func (h *SmartScanHandler) GetProfileRecommendations(w http.ResponseWriter, r *http.Request)
GetProfileRecommendations handles GET /api/v1/smart-scan/profile-recommendations.
@Summary Get profile recommendations
@Description Returns profile suggestions grouped by detected OS family.
@Tags smart-scan
@Produce json
@Success 200 {array} services.ProfileRecommendation
@Failure 500 {object} ErrorResponse
@Router /smart-scan/profile-recommendations [get]
func (*SmartScanHandler) GetSuggestions ¶ added in v0.25.0
func (h *SmartScanHandler) GetSuggestions(w http.ResponseWriter, r *http.Request)
GetSuggestions handles GET /api/v1/smart-scan/suggestions.
@Summary Get Smart Scan suggestions
@Description Returns fleet-wide counts of hosts in each knowledge-gap category.
@Tags smart-scan
@Produce json
@Success 200 {object} services.SuggestionSummary
@Failure 500 {object} ErrorResponse
@Router /smart-scan/suggestions [get]
func (*SmartScanHandler) RefreshIdentity ¶ added in v0.26.0
func (h *SmartScanHandler) RefreshIdentity(w http.ResponseWriter, r *http.Request)
RefreshIdentity handles POST /api/v1/smart-scan/hosts/{id}/refresh-identity. It unconditionally queues an identity_enrichment scan for the host — bypassing the usual "does the host need this?" evaluation because the user asked explicitly via the Identity tab's "Refresh identity now" button.
@Summary Refresh host identity
@Description Queues an identity_enrichment scan for the host, probing mDNS/SNMP/DNS/TLS surfaces so post-scan
@Description enrichment can fill in name signals. Runs even when the host already has a usable name.
@Tags smart-scan
@Produce json
@Param id path string true "Host UUID"
@Success 202 {object} triggerHostResponse
@Failure 400 {object} ErrorResponse
@Failure 404 {object} ErrorResponse
@Failure 429 {object} ErrorResponse
@Failure 500 {object} ErrorResponse
@Router /smart-scan/hosts/{id}/refresh-identity [post]
func (*SmartScanHandler) TriggerBatch ¶ added in v0.25.0
func (h *SmartScanHandler) TriggerBatch(w http.ResponseWriter, r *http.Request)
TriggerBatch handles POST /api/v1/smart-scan/trigger-batch.
@Summary Batch trigger Smart Scan
@Description Queues smart scans for all eligible hosts matching the filter.
@Tags smart-scan
@Accept json
@Produce json
@Param body body triggerBatchRequest false "Batch filter"
@Success 202 {object} services.BatchResult
@Failure 400 {object} ErrorResponse
@Failure 500 {object} ErrorResponse
@Router /smart-scan/trigger-batch [post]
func (*SmartScanHandler) TriggerHost ¶ added in v0.25.0
func (h *SmartScanHandler) TriggerHost(w http.ResponseWriter, r *http.Request)
TriggerHost handles POST /api/v1/smart-scan/hosts/{id}/trigger.
@Summary Trigger Smart Scan for a host
@Description Evaluates the host's knowledge gaps and queues the appropriate scan.
@Tags smart-scan
@Produce json
@Param id path string true "Host UUID"
@Success 202 {object} triggerHostResponse
@Success 200 {object} triggerHostResponse "No action needed"
@Failure 400 {object} ErrorResponse
@Failure 429 {object} ErrorResponse
@Failure 500 {object} ErrorResponse
@Router /smart-scan/hosts/{id}/trigger [post]
type SmartScanScheduleRequest ¶ added in v0.25.0
type SmartScanScheduleRequest struct {
Name string `json:"name"`
CronExpr string `json:"cron_expr"`
Enabled bool `json:"enabled"`
ScoreThreshold int `json:"score_threshold,omitempty"`
MaxStalenessHours int `json:"max_staleness_hours,omitempty"`
NetworkCIDR string `json:"network_cidr,omitempty"`
Limit int `json:"limit,omitempty"`
}
SmartScanScheduleRequest is the request body for POST /schedules/smart-scan.
type StatsHandler ¶ added in v0.24.0
type StatsHandler struct {
// contains filtered or unexported fields
}
StatsHandler handles statistics API endpoints.
func NewStatsHandler ¶ added in v0.24.0
func NewStatsHandler(database *db.DB, logger *slog.Logger) *StatsHandler
NewStatsHandler creates a new StatsHandler.
func (*StatsHandler) GetStatsSummary ¶ added in v0.24.0
func (h *StatsHandler) GetStatsSummary(w http.ResponseWriter, r *http.Request)
GetStatsSummary handles GET /api/v1/stats/summary.
@Summary Get statistics summary
@Description Returns aggregated statistics including host counts by status and OS family,
@Description top open ports, stale host count, average scan duration, average knowledge
@Description score, and the distribution of knowledge scores across four bands.
@Tags stats
@Produce json
@Success 200 {object} StatsSummaryResponse
@Failure 500 {object} ErrorResponse
@Router /stats/summary [get]
type StatsSummaryResponse ¶ added in v0.24.0
type StatsSummaryResponse struct {
HostsByStatus map[string]int `json:"hosts_by_status"`
HostsByOSFamily []OSFamilyCount `json:"hosts_by_os_family"`
TopPorts []PortCount `json:"top_ports"`
StaleHostCount int `json:"stale_host_count"`
AvgScanDurationS float64 `json:"avg_scan_duration_s"`
AvgKnowledgeScore float64 `json:"avg_knowledge_score"`
KnowledgeScoreDistribution KnowledgeScoreDistribution `json:"knowledge_score_distribution"`
}
StatsSummaryResponse holds the aggregated statistics summary.
type StatusResponse ¶
type StatusResponse struct {
Service ServiceInfo `json:"service"`
System SystemInfo `json:"system"`
Database DatabaseInfo `json:"database"`
Metrics MetricsInfo `json:"metrics"`
ScanQueue ScanQueueInfo `json:"scan_queue"`
Health HealthResponse `json:"health"`
Timestamp time.Time `json:"timestamp"`
}
StatusResponse represents a detailed status response.
type SystemInfo ¶
type SystemInfo struct {
OS string `json:"os"`
Architecture string `json:"architecture"`
CPUs int `json:"cpus"`
GoVersion string `json:"go_version"`
Memory MemoryInfo `json:"memory"`
Goroutines int `json:"goroutines"`
Environment map[string]string `json:"environment,omitempty"`
}
SystemInfo contains system-related information.
type TimingProfile ¶
type TimingProfile struct {
Template string `json:"template,omitempty"` // paranoid, sneaky, polite, normal, aggressive, insane
MinRTTTimeout Duration `json:"min_rtt_timeout,omitempty"`
MaxRTTTimeout Duration `json:"max_rtt_timeout,omitempty"`
InitialRTTTimeout Duration `json:"initial_rtt_timeout,omitempty"`
MaxRetries int `json:"max_retries,omitempty"`
HostTimeout Duration `json:"host_timeout,omitempty"`
ScanDelay Duration `json:"scan_delay,omitempty"`
MaxScanDelay Duration `json:"max_scan_delay,omitempty"`
}
TimingProfile represents timing configuration for scans.
type UpdateNetworkRequest ¶ added in v0.8.0
type UpdateNetworkRequest struct {
Name *string `json:"name,omitempty" validate:"omitempty,min=1,max=100"`
CIDR *string `json:"cidr,omitempty" validate:"omitempty,cidr"`
Description *string `json:"description,omitempty"`
DiscoveryMethod *string `json:"discovery_method,omitempty" validate:"omitempty,oneof=ping tcp arp"`
IsActive *bool `json:"is_active,omitempty"`
ScanEnabled *bool `json:"scan_enabled,omitempty"`
}
UpdateNetworkRequest represents the request body for updating a network.
type VersionResponse ¶
type VersionResponse struct {
Version string `json:"version"`
Commit string `json:"commit"`
BuildTime string `json:"build_time"`
GoVersion string `json:"go_version"`
Timestamp time.Time `json:"timestamp"`
}
VersionResponse represents version information.
type WebSocketHandler ¶
type WebSocketHandler struct {
// contains filtered or unexported fields
}
WebSocketHandler handles WebSocket connections for real-time updates.
func NewWebSocketHandler ¶
func NewWebSocketHandler(logger *slog.Logger, metricsManager *metrics.Registry) *WebSocketHandler
NewWebSocketHandler creates a new WebSocket handler.
func (*WebSocketHandler) BroadcastDiscoveryUpdate ¶
func (h *WebSocketHandler) BroadcastDiscoveryUpdate(update *DiscoveryUpdateMessage) error
BroadcastDiscoveryUpdate sends a discovery update to all connected discovery clients.
func (*WebSocketHandler) BroadcastScanUpdate ¶
func (h *WebSocketHandler) BroadcastScanUpdate(update *ScanUpdateMessage) error
BroadcastScanUpdate sends a scan update to all connected scan clients.
func (*WebSocketHandler) BroadcastSystemMessage ¶
func (h *WebSocketHandler) BroadcastSystemMessage(messageType, content string) error
BroadcastSystemMessage sends a system message to all connected clients.
func (*WebSocketHandler) Close ¶
func (h *WebSocketHandler) Close() error
Close gracefully shuts down the WebSocket handler.
func (*WebSocketHandler) DiscoveryWebSocket ¶
func (h *WebSocketHandler) DiscoveryWebSocket(w http.ResponseWriter, r *http.Request)
DiscoveryWebSocket handles WebSocket connections for discovery updates.
func (*WebSocketHandler) GeneralWebSocket ¶ added in v0.12.0
func (h *WebSocketHandler) GeneralWebSocket(w http.ResponseWriter, r *http.Request)
GeneralWebSocket handles general WebSocket connections for all updates.
func (*WebSocketHandler) GetConnectedClients ¶
func (h *WebSocketHandler) GetConnectedClients() map[string]int
GetConnectedClients returns the number of connected clients by type.
func (*WebSocketHandler) LogsWebSocket ¶ added in v0.22.0
func (h *WebSocketHandler) LogsWebSocket(w http.ResponseWriter, r *http.Request)
func (*WebSocketHandler) ScanWebSocket ¶
func (h *WebSocketHandler) ScanWebSocket(w http.ResponseWriter, r *http.Request)
ScanWebSocket handles WebSocket connections for scan updates.
func (*WebSocketHandler) Shutdown ¶
func (h *WebSocketHandler) Shutdown()
Shutdown gracefully stops the WebSocket handler.
func (*WebSocketHandler) WithRingBuffer ¶ added in v0.22.0
func (h *WebSocketHandler) WithRingBuffer(rb *logging.RingBuffer) *WebSocketHandler
WithRingBuffer sets the ring buffer used for log streaming and returns the handler for method chaining.
type WebSocketMessage ¶
type WebSocketMessage struct {
Type string `json:"type"`
Timestamp time.Time `json:"timestamp"`
Data interface{} `json:"data"`
RequestID string `json:"request_id,omitempty"`
}
WebSocketMessage represents a WebSocket message structure.
type WorkerInfo ¶
type WorkerInfo struct {
ID string `json:"id"`
Status string `json:"status"`
CurrentJob *JobInfo `json:"current_job,omitempty"`
JobsProcessed int64 `json:"jobs_processed"`
JobsFailed int64 `json:"jobs_failed"`
LastJobTime *time.Time `json:"last_job_time,omitempty"`
StartTime time.Time `json:"start_time"`
Uptime time.Duration `json:"uptime"`
MemoryUsage int64 `json:"memory_usage_bytes"`
CPUUsage float64 `json:"cpu_usage_percent"`
ErrorRate float64 `json:"error_rate"`
Metrics map[string]int `json:"metrics"`
}
WorkerInfo represents individual worker information.
type WorkerStatusResponse ¶
type WorkerStatusResponse struct {
TotalWorkers int `json:"total_workers"`
ActiveWorkers int `json:"active_workers"`
IdleWorkers int `json:"idle_workers"`
QueueSize int `json:"queue_size"`
ProcessedJobs int64 `json:"processed_jobs"`
FailedJobs int64 `json:"failed_jobs"`
AvgJobDuration time.Duration `json:"avg_job_duration"`
Workers []WorkerInfo `json:"workers"`
Summary map[string]interface{} `json:"summary"`
Timestamp time.Time `json:"timestamp"`
}
WorkerStatusResponse represents worker pool status information.
Source Files
¶
- admin.go
- admin_config.go
- admin_logging.go
- admin_types.go
- admin_validate.go
- admin_workers.go
- certificates.go
- common.go
- devices.go
- discovery.go
- group.go
- health.go
- host.go
- host_identity.go
- interfaces.go
- manager.go
- networks.go
- ports.go
- profile.go
- scan.go
- schedule.go
- smartscan.go
- snmp_credentials.go
- stats.go
- tags.go
- websocket.go