pkg

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeRepo

func InitializeRepo(logger *slog.Logger, idm identitymanager.IDManager) *policy.Repository

func LoadPolicies

func LoadPolicies(logger *slog.Logger, policyDirs, policyFiles []string) (api.Rules, error)

LoadPolicies loads Cilium Network Policies from the specified directories and files.

func OutputResults

func OutputResults(results []ScenarioResult, w io.Writer, isJSON bool) error

Types

type Direction

type Direction string
const (
	DirectionIngress Direction = "ingress"
	DirectionEgress  Direction = "egress"
)

type Scenario

type Scenario struct {
	Name            string         `json:"name"`
	From            []labels.Label `json:"from"`
	To              []labels.Label `json:"to"`
	DPort           *models.Port   `json:"dPort"`
	Direction       Direction      `json:"direction"`
	ExpectedVerdict Verdict        `json:"expectedVerdict"`
}

func LoadScenarios

func LoadScenarios(scenarioDirs, scenarioFiles []string) ([]Scenario, error)

func (Scenario) ToEndpointInfo added in v0.1.0

func (s Scenario) ToEndpointInfo(logger *slog.Logger, flow *policy.Flow) (src, dest *policy.EndpointInfo)

func (Scenario) ToFlow added in v0.1.0

func (s Scenario) ToFlow(allocator *cache.CachingIdentityAllocator) *policy.Flow

type ScenarioResult

type ScenarioResult struct {
	Name     string  `json:"name"`
	Expected Verdict `json:"expectedVerdict"`
	Actual   Verdict `json:"actualVerdict"`
}

func RunScenarios

func RunScenarios(logger *slog.Logger, repo *policy.Repository, idm identitymanager.IDManager, scenarios []Scenario, isVerbose bool) []ScenarioResult

type Verdict

type Verdict string
const (
	VerdictAllow     Verdict = "Allowed"
	VerdictDeny      Verdict = "Denied"
	VerdictUndecided Verdict = "Undecided"
)

func ParseDecision

func ParseDecision(d api.Decision) Verdict

func (Verdict) Decision

func (v Verdict) Decision() api.Decision

func (Verdict) String

func (v Verdict) String() string

Jump to

Keyboard shortcuts

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