risk

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 3 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 risk: probabilistic attack-path likelihood (PRD section 68, "probabilistic attack paths").

Reachability says a path *can* be walked. Likelihood estimates how *plausibly* an attacker walks it. Each edge gets an exploitation probability derived from its security cost; the path's likelihood is the product of its edges' probabilities.

Package risk implements explainable attack-path risk scoring (PRD sections 13 and 14).

Index

Constants

View Source
const (
	LikelihoodVeryLikely  = "VERY_LIKELY"
	LikelihoodLikely      = "LIKELY"
	LikelihoodPossible    = "POSSIBLE"
	LikelihoodUnlikely    = "UNLIKELY"
	LikelihoodImplausible = "IMPLAUSIBLE"
)

Likelihood thresholds for reporting bands.

View Source
const (
	SeverityInformational = "INFORMATIONAL"
	SeverityLow           = "LOW"
	SeverityMedium        = "MEDIUM"
	SeverityHigh          = "HIGH"
	SeverityCritical      = "CRITICAL"
)

Severity bands (PRD section 13).

Variables

This section is empty.

Functions

func EdgeLikelihood added in v0.6.0

func EdgeLikelihood(e *graph.Edge) float64

EdgeLikelihood estimates the probability that an attacker can traverse a single edge, given they reached its source.

Inputs:

  • e.EffectiveRisk(): how privileged/dangerous the relationship is (higher risk = easier or more valuable traversal)
  • e.Confidence: how certain we are the relationship exists at all
  • metadata override: an explicit likelihood from configuration

The base probability treats effective risk as ease of abuse (risk 100 -> 0.90, risk 0 -> 0.10) and multiplies by confidence so speculative relationships attenuate likelihood. Configured overrides win outright.

func ExpectedThreat added in v0.6.0

func ExpectedThreat(score int, likelihood float64) int

ExpectedThreat combines likelihood with the deterministic risk score: the product estimates how much of the path's damage is realistically expected. Used to order paths that share a target.

func LikelihoodFor added in v0.6.0

func LikelihoodFor(p float64) string

LikelihoodFor maps a probability to its reporting band.

func LikelihoodRank added in v0.6.0

func LikelihoodRank(band string) int

LikelihoodRank returns an ordinal for comparing bands.

func PathLikelihood added in v0.6.0

func PathLikelihood(edges []*graph.Edge) float64

PathLikelihood returns the probability that an attacker traverses the full path in one attempt, assuming independence between edges. Long paths attenuate quickly, which is the point: an 8-hop chain of 0.5-probability hops is ~0.4% likely even when every hop alone is feasible.

func SeverityFor

func SeverityFor(score int) string

SeverityFor maps a 0-100 score to its severity band.

func SeverityRank

func SeverityRank(s string) int

SeverityRank returns an ordinal for comparing severities.

func SortFactors

func SortFactors(fs []Factor)

SortFactors orders a factor breakdown from largest positive contribution to largest penalty, for readable explanations.

Types

type Factor

type Factor struct {
	Name   string `json:"name"`
	Delta  int    `json:"delta"`
	Reason string `json:"reason"`
}

Factor is one explainable contribution to a risk score.

type Result

type Result struct {
	Score      int      `json:"score"`
	Severity   string   `json:"severity"`
	Factors    []Factor `json:"factors"`
	Confidence float64  `json:"confidence"`
}

Result is the outcome of scoring a single path.

func ScorePath

func ScorePath(nodes []*graph.Node, edges []*graph.Edge, confidence float64) Result

ScorePath scores one attack path given its node and edge sequences. The returned result includes a full factor breakdown so that every score remains explainable (PRD section 13).

Jump to

Keyboard shortcuts

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