Documentation
¶
Index ¶
- Constants
- func AddHost(host sirius.Host) error
- func AddHostWithSource(host sirius.Host, source models.ScanSource) error
- func AddHostWithSourceAndJSONB(host sirius.Host, source models.ScanSource, ...) error
- func DeleteHost(ip string) error
- func DetermineSourceFromContext(userAgent, referer, ipAddress string) models.ScanSource
- func GetAllHosts() ([]sirius.Host, error)
- func GetHost(ip string) (sirius.Host, error)
- func GetHostWithSources(ip string) (models.HostWithSources, error)
- func GetSourceCoverageStats() ([]models.SourceCoverageStats, error)
- func GetVulnerabilityHistory(hostID uint, vulnID uint) ([]models.SourceAttribution, error)
- func GetVulnerabilitySources(vulnID string) ([]models.VulnerabilitySourceInfo, error)
- func InvalidateMostVulnerableHostsCache() error
- type EnhancedHostData
- type HostRepository
- func (r *HostRepository) GetAllHostsWithRelations() ([]HostWithRelations, error)
- func (r *HostRepository) GetHostWithRelations(ip string) (*HostWithRelations, error)
- func (r *HostRepository) LinkHostPort(hostID, portID uint, source models.ScanSource) error
- func (r *HostRepository) LinkHostVulnerability(hostID, vulnID uint, source models.ScanSource) error
- func (r *HostRepository) UpdateHostJSONB(hostID uint, ...) error
- func (r *HostRepository) UpsertHost(ip, hostname, os, osVersion, hid string) (hostID uint, err error)
- func (r *HostRepository) UpsertPort(number int, protocol, state string) (portID uint, err error)
- func (r *HostRepository) UpsertVulnerability(vid, title, desc string, score float64) (vulnID uint, err error)
- type HostRiskStats
- type HostVulnerabilitySeverityCounts
- type HostVulnerabilityStats
- type HostWithRelations
- type PortRelation
- type SoftwareInventoryData
- type SoftwareStatistics
- type SystemFingerprintData
- type VulnerabilityRelation
- type VulnerabilitySummary
- type VulnerableHostsResponse
Constants ¶
const ( // CacheKeyMostVulnerable is the base key for caching vulnerable hosts data CacheKeyMostVulnerable = "dashboard:most_vulnerable_hosts" // CacheTTL is the cache time-to-live in seconds (5 minutes) CacheTTL = 300 )
Variables ¶
This section is empty.
Functions ¶
func AddHost ¶
AddHost Chain: SDK Consumer (e.g. Sirius REST API) -> SDK go-api sirius/host (Here) Legacy function - uses repository pattern with "legacy" source for backward compatibility
func AddHostWithSource ¶ added in v0.0.6
func AddHostWithSource(host sirius.Host, source models.ScanSource) error
AddHostWithSource adds or updates a host with source attribution using repository pattern
func AddHostWithSourceAndJSONB ¶ added in v0.0.6
func AddHostWithSourceAndJSONB(host sirius.Host, source models.ScanSource, softwareInventory, systemFingerprint, agentMetadata map[string]interface{}) error
AddHostWithSourceAndJSONB adds or updates a host with source attribution and JSONB data using repository pattern
func DeleteHost ¶
DeleteHost handles the POST /host/delete route DeleteHost Chain: SDK Consumer (e.g. Sirius REST API) -> SDK go-api sirius/host (Here)
func DetermineSourceFromContext ¶ added in v0.0.6
func DetermineSourceFromContext(userAgent, referer, ipAddress string) models.ScanSource
DetermineSourceFromContext attempts to determine scan source from various context clues
func GetAllHosts ¶
func GetHostWithSources ¶ added in v0.0.6
func GetHostWithSources(ip string) (models.HostWithSources, error)
GetHostWithSources retrieves a host with all source-attributed data
func GetSourceCoverageStats ¶ added in v0.0.6
func GetSourceCoverageStats() ([]models.SourceCoverageStats, error)
GetSourceCoverageStats gets statistics about scan source coverage
func GetVulnerabilityHistory ¶ added in v0.0.6
func GetVulnerabilityHistory(hostID uint, vulnID uint) ([]models.SourceAttribution, error)
GetVulnerabilityHistory gets the source history for a specific vulnerability on a host
func GetVulnerabilitySources ¶ added in v0.0.6
func GetVulnerabilitySources(vulnID string) ([]models.VulnerabilitySourceInfo, error)
GetVulnerabilitySources gets all sources that have reported a specific vulnerability
func InvalidateMostVulnerableHostsCache ¶ added in v0.0.12
func InvalidateMostVulnerableHostsCache() error
InvalidateMostVulnerableHostsCache clears all cached vulnerable hosts data This should be called when: - A scan completes and adds new vulnerabilities - Vulnerabilities are bulk updated or imported - Host vulnerability status changes significantly
Types ¶
type EnhancedHostData ¶ added in v0.0.6
type EnhancedHostData struct {
Host sirius.Host `json:"host"`
SoftwareInventory map[string]interface{} `json:"software_inventory,omitempty"`
SystemFingerprint map[string]interface{} `json:"system_fingerprint,omitempty"`
AgentMetadata map[string]interface{} `json:"agent_metadata,omitempty"`
}
EnhancedHostData represents host data with JSONB fields
func GetHostWithEnhancedData ¶ added in v0.0.6
func GetHostWithEnhancedData(ip string, includeFields []string) (*EnhancedHostData, error)
GetHostWithEnhancedData retrieves host information including JSONB fields using repository pattern
type HostRepository ¶ added in v0.0.12
type HostRepository struct {
// contains filtered or unexported fields
}
HostRepository provides explicit database operations for hosts without circular references
func NewHostRepository ¶ added in v0.0.12
func NewHostRepository() *HostRepository
NewHostRepository creates a new HostRepository instance
func (*HostRepository) GetAllHostsWithRelations ¶ added in v0.0.12
func (r *HostRepository) GetAllHostsWithRelations() ([]HostWithRelations, error)
GetAllHostsWithRelations retrieves all hosts with their ports and vulnerabilities
func (*HostRepository) GetHostWithRelations ¶ added in v0.0.12
func (r *HostRepository) GetHostWithRelations(ip string) (*HostWithRelations, error)
GetHostWithRelations retrieves a host with ports and vulnerabilities using explicit JOINs
func (*HostRepository) LinkHostPort ¶ added in v0.0.12
func (r *HostRepository) LinkHostPort(hostID, portID uint, source models.ScanSource) error
LinkHostPort creates or updates a host-port relationship with source attribution
func (*HostRepository) LinkHostVulnerability ¶ added in v0.0.12
func (r *HostRepository) LinkHostVulnerability(hostID, vulnID uint, source models.ScanSource) error
LinkHostVulnerability creates or updates a host-vulnerability relationship with source attribution
func (*HostRepository) UpdateHostJSONB ¶ added in v0.0.12
func (r *HostRepository) UpdateHostJSONB(hostID uint, softwareInventory, systemFingerprint, agentMetadata map[string]interface{}) error
UpdateHostJSONB updates JSONB fields for a host
func (*HostRepository) UpsertHost ¶ added in v0.0.12
func (r *HostRepository) UpsertHost(ip, hostname, os, osVersion, hid string) (hostID uint, err error)
UpsertHost creates or updates a host and returns its ID
func (*HostRepository) UpsertPort ¶ added in v0.0.12
func (r *HostRepository) UpsertPort(number int, protocol, state string) (portID uint, err error)
UpsertPort creates or finds a port by number and protocol, returns its ID
func (*HostRepository) UpsertVulnerability ¶ added in v0.0.12
func (r *HostRepository) UpsertVulnerability(vid, title, desc string, score float64) (vulnID uint, err error)
UpsertVulnerability creates or finds a vulnerability by VID, returns its ID
type HostRiskStats ¶
type HostRiskStats struct {
VulnerabilityCount int `json:"vulnerabilityCount" gorm:"column:vulnerability_count"`
TotalRiskScore float64 `json:"totalRiskScore" gorm:"column:total_risk_score"`
AverageRiskScore float64 `json:"averageRiskScore" gorm:"column:average_risk_score"`
HostSeverityCounts HostVulnerabilitySeverityCounts `json:"hostSeverityCounts" gorm:"-"`
SoftwareStats *SoftwareStatistics `json:"softwareStats,omitempty" gorm:"-"`
LastUpdated string `json:"lastUpdated,omitempty" gorm:"-"`
}
HostRiskStats holds aggregated risk score statistics for vulnerabilities on a host.
func GetHostRiskStatistics ¶
func GetHostRiskStatistics(ip string) (HostRiskStats, error)
GetHostRiskStatistics returns aggregated risk statistics for vulnerabilities on a given host identified by its IP.
type HostVulnerabilitySeverityCounts ¶
type HostVulnerabilitySeverityCounts struct {
Critical int `json:"critical"`
High int `json:"high"`
Medium int `json:"medium"`
Low int `json:"low"`
Informational int `json:"informational"`
}
HostVulnerabilitySeverityCounts holds the count of vulnerabilities by severity for a given host.
func GetHostVulnerabilitySeverityCounts ¶
func GetHostVulnerabilitySeverityCounts(ip string) (HostVulnerabilitySeverityCounts, error)
GetHostVulnerabilitySeverityCounts retrieves vulnerability severity counts for a host identified by its IP.
type HostVulnerabilityStats ¶ added in v0.0.12
type HostVulnerabilityStats struct {
HostID string `json:"hostId" gorm:"column:host_id"`
HostIP string `json:"hostIp" gorm:"column:host_ip"`
Hostname string `json:"hostname,omitempty" gorm:"column:hostname"`
TotalVulnerabilities int `json:"totalVulnerabilities" gorm:"column:total_vulnerabilities"`
WeightedRiskScore float64 `json:"weightedRiskScore" gorm:"column:weighted_risk_score"`
SeverityCounts HostVulnerabilitySeverityCounts `json:"severityCounts" gorm:"-"`
LastUpdated string `json:"lastUpdated" gorm:"column:last_updated"`
}
HostVulnerabilityStats represents vulnerability statistics for a single host
func GetMostVulnerableHosts ¶ added in v0.0.12
func GetMostVulnerableHosts(limit int) ([]HostVulnerabilityStats, error)
GetMostVulnerableHosts returns hosts ranked by weighted vulnerability score The weighted risk score is the sum of all risk_scores for vulnerabilities on that host
type HostWithRelations ¶ added in v0.0.12
type HostWithRelations struct {
Host models.Host
Ports []PortRelation
Vulnerabilities []VulnerabilityRelation
}
HostWithRelations represents a host with its ports and vulnerabilities loaded via explicit JOINs
type PortRelation ¶ added in v0.0.12
type PortRelation struct {
Port models.Port
Source string
SourceVersion string
FirstSeen time.Time
LastSeen time.Time
Status string
Notes string
}
PortRelation represents a port with source attribution
type SoftwareInventoryData ¶ added in v0.0.6
type SoftwareInventoryData struct {
Packages []map[string]interface{} `json:"packages"`
PackageCount int `json:"package_count"`
CollectedAt string `json:"collected_at"`
Source string `json:"source"`
Statistics map[string]interface{} `json:"statistics,omitempty"`
}
SoftwareInventoryData represents structured software inventory information
func GetHostSoftwareInventory ¶ added in v0.0.6
func GetHostSoftwareInventory(ip string) (*SoftwareInventoryData, error)
GetHostSoftwareInventory retrieves only software inventory data for a host
type SoftwareStatistics ¶ added in v0.0.6
type SoftwareStatistics struct {
TotalPackages int `json:"total_packages"`
Architectures map[string]int `json:"architectures"`
Publishers map[string]int `json:"publishers"`
LastUpdated string `json:"last_updated"`
PackagesBySource map[string]int `json:"packages_by_source,omitempty"`
}
SoftwareStatistics represents aggregated software inventory statistics
func GetHostSoftwareStatistics ¶ added in v0.0.6
func GetHostSoftwareStatistics(ip string) (*SoftwareStatistics, error)
GetHostSoftwareStatistics retrieves aggregated software statistics for a host
type SystemFingerprintData ¶ added in v0.0.6
type SystemFingerprintData struct {
Fingerprint map[string]interface{} `json:"fingerprint"`
CollectedAt string `json:"collected_at"`
Source string `json:"source"`
Platform string `json:"platform"`
CollectionDurationMs int64 `json:"collection_duration_ms"`
Summary map[string]interface{} `json:"summary,omitempty"`
}
SystemFingerprintData represents structured system fingerprint information
func GetHostSystemFingerprint ¶ added in v0.0.6
func GetHostSystemFingerprint(ip string) (*SystemFingerprintData, error)
GetHostSystemFingerprint retrieves only system fingerprint data for a host
type VulnerabilityRelation ¶ added in v0.0.12
type VulnerabilityRelation struct {
Vulnerability models.Vulnerability
Source string
SourceVersion string
FirstSeen time.Time
LastSeen time.Time
Status string
Confidence float64
Port *int
ServiceInfo string
Notes string
}
VulnerabilityRelation represents a vulnerability with source attribution
type VulnerabilitySummary ¶
type VulnerabilitySummary struct {
VID string `json:"vid"`
Title string `json:"title"`
HostCount int `json:"hostCount"`
Description string `json:"description"`
RiskScore float64 `json:"riskScore"`
}
VulnerabilitySummary represents a vulnerability with its associated host count
func GetAllVulnerabilities ¶
func GetAllVulnerabilities() ([]VulnerabilitySummary, error)
GetAllVulnerabilities host/vulnerabilities SDK
type VulnerableHostsResponse ¶ added in v0.0.12
type VulnerableHostsResponse struct {
Hosts []HostVulnerabilityStats `json:"hosts"`
TotalHosts int `json:"totalHosts"`
Cached bool `json:"cached"`
CachedAt *string `json:"cachedAt,omitempty"`
TTL int `json:"ttl"`
}
VulnerableHostsResponse is the complete response structure for the API
func GetMostVulnerableHostsCached ¶ added in v0.0.12
func GetMostVulnerableHostsCached(limit int) (VulnerableHostsResponse, error)
GetMostVulnerableHostsCached returns cached data or calculates fresh statistics This function implements a caching layer with Valkey to reduce database load