rules

package
v0.0.0-...-76384c5 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package rules implements policy ruleset models and matching algorithms for API requests.

Package rules implements policy ruleset models and matching algorithms for API requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IdentifyCommandType

func IdentifyCommandType(method, uri string) string

IdentifyCommandType classifies incoming Docker API requests into standard operation categories.

Types

type Action

type Action string

Action defines the decision outcome for a policy evaluation.

const (
	// ActionAllow permits the request to be forwarded upstream.
	ActionAllow Action = "allow"
	// ActionDeny blocks the request and returns HTTP 403 Forbidden.
	ActionDeny Action = "deny"
	// ActionFilter indicates response list items should be sanitized.
	ActionFilter Action = "filter"
)

func Evaluate

func Evaluate(method, uri string, bodySnippet []byte, rs *Ruleset) (Action, string, string)

Evaluate inspects the HTTP request method, URI path, command category, and deserialized payload against the ruleset. Returns the resulting Action, custom denial Message (if any), and the matched Rule ID (or "default").

type ContainerCreateRequest

type ContainerCreateRequest = container.CreateRequest

ContainerCreateRequest aliases canonical container.CreateRequest from official Moby API types.

type ContainerCreateRule

type ContainerCreateRule struct {
	Privileged    *bool    `yaml:"privileged"`
	AllowedMounts []string `yaml:"allowed_mounts"`
	AllowedPorts  []string `yaml:"allowed_ports"`
	AllowedImages []string `yaml:"allowed_images"`
	AllowedNames  []string `yaml:"allowed_names"`
}

ContainerCreateRule defines semantic constraints evaluated against container creation requests.

type ContainerSummary

type ContainerSummary = container.Summary

ContainerSummary aliases canonical container.Summary from official Moby API types.

type ExecCreateRequest

type ExecCreateRequest = container.ExecCreateRequest

ExecCreateRequest aliases canonical container.ExecCreateRequest from official Moby API types.

type ExecCreateRule

type ExecCreateRule struct {
	AllowedCommands   []string `yaml:"allowed_commands"`
	AllowedContainers []string `yaml:"allowed_containers"`
}

ExecCreateRule defines semantic constraints evaluated against exec creation requests.

type HostConfig

type HostConfig = container.HostConfig

HostConfig aliases canonical container.HostConfig from official Moby API types.

type ImageSummary

type ImageSummary = image.Summary

ImageSummary aliases canonical image.Summary from official Moby API types.

type PolicyRule

type PolicyRule = SemanticRule

PolicyRule alias for backwards compatibility during migration.

type ResponseFilterRule

type ResponseFilterRule struct {
	AllowedNames  []string          `yaml:"allowed_names"`
	AllowedLabels map[string]string `yaml:"allowed_labels"`
}

ResponseFilterRule defines allowlist criteria applied to filter container or image list responses.

type Ruleset

type Ruleset struct {
	Version       string         `yaml:"version"`
	DefaultAction Action         `yaml:"default_action"`
	Rules         []SemanticRule `yaml:"rules"`
}

Ruleset defines the top-level security policy evaluated against incoming requests.

type SemanticRule

type SemanticRule struct {
	ID              string               `yaml:"id"`
	Action          Action               `yaml:"action"`
	Message         string               `yaml:"message"`
	Methods         []string             `yaml:"methods"`
	PathPattern     string               `yaml:"path_pattern"`
	BodyPattern     string               `yaml:"body_pattern"`
	CommandTypes    []string             `yaml:"command_types"`
	ContainerCreate *ContainerCreateRule `yaml:"container_create"`
	ExecCreate      *ExecCreateRule      `yaml:"exec_create"`
	ResponseFilter  *ResponseFilterRule  `yaml:"response_filter"`
}

SemanticRule defines an individual access control or filtering directive within a ruleset.

Jump to

Keyboard shortcuts

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