policy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 5 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 policy implements the rules engine: YAML-defined conditions evaluated against the graph, with embedded default rules (PRD section 45).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchesSelector

func MatchesSelector(n *graph.Node, sel *Selector) bool

MatchesSelector reports whether a target node matches the selector.

Types

type Rule

type Rule struct {
	ID       string `yaml:"id" json:"id"`
	Name     string `yaml:"name" json:"name"`
	Severity string `yaml:"severity" json:"severity"`
	// When selects source agents: a node-type filter plus optional
	// provider and metadata match.
	When RuleWhen `yaml:"when" json:"when"`
	// DenyReach forbids the selected agents from reaching nodes matching
	// the target selector.
	DenyReach *Selector `yaml:"deny_reach" json:"deny_reach,omitempty"`
}

Rule is a policy definition.

type RuleWhen

type RuleWhen struct {
	NodeType    string            `yaml:"node_type" json:"node_type"`
	Provider    string            `yaml:"provider,omitempty" json:"provider,omitempty"`
	HasMetadata map[string]string `yaml:"has_metadata,omitempty" json:"has_metadata,omitempty"`
}

RuleWhen selects the agents a rule applies to.

type Selector

type Selector struct {
	NodeType    string            `yaml:"node_type" json:"node_type"`
	Provider    string            `yaml:"provider,omitempty" json:"provider,omitempty"`
	HasMetadata map[string]string `yaml:"has_metadata,omitempty" json:"has_metadata,omitempty"`
	HasAnyTag   []string          `yaml:"has_any_tag,omitempty" json:"has_any_tag,omitempty"`
	Environment string            `yaml:"environment,omitempty" json:"environment,omitempty"`
	Privilege   string            `yaml:"privilege,omitempty" json:"privilege,omitempty"`
	CrownJewel  *bool             `yaml:"crown_jewel,omitempty" json:"crown_jewel,omitempty"`
}

Selector matches target nodes.

type Set

type Set struct {
	Rules []Rule `yaml:"rules"`
}

Set is a collection of rules.

func DefaultRules

func DefaultRules() *Set

DefaultRules implements the built-in policy set.

func Parse

func Parse(data []byte) (*Set, error)

Parse decodes a YAML rule set.

type Violation

type Violation struct {
	RuleID        string   `json:"rule_id"`
	RuleName      string   `json:"rule_name"`
	Severity      string   `json:"severity"`
	Agent         string   `json:"agent"`
	Target        string   `json:"target"`
	TargetType    string   `json:"target_type"`
	Path          []string `json:"path"`
	PathEdgeTypes []string `json:"path_edge_types"`
}

Violation is one rule breach.

func Evaluate

func Evaluate(g *graph.Graph, s *Set, opts paths.Options) ([]*Violation, error)

Evaluate checks every rule against the graph and returns violations. Internet-exposed agents are checked first so the most serious exposure surfaces at the top.

Jump to

Keyboard shortcuts

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