threatmodel

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: GPL-3.0 Imports: 13 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 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

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

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

type StatusCounts struct {
	Open        int
	Mitigated   int
	Covered     int
	Accepted    int
	Theoretical int
}

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

type TechniqueMeta struct {
	Name          string
	MitigationIDs []string
}

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).

Jump to

Keyboard shortcuts

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