pluginmanager

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package pluginmanager handles the communication with the model and decision plugins

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ModelProcessHandler

func ModelProcessHandler(modelId string, modelProcess func(ModelInput) (ModelResults, error))

ModelProcessHandler listens for messages on the model queue

Types

type DecisionInput

type DecisionInput struct {
	TransactionId string
	Results       map[string]ModelResults
	ModelWeight   map[string]float64
	WAFdata       map[string]string
}

DecisionInput is the struct that contains the input data for the decision plugin

type ModelInput

type ModelInput struct {
	TransactionId string `json:"transactionId"`
	Payload       string `json:"payload"`
}

ModelInput is the struct that contains the input data for the model plugin

type ModelResults

type ModelResults struct {
	ProbAttack float64                `json:"probattack"`
	Data       map[string]interface{} `json:"data"`
}

ResultData maps the model plugin ID with the corresponding analysis result.

type ModelStatus

type ModelStatus struct {
	ModelID    string
	ProbAttack float64
	Err        error
}

ModelStatus stores whether there was an error while processing a request (response) by the modelID model plugin

type ModelTransmitionResults

type ModelTransmitionResults struct {
	TransactionId string `json:"transactionId"`
	ModelResults  `json:",inline"`
	Error         error `json:"error"`
}

ModelTransmitionResults is the struct that contains the results of the model plugin

type PluginManager

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

PluginManager is the main plugin struct storing information of every plugin execution.

func New

func New(meter metric.Meter) *PluginManager

New creates a new PluginManager instance.

func (*PluginManager) AddModelChannel

func (p *PluginManager) AddModelChannel(transactionId string, t cf.ModelPluginType, modelPlugStatus chan ModelStatus, modelType string)

AddModelChannel adds a channel to result channel map

func (*PluginManager) AddToQueue

func (p *PluginManager) AddToQueue(modelId, transactionId, payload string) error

AddToQueue adds a payload to the model queue

func (*PluginManager) CheckResult

func (p *PluginManager) CheckResult(transactionId, decisionId string, wafParams map[string]string) (bool, error)

CheckResult is in charge of calling the decision plugin with id decisionID over the transaction with id transactID

func (*PluginManager) CloseTransaction

func (p *PluginManager) CloseTransaction(transactionId string)

CloseTransaction closes the transaction with the given ID removing all sync model data

func (*PluginManager) InitTransaction

func (p *PluginManager) InitTransaction(transactionId string)

InitTransaction initializes the transaction with the given ID

func (*PluginManager) ModelResultsHandler

func (p *PluginManager) ModelResultsHandler(modelId string)

ModelResultsHandler listens for messages on the model results queue

func (*PluginManager) Process

func (p *PluginManager) Process(modelID, transactionId, payload string, t cf.ModelPluginType, modelPlugStatus chan ModelStatus)

Process is in charge of calling the model plugin with id modelID

func (*PluginManager) RemoveAsyncModelChannel

func (p *PluginManager) RemoveAsyncModelChannel(transactionId string, t cf.ModelPluginType)

RemoveModelChannel removes a channel from the result channel map

Jump to

Keyboard shortcuts

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