audit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrometheusHistogram is label name of PrometheusCounterBackend
	PrometheusHistogram = "prometheus-histogram"
	// LocalLogLabel is label name of LocalLogBackend
	LocalLogLabel = "local-log"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// ProcessHTTPRequest is used to perform HTTP audit process
	ProcessHTTPRequest(req *http.Request) bool
	// Match is used to determine if the backend matches
	Match(*BackendLabels) bool
	ProcessBeforeHandler() bool
}

Backend defines what function audit backend should hold

func NewLocalLogBackend

func NewLocalLogBackend(before bool) Backend

NewLocalLogBackend returns a LocalLogBackend

func NewPrometheusHistogramBackend

func NewPrometheusHistogramBackend(histogramVec *prometheus.HistogramVec, before bool) Backend

NewPrometheusHistogramBackend returns a PrometheusHistogramBackend

type BackendLabels

type BackendLabels struct {
	Labels []string
}

BackendLabels is used to store some audit backend labels.

type LabelMatcher

type LabelMatcher struct {
	// contains filtered or unexported fields
}

LabelMatcher is used to help backend implement audit.Backend

func (*LabelMatcher) Match

func (m *LabelMatcher) Match(labels *BackendLabels) bool

Match is used to check whether backendLabel is in the labels

type LocalLogBackend

type LocalLogBackend struct {
	*LabelMatcher
	*Sequence
}

LocalLogBackend is an implementation of audit.Backend and it uses `github.com/pingcap/log` to implement audit

func (*LocalLogBackend) ProcessHTTPRequest

func (l *LocalLogBackend) ProcessHTTPRequest(r *http.Request) bool

ProcessHTTPRequest is used to implement audit.Backend

type PrometheusHistogramBackend

type PrometheusHistogramBackend struct {
	*LabelMatcher
	*Sequence
	// contains filtered or unexported fields
}

PrometheusHistogramBackend is an implementation of audit.Backend and it uses Prometheus histogram data type to implement audit. Note: histogram.WithLabelValues will degrade performance. Please don't use it in the hot path.

func (*PrometheusHistogramBackend) ProcessHTTPRequest

func (b *PrometheusHistogramBackend) ProcessHTTPRequest(req *http.Request) bool

ProcessHTTPRequest is used to implement audit.Backend

type Sequence

type Sequence struct {
	// contains filtered or unexported fields
}

Sequence is used to help backend implement audit.Backend

func (*Sequence) ProcessBeforeHandler

func (s *Sequence) ProcessBeforeHandler() bool

ProcessBeforeHandler is used to identify whether this backend should execute before handler

Jump to

Keyboard shortcuts

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