Documentation
¶
Overview ¶
Package threatmodel implements the continuous threat-modeling generation engine: it resolves a scope's crown-jewel / critical targets, walks the exposure-chain graph per attacker profile, and enumerates the applicable ATT&CK techniques per hop with a live-derived status (open / mitigated / covered / accepted / theoretical). The applicability and status logic are pure and IO-free (this file + status.go); service.go orchestrates the IO.
See docs/rfcs/RFC-continuous-threat-modeling.md.
Index ¶
- type ApplicableTechnique
- type Coverage
- type CoverageTotals
- type ExposureChainProvider
- type Service
- func (s *Service) Coverage(ctx context.Context, tenantID, id shared.ID) (*tmdom.ThreatModel, Coverage, error)
- func (s *Service) GenerateForScope(ctx context.Context, tenantID shared.ID, scopeType tmdom.ScopeType, ...) (*tmdom.ThreatModel, error)
- func (s *Service) Get(ctx context.Context, tenantID, id shared.ID, filter tmdom.ThreatFilter) (*tmdom.ThreatModel, []*tmdom.ThreatModelThreat, error)
- func (s *Service) List(ctx context.Context, tenantID shared.ID, filter tmdom.ModelFilter, ...) ([]*tmdom.ThreatModel, int, error)
- type StatusCounts
- type TacticCoverage
- type TechniqueCoverage
- type TechniqueMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplicableTechnique ¶
type ApplicableTechnique struct {
TechniqueID string
// EdgeType is the applicability row's edge constraint ("" = any incoming edge).
EdgeType string
// Weight in (0,1] scales the chain score for this technique: easy,
// no-credential techniques weigh full; privilege/persistence-gated ones less.
Weight float64
}
ApplicableTechnique is one technique that applies at a hop for an attacker, carrying the catalog row it matched and the risk weight for scoring.
type Coverage ¶
type Coverage struct {
Tactics []TacticCoverage
Totals CoverageTotals
}
Coverage is the aggregated tactic × technique coverage matrix for a model. The envelope facts (model id, dataset version, generated_at) are added by the handler from the model; buildCoverage returns only the matrix + totals.
type CoverageTotals ¶
type CoverageTotals struct {
Techniques int
Open int
Mitigated int
Covered int
Accepted int
Theoretical int
CoveragePct float64
}
CoverageTotals is the model-wide rollup over the technique cells (not the raw threats): how many distinct technique cells exist and how they distribute over the worst-case statuses, plus a coverage percentage.
type ExposureChainProvider ¶
type ExposureChainProvider interface {
GetExposureChains(ctx context.Context, tenantID shared.ID) (*attack.ExposureChainResult, error)
}
ExposureChainProvider yields the tenant's exposure chains (public entry point → KEV/critical target). Implemented by *attack.SurfaceService.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service generates and reads threat models. It composes the exposure-chain engine (reachability substrate), the attacker profiles (capability gates), the ATT&CK applicability/mitigation catalog, and live findings (status) into a regenerated-each-cycle projection.
func NewService ¶
func NewService( repo tmdom.Repository, chains ExposureChainProvider, assets asset.Repository, rels asset.RelationshipRepository, profiles tmdom.AttackerProfileReader, findings tmdom.FindingReader, log *logger.Logger, ) *Service
NewService wires the generation service.
func (*Service) Coverage ¶
func (s *Service) Coverage(ctx context.Context, tenantID, id shared.ID) (*tmdom.ThreatModel, Coverage, error)
Coverage returns the model and its aggregated tactic × technique coverage matrix (worst-case status rollup per technique, per-status counts, totals). It reuses ListThreats (all threats for the model) and enriches technique names + mitigation lists from the ATT&CK catalog. Tenant-scoped via GetByID/ListThreats.
func (*Service) GenerateForScope ¶
func (s *Service) GenerateForScope(ctx context.Context, tenantID shared.ID, scopeType tmdom.ScopeType, scopeRefID *shared.ID) (*tmdom.ThreatModel, error)
GenerateForScope (re)generates the threat model for a scope and returns the persisted model. It is idempotent: when the graph/findings/profile inputs are unchanged since the last generation (equal input_hash) it returns the existing model without rewriting the threats.
func (*Service) Get ¶
func (s *Service) Get(ctx context.Context, tenantID, id shared.ID, filter tmdom.ThreatFilter) (*tmdom.ThreatModel, []*tmdom.ThreatModelThreat, error)
Get returns a model and its (optionally filtered) threats, tenant-scoped.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, tenantID shared.ID, filter tmdom.ModelFilter, page pagination.Pagination) ([]*tmdom.ThreatModel, int, error)
List returns threat models for the tenant, filtered and paginated.
type StatusCounts ¶
StatusCounts is the per-status breakdown of the threats behind one technique cell. The sum equals TechniqueCoverage.ThreatCount.
type TacticCoverage ¶
type TacticCoverage struct {
Tactic string
Techniques []TechniqueCoverage
}
TacticCoverage groups the technique cells that share a tactic (by tactic name as stored on the threats).
type TechniqueCoverage ¶
type TechniqueCoverage struct {
TechniqueID string
TechniqueName string
Status string
Counts StatusCounts
MaxScore float64
MitigationIDs []string
ThreatCount int
}
TechniqueCoverage is one technique cell in the tactic × technique matrix. It carries the worst-case status rollup plus the per-status detail so a heatmap can color by Status and a tooltip can show the breakdown, and so an ATT&CK Navigator layer can be produced client-side from TechniqueID + Status/MaxScore.
type TechniqueMeta ¶
TechniqueMeta is the catalog enrichment for one ATT&CK technique: its display name and the full set of mitigations the catalog maps to it. It is looked up by technique id when building the coverage matrix. Both fields are optional — when the catalog is unavailable buildCoverage degrades to the facts carried on the threats themselves (empty name, mitigation ids taken from the threats).