apiserver

package
v1.5.35 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PapiPullKey = "papi:last_pull"
)

Variables

View Source
var SCOPE_CAPI_ALIAS_ALIAS string = "crowdsecurity/community-blocklist" //we don't use "CAPI" directly, to make it less confusing for the user
View Source
var (
	SyncInterval = time.Second * 10
)

Functions

func AlertCmd

func AlertCmd(message *Message, p *Papi, sync bool) error

func CustomRecoveryWithWriter

func CustomRecoveryWithWriter() gin.HandlerFunc

RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.

func DecisionCmd

func DecisionCmd(message *Message, p *Papi, sync bool) error

func ManagementCmd

func ManagementCmd(message *Message, p *Papi, sync bool) error

func NewAPIC

func NewAPIC(config *csconfig.OnlineApiClientCfg, dbClient *database.Client, consoleConfig *csconfig.ConsoleConfig, apicWhitelist *csconfig.CapiWhitelist) (*apic, error)

Types

type APIServer

type APIServer struct {
	URL string
	TLS *csconfig.TLSCfg
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config *csconfig.LocalApiServerCfg) (*APIServer, error)

func (*APIServer) AttachPluginBroker

func (s *APIServer) AttachPluginBroker(broker *csplugin.PluginBroker)

func (*APIServer) Close

func (s *APIServer) Close()

func (*APIServer) GetTLSConfig

func (s *APIServer) GetTLSConfig() (*tls.Config, error)

func (*APIServer) InitController

func (s *APIServer) InitController() error

func (*APIServer) Router

func (s *APIServer) Router() (*gin.Engine, error)

func (*APIServer) Run

func (s *APIServer) Run(apiReady chan bool) error

func (*APIServer) Shutdown

func (s *APIServer) Shutdown() error
type Header struct {
	OperationType string    `json:"operation_type"`
	OperationCmd  string    `json:"operation_cmd"`
	Timestamp     time.Time `json:"timestamp"`
	Message       string    `json:"message"`
	UUID          string    `json:"uuid"`
	Source        *Source   `json:"source"`
	Destination   string    `json:"destination"`
}

type Message

type Message struct {
	Header *Header
	Data   interface{} `json:"data"`
}

type OperationChannels

type OperationChannels struct {
	AddAlertChannel       chan []*models.Alert
	DeleteDecisionChannel chan []*models.Decision
}

type Papi

type Papi struct {
	URL      string
	Client   *longpollclient.LongPollClient
	DBClient *database.Client

	Channels *OperationChannels

	SyncInterval time.Duration

	Logger *log.Entry
	// contains filtered or unexported fields
}

func NewPAPI

func NewPAPI(apic *apic, dbClient *database.Client, consoleConfig *csconfig.ConsoleConfig, logLevel log.Level) (*Papi, error)

func (*Papi) GetPermissions

func (p *Papi) GetPermissions() (PapiPermCheckSuccess, error)

func (*Papi) Pull

func (p *Papi) Pull() error

PullPAPI is the long polling client for real-time decisions from PAPI

func (*Papi) PullOnce

func (p *Papi) PullOnce(since time.Time, sync bool) error

func (*Papi) SendDeletedDecisions

func (p *Papi) SendDeletedDecisions(cacheOrig *models.DecisionsDeleteRequest)

func (*Papi) Shutdown

func (p *Papi) Shutdown()

func (*Papi) SyncDecisions

func (p *Papi) SyncDecisions() error

type PapiPermCheckError

type PapiPermCheckError struct {
	Error string `json:"error"`
}

type PapiPermCheckSuccess

type PapiPermCheckSuccess struct {
	Status     string   `json:"status"`
	Plan       string   `json:"plan"`
	Categories []string `json:"categories"`
}

type Source

type Source struct {
	User string `json:"user"`
}

Directories

Path Synopsis
v1
middlewares
v1

Jump to

Keyboard shortcuts

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