threat

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2026 License: GPL-3.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package threat implements the application service for the threat bounded context — orchestrates pkg/domain/threat entities and cross-cutting concerns (audit, notifications, RBAC).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActorService

type ActorService struct {
	// contains filtered or unexported fields
}

ActorService manages threat actor intelligence.

func NewActorService

func NewActorService(repo threatactor.Repository, log *logger.Logger) *ActorService

NewActorService creates a new threat actor service.

func (*ActorService) CreateActor

func (s *ActorService) CreateActor(ctx context.Context, input CreateActorInput) (*threatactor.ThreatActor, error)

CreateActor creates a new threat actor.

func (*ActorService) DeleteActor

func (s *ActorService) DeleteActor(ctx context.Context, tenantID, actorID string) error

DeleteActor deletes a threat actor.

func (*ActorService) GetActor

func (s *ActorService) GetActor(ctx context.Context, tenantID, actorID string) (*threatactor.ThreatActor, error)

GetActor retrieves a threat actor by ID.

func (*ActorService) ListActors

ListActors lists threat actors with filtering.

type CreateActorInput

type CreateActorInput struct {
	TenantID         string
	Name             string
	Aliases          []string
	Description      string
	ActorType        string
	Sophistication   string
	Motivation       string
	CountryOfOrigin  string
	MitreGroupID     string
	TTPs             []threatactor.TTP
	TargetIndustries []string
	TargetRegions    []string
	Tags             []string
}

CreateActorInput holds input for creating a threat actor.

type EPSSStats

type EPSSStats struct {
	TotalScores       int `json:"total_scores"`
	HighRiskCount     int `json:"high_risk_count"`     // EPSS >= epssHighThreshold (0.1)
	CriticalRiskCount int `json:"critical_risk_count"` // EPSS >= epssCriticalThreshold (0.5)
}

EPSSStats contains EPSS statistics. When produced by GetEPSSStatsForTenant (the /threat-intel/stats dashboard path), the counts are tenant-scoped: HighRiskCount / CriticalRiskCount are the tenant's OPEN findings whose CVE has an EPSS score >= epssHighThreshold / epssCriticalThreshold.

type IntelService

type IntelService struct {
	// contains filtered or unexported fields
}

IntelService handles threat intelligence operations.

func NewIntelService

func NewIntelService(
	repo threatintel.ThreatIntelRepository,
	log *logger.Logger,
) *IntelService

NewIntelService creates a new IntelService.

func (*IntelService) EnrichCVE

EnrichCVE enriches a single CVE with threat intel data.

func (*IntelService) EnrichCVEs

func (s *IntelService) EnrichCVEs(ctx context.Context, cveIDs []string) (map[string]*threatintel.ThreatIntelEnrichment, error)

EnrichCVEs enriches multiple CVEs with threat intel data.

func (*IntelService) GetEPSSScore

func (s *IntelService) GetEPSSScore(ctx context.Context, cveID string) (*threatintel.EPSSScore, error)

GetEPSSScore retrieves an EPSS score by CVE ID.

func (*IntelService) GetEPSSScores

func (s *IntelService) GetEPSSScores(ctx context.Context, cveIDs []string) ([]*threatintel.EPSSScore, error)

GetEPSSScores retrieves EPSS scores for multiple CVE IDs.

func (*IntelService) GetEPSSStats

func (s *IntelService) GetEPSSStats(ctx context.Context) (*EPSSStats, error)

GetEPSSStats returns EPSS statistics.

func (*IntelService) GetEPSSStatsForTenant added in v0.6.0

func (s *IntelService) GetEPSSStatsForTenant(ctx context.Context, tenantID shared.ID) (*EPSSStats, error)

GetEPSSStatsForTenant returns EPSS statistics scoped to a single tenant's exposure. Unlike GetEPSSStats (which reports global catalog figures identical for every tenant and saturates its LIMIT-bounded counts), the high/critical figures here count the tenant's OPEN findings whose CVE meets the EPSS threshold — the tenant's real exploitation-probability exposure.

func (*IntelService) GetHighRiskEPSS

func (s *IntelService) GetHighRiskEPSS(ctx context.Context, threshold float64, limit int) ([]*threatintel.EPSSScore, error)

GetHighRiskEPSS retrieves high-risk EPSS scores.

func (*IntelService) GetKEVEntry

func (s *IntelService) GetKEVEntry(ctx context.Context, cveID string) (*threatintel.KEVEntry, error)

GetKEVEntry retrieves a KEV entry by CVE ID.

func (*IntelService) GetKEVStats

func (s *IntelService) GetKEVStats(ctx context.Context) (*KEVStats, error)

GetKEVStats returns KEV statistics.

func (*IntelService) GetKEVStatsForTenant added in v0.6.0

func (s *IntelService) GetKEVStatsForTenant(ctx context.Context, tenantID shared.ID) (*KEVStats, error)

GetKEVStatsForTenant returns KEV statistics scoped to a single tenant's exposure. Unlike GetKEVStats (which reports global catalog figures identical for every tenant and saturates its LIMIT-bounded counts), the "past due" figure here counts the tenant's OPEN findings that reference an overdue KEV CVE, and the ransomware / recently-added figures are real de-saturated COUNTs of the global KEV feed (legitimately global context, but true totals).

func (*IntelService) GetSyncStatus

func (s *IntelService) GetSyncStatus(ctx context.Context, source string) (*threatintel.SyncStatus, error)

GetSyncStatus returns sync status for a specific source.

func (*IntelService) GetSyncStatuses

func (s *IntelService) GetSyncStatuses(ctx context.Context) ([]*threatintel.SyncStatus, error)

GetSyncStatuses returns all sync statuses.

func (*IntelService) GetThreatIntelStats

func (s *IntelService) GetThreatIntelStats(ctx context.Context, tenantID shared.ID) (*ThreatIntelStats, error)

GetThreatIntelStats returns unified threat intelligence statistics for a tenant. This combines tenant-scoped EPSS stats, tenant-scoped KEV stats, and (global) sync statuses in a single call. The KEV/EPSS figures reflect the tenant's exposure, not the global CISA/EPSS catalog.

func (*IntelService) IsInKEV

func (s *IntelService) IsInKEV(ctx context.Context, cveID string) (bool, error)

IsInKEV checks if a CVE is in the KEV catalog.

func (*IntelService) SetSyncEnabled

func (s *IntelService) SetSyncEnabled(ctx context.Context, source string, enabled bool) error

SetSyncEnabled enables or disables sync for a source.

func (*IntelService) SyncAll

func (s *IntelService) SyncAll(ctx context.Context) []IntelSyncResult

SyncAll syncs all enabled threat intel sources.

func (*IntelService) SyncEPSS

func (s *IntelService) SyncEPSS(ctx context.Context) IntelSyncResult

SyncEPSS syncs EPSS scores from FIRST.org.

func (*IntelService) SyncKEV

func (s *IntelService) SyncKEV(ctx context.Context) IntelSyncResult

SyncKEV syncs KEV catalog from CISA.

type IntelSyncResult

type IntelSyncResult struct {
	Source        string
	RecordsSynced int
	DurationMs    int64
	Error         error
}

IntelSyncResult contains the result of a sync operation.

type KEVEscalationResult added in v0.6.0

type KEVEscalationResult struct {
	// Escalated is the number of findings whose severity was raised to
	// critical because their CVE is in KEV.
	Escalated int
	// Flagged is the number of findings whose is_in_kev was reconciled
	// from false to true (independent of severity).
	Flagged int
	// Tenants is the distinct set of tenant IDs with at least one finding
	// touched by either the escalation or the is_in_kev reconciliation.
	Tenants []shared.ID
}

KEVEscalationResult reports what a KEV reconciliation pass changed.

Escalated and Flagged are independent: a non-critical finding whose CVE entered KEV is BOTH escalated (severity→critical) AND flagged (is_in_kev false→true); an already-critical KEV finding is only flagged. Tenants is the distinct set of tenants touched by either change — the caller enqueues one priority reclassify per tenant so is_in_kev/severity actually drive priority_class.

type KEVEscalator

type KEVEscalator interface {
	// EscalateKEVFindings raises severity to 'critical' for non-critical open
	// findings whose cve_id is in the kev_catalog, AND reconciles is_in_kev to
	// true for every non-terminal finding whose cve_id is in the catalog
	// (independent of severity). Returns what changed, including the distinct
	// tenants touched so the caller can trigger priority reclassification.
	EscalateKEVFindings(ctx context.Context) (KEVEscalationResult, error)
}

KEVEscalator auto-escalates findings whose CVEs appear in the CISA KEV catalog.

type KEVStats

type KEVStats struct {
	TotalEntries            int `json:"total_entries"`
	PastDueCount            int `json:"past_due_count"`
	RecentlyAddedLast30Days int `json:"recently_added_last_30_days"`
	RansomwareRelatedCount  int `json:"ransomware_related_count"`
}

KEVStats contains KEV catalog statistics.

type ThreatIntelStats

type ThreatIntelStats struct {
	EPSS         *EPSSStats            `json:"epss"`
	KEV          *KEVStats             `json:"kev"`
	SyncStatuses []*ThreatIntelSyncDTO `json:"sync_statuses"`
}

ThreatIntelStats contains unified threat intelligence statistics.

type ThreatIntelSyncDTO

type ThreatIntelSyncDTO struct {
	Source         string  `json:"source"`
	Enabled        bool    `json:"enabled"`
	LastSyncAt     *string `json:"last_sync_at,omitempty"`
	LastSyncStatus string  `json:"last_sync_status"`
	RecordsSynced  int     `json:"records_synced"`
	LastError      *string `json:"last_error,omitempty"`
	NextSyncAt     *string `json:"next_sync_at,omitempty"`
}

ThreatIntelSyncDTO is a data transfer object for sync status.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL