audit

package
v2.16.20 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0, Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package audit contains types and functions to summarize the features used in a configuration and to emit recommendations and comments when executing a check

Index

Constants

View Source
const (
	SeverityCritical = "CRITICAL"
	SeverityHigh     = "HIGH"
	SeverityMedium   = "MEDIUM"
	SeverityLow      = "LOW"
)
View Source
const (
	BitEndpointWildcard             int = 0
	BitEndpointQueryStringWildcard  int = 1
	BitEndpointHeaderStringWildcard int = 2
	BitEndpointCatchAll             int = 3
)
View Source
const (
	ServicePlugin = iota
	ServiceSequentialStart
	ServiceDebug
	ServiceAllowInsecureConnections
	ServiceDisableStrictREST
	ServiceHasTLS
	ServiceTLSEnabled
	ServiceTLSEnableMTLS
	ServiceTLSDisableSystemCaPool
	ServiceTLSCaCerts
	ServiceEcho
	ServiceUseH2C
	ServiceTLSPrivPubKey
)
View Source
const (
	EncodingNOOP = iota
	EncodingJSON
	EncodingSAFEJSON
	EncodingSTRING
	EncodingRSS
	EncodingXML
	EncodingOther
)
View Source
const (
	BackendAllow = iota + EncodingOther + 1
	BackendDeny
	BackendMapping
	BackendGroup
	BackendTarget
	BackendIsCollection
	BackendHeadersToPass
	BackendQuery
)
View Source
const (
	RouterErrorBody = iota
	RouterDisableHealth
	RouterDisableAccessLog
	RouterHealthPath
	RouterErrorMsg
	RouterDisableRedirectTrailingSlash
	RouterDisableRedirectFixedPath
	RouterExtraSlash
	RouterHandleMethodNotAllowed
	RouterPathDecoding
	RouterAutoOptions
	RouterForwardedByClientIp
	RouterRemoteIpHeaders
	RouterTrustedProxies
	RouterAppEngine
	RouterMaxMultipartMemory
	RouterLoggerSkipPaths
	RouterHideVersionHeader
	RouterUseH2C
)
View Source
const (
	BackendComponentHTTPClient = iota
	BackendComponentHTTPClientAllowInsecureConnections
	BackendComponentHTTPClientCerts
)

Variables

View Source
var AiProviders = [][]string{{"gemini", "v1beta"}, {"openai", "v1"}, {"mistral", "v1"}, {"anthropic", "v1"}}

Functions

func Marshal

func Marshal(s *Service) ([]byte, error)

Marshal returns the encoded and compressed representation of the Service

func Unmarshal

func Unmarshal(b []byte, s *Service) error

Unmarshal decompresses and decodes the received bits into a Service

Types

type Agent

type Agent struct {
	Details    []int     `json:"d"`
	Backends   []Backend `json:"b"`
	Components Component `json:"c"`
}

Agent captures details of the AsyncAgents present at the configuration

func (Agent) Clone

func (a Agent) Clone() Agent

Clone returns a deep copy of the agent

type AuditResult

type AuditResult struct {
	Recommendations []Recommendation `json:"recommendations"`
	Stats           Stats            `json:"stats"`
}

AuditResult contains all the recommendations and stats generated by the audit process

func Audit

func Audit(cfg *config.ServiceConfig, ignore, severities []string) (AuditResult, error)

Audit audits the received configuration and generates an AuditResult with all the Recommendations

type Backend

type Backend struct {
	Details    []int     `json:"d"`
	Components Component `json:"c"`
}

Backend captures details of the backends present at the configuration

func (Backend) Clone

func (b Backend) Clone() Backend

Clone returns a deep copy of the backend

type Component

type Component map[string][]int

Component captures details of the extra configuration sections

func (Component) Clone

func (c Component) Clone() Component

Clone returns a deep copy of the set of components

type Endpoint

type Endpoint struct {
	Details    []int     `json:"d"`
	Backends   []Backend `json:"b"`
	Components Component `json:"c"`
}

Endpoint captures details of the endpoints present at the configuration

func (Endpoint) Clone

func (e Endpoint) Clone() Endpoint

Clone returns a deep copy of the endpoint

type Recommendation

type Recommendation struct {
	Rule     string `json:"rule"`
	Severity string `json:"severity"`
	Message  string `json:"message"`
}

Recommendation maps a rule id with a severity and a message

type Rule

type Rule struct {
	Recommendation Recommendation
	Evaluate       func(*Service) bool
}

Rule encapsulates a recommendation and an evaluation function that determines if the recommendation applies for a given service definition

func NewRule

func NewRule(id, severity, msg string, ef func(*Service) bool) Rule

NewRule creates a Rule with the given arguments

type Service

type Service struct {
	Details    []int      `json:"d"`
	Agents     []Agent    `json:"a"`
	Endpoints  []Endpoint `json:"e"`
	Components Component  `json:"c"`
}

Service represents a KrakenD configuration as a tree of bitsets representing which components and flags are enabled at the KrakenD configuration

func Parse

func Parse(cfg *config.ServiceConfig) Service

Parse creates a Service capturing the details of the received configuration

func (Service) Clone

func (s Service) Clone() Service

Clone returns a deep copy of the service

type Stats

type Stats struct{}

Stats is an empty struct that will be completed in the future

Jump to

Keyboard shortcuts

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