outputer

package
v0.0.0-...-e9de818 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HubPluginMsgTypeAlarm    string = "alert"
	HubPluginMsgTypeReminder string = "reminder"
)
View Source
const (
	DataModelHidsAlarm           string = "hids alarm"
	DataModelRaspAlarm           string = "rasp alarm"
	DataModelKubeAlarm           string = "kube alarm"
	DataModelVirusAlarm          string = "virus alarm"
	DataModelAuthorizationExpire string = "authorization expire"

	DataSubModelHidsAlarm  string = "hids"
	DataSubModelRaspAlarm  string = "rasp"
	DataSubModelKubeAlarm  string = "kube"
	DataSubModelVirusAlarm string = "virus"

	DataTypeInsert string = "insert"

	ConfigTypeKafka    string = "kafka"
	ConfigTypeFeishu   string = "feishu"
	ConfigTypeDingding string = "dingding"
	ConfigTypeEmail    string = "email"
	ConfigTypeSyslog   string = "syslog"
	ConfigTypeEs       string = "elasticsearch"
	ConfigTypeEWechat  string = "enterprise wechat"
	ConfigTypeCustom   string = "custom"
)
View Source
const (
	ConfigOutputerOpen     int = 1
	ConfigOutputerQueueMax int = 100
)
View Source
const (
	SYSLOG_ALARM_LEVEL_CRITICAL string = "critical"
	SYSLOG_ALARM_LEVEL_HIGH     string = "high"
	SYSLOG_ALARM_LEVEL_MEDIUM   string = "medium"
	SYSLOG_ALARM_LEVEL_LOW      string = "low"
)

Variables

This section is empty.

Functions

func ApplyHubPlugin

func ApplyHubPlugin(req TestPluginReq) (interface{}, error)

func InitOutput

func InitOutput()

func InitSyslogConnect

func InitSyslogConnect(conf *NoticeMsgConfigSyslog) (*syslog.Writer, error)

func RequestHubPluginByHub

func RequestHubPluginByHub(req *HubPluginPushMsgRequest) error

Types

type Config

type Config struct {
	ID    string   `json:"id" bson:"id"`
	Type  string   `json:"type" bson:"type"`
	Model []string `json:"model" bson:"model"`

	Address []string `json:"address" bson:"address"`
	Topic   string   `json:"topic" bson:"topic"`
	SASL    struct {
		Enable   bool   `json:"enable" bson:"enable"`
		UserName string `json:"username" bson:"username"`
		PassWord string `json:"password" bson:"password"`
	} `json:"sasl" bson:"sasl"`

	InsertTime int64 `json:"insert_time" bson:"insert_time"`
	UpdateTime int64 `json:"update_time" bson:"update_time"`
}

db config

type DataHitModelInfo

type DataHitModelInfo struct {
	Model    string `json:"model" bson:"model"`
	SubModel string `json:"sub_model" bson:"sub_model"`
	Type     string `json:"type" bson:"type"`
	Level    string `json:"level" bson:"level"`
}

data

type DataModel

type DataModel struct {
	HitModel DataHitModelInfo `json:"hit_model" bson:"hit_model"`
	Filter   interface{}      `json:"filter" bson:"filter"`
	Data     interface{}      `json:"data" bson:"data"`
}

func BuildDataModel

func BuildDataModel(model, subModel, dType, alarmLevel string, filter, data interface{}) *DataModel

type EsWorker

type EsWorker struct {
	Queue chan *DataModel
	// contains filtered or unexported fields
}

func (*EsWorker) Close

func (b *EsWorker) Close()

func (*EsWorker) ESRefreshIndex

func (b *EsWorker) ESRefreshIndex()

Hour / Day

func (*EsWorker) HitModel

func (b *EsWorker) HitModel(model DataHitModelInfo) bool

func (*EsWorker) Init

func (b *EsWorker) Init(conf *OutputerConfig) error

func (*EsWorker) SendMsg

func (b *EsWorker) SendMsg(dm *DataModel)

func (*EsWorker) WaitForInputMsg

func (b *EsWorker) WaitForInputMsg()

type Handler

type Handler struct {
	// contains filtered or unexported fields
}
var OuterHandler *Handler

func (*Handler) Add

func (o *Handler) Add(dm *DataModel)

func (*Handler) Init

func (o *Handler) Init() error

使用update_time来识别是否需要更新

func (*Handler) IsEnable

func (o *Handler) IsEnable() bool

func (*Handler) UpdateConfig

func (o *Handler) UpdateConfig(conf *OutputerConfig) error

type HubPluginPushMsgRequest

type HubPluginPushMsgRequest struct {
	PluginType string            `json:"plugin_type"`
	PluginName string            `json:"plugin_name"`
	Type       string            `json:"type"`
	Config     map[string]string `json:"config"`
	Data       interface{}       `json:"data"`
}

type HubPluginPushMsgResponse

type HubPluginPushMsgResponse struct {
	Success  bool        `json:"success"`
	Data     interface{} `json:"data"`
	ErrorMsg string      `json:"errormsg"`
}

type HubPluginPushMsgResponseSucessData

type HubPluginPushMsgResponseSucessData struct {
	Done bool `json:"done"`
}

type HubPluginWorker

type HubPluginWorker struct {
	Queue chan *DataModel
	// contains filtered or unexported fields
}

worker

func (*HubPluginWorker) Close

func (b *HubPluginWorker) Close()

func (*HubPluginWorker) HitModel

func (b *HubPluginWorker) HitModel(model DataHitModelInfo) bool

func (*HubPluginWorker) Init

func (b *HubPluginWorker) Init(conf *OutputerConfig) error

func (*HubPluginWorker) ReadConfig

func (b *HubPluginWorker) ReadConfig(config NoticeMsgConfig, pluginMsgType string) error

func (*HubPluginWorker) SendMsg

func (b *HubPluginWorker) SendMsg(dm *DataModel)

func (*HubPluginWorker) WaitForInputMsg

func (b *HubPluginWorker) WaitForInputMsg()

type HubResponse

type HubResponse struct {
	Success  bool        `json:"success"`
	Data     interface{} `json:"data"`
	ErrorMsg string      `json:"errormsg"`
}

type HubTestPluginReq

type HubTestPluginReq struct {
	PluginType string            `json:"plugin_type"`
	PluginName string            `json:"plugin_name"`
	Config     map[string]string `json:"config"`
	Data       interface{}       `json:"data"`
	Sha256Sum  string            `json:"sha256sum"`
	ZipBytes   []byte            `json:"zipBytes"`
}

type KafkaWorker

type KafkaWorker struct {
	Queue chan *DataModel
	// contains filtered or unexported fields
}

func (*KafkaWorker) Close

func (b *KafkaWorker) Close()

func (*KafkaWorker) HitModel

func (b *KafkaWorker) HitModel(model DataHitModelInfo) bool

func (*KafkaWorker) Init

func (b *KafkaWorker) Init(conf *OutputerConfig) error

func (*KafkaWorker) SendMsg

func (b *KafkaWorker) SendMsg(dm *DataModel)

func (*KafkaWorker) WaitForInputMsg

func (b *KafkaWorker) WaitForInputMsg()

type LeaderAuthRequest

type LeaderAuthRequest struct {
	Username string `json:"username" bson:"username" binding:"required"`
	Password string `json:"password" bson:"password" binding:"required"`
}

type NoticeConfigDbDataContent

type NoticeConfigDbDataContent struct {
	NoticeRunConfig `json:",inline" bson:",inline"`
	MsgConfig       NoticeMsgConfig `json:"notice_config" bson:"notice_config"`
}

type NoticeConfigDbDataFormat

type NoticeConfigDbDataFormat struct {
	ID                        string `json:"_id" bson:"_id"`
	NoticeConfigDbDataContent `json:",inline" bson:",inline"`
}

type NoticeMsgConfig

type NoticeMsgConfig struct {
	FeishuConfig   *NoticeMsgConfigFeishu           `json:"feishu_config,omitempty" bson:"feishu_config,omitempty"`
	DingdingConfig *NoticeMsgConfigDingding         `json:"dingding_config,omitempty" bson:"dingding_config,omitempty"`
	EWechat        *NoticeMsgConfigEnterpriseWechat `json:"enterprise_wechat,omitempty" bson:"enterprise_wechat,omitempty"`
	Syslog         *NoticeMsgConfigSyslog           `json:"syslog,omitempty" bson:"syslog,omitempty"`
	Email          *NoticeMsgConfigEmail            `json:"email,omitempty" bson:"email,omitempty"`
	Kafka          *NoticeMsgConfigKafka            `json:"kafka,omitempty" bson:"kafka,omitempty"`
	ES             *NoticeMsgConfigEs               `json:"elasticsearch,omitempty" bson:"elasticsearch,omitempty"`
	Custom         *NoticeMsgConfigCustom           `json:"custom,omitempty" bson:"custom,omitempty"`
}

type NoticeMsgConfigCustom

type NoticeMsgConfigCustom struct {
	PluginName   string            `json:"plugin_name" bson:"plugin_name"`
	CustomConfig map[string]string `json:"custom_config" bson:"custom_config"`
	Remarks      string            `json:"remarks,omitempty" bson:"remarks,omitempty"`
}

type NoticeMsgConfigDingding

type NoticeMsgConfigDingding struct {
	WebHookUrl string `json:"web_hook_url" bson:"web_hook_url"`
	Seceret    string `json:"seceret,omitempty" bson:"seceret,omitempty"`
	Remarks    string `json:"remarks,omitempty" bson:"remarks,omitempty"`
}

type NoticeMsgConfigEmail

type NoticeMsgConfigEmail struct {
	Server   string   `json:"server" bson:"server"`
	UserName string   `json:"user_name" bson:"user_name"`
	Password string   `json:"password" bson:"password"`
	ToEmail  []string `json:"to_email" bson:"to_email"`
	Remarks  string   `json:"remarks,omitempty" bson:"remarks,omitempty"`
}

type NoticeMsgConfigEnterpriseWechat

type NoticeMsgConfigEnterpriseWechat struct {
	WebHookUrl string `json:"web_hook_url" bson:"web_hook_url"`
	Remarks    string `json:"remarks,omitempty" bson:"remarks,omitempty"`
}

type NoticeMsgConfigEs

type NoticeMsgConfigEs struct {
	ESHost             []string `json:"es_host" bson:"es_host"`
	ESIndex            string   `json:"es_index" bson:"es_index"`
	ESAuthUser         string   `json:"es_auth_user" bson:"es_auth_user"`
	ESAuthPasswd       string   `json:"es_auth_passwd" bson:"es_auth_passwd"`
	ESIndexRefreshType string   `json:"es_index_refresh_type" bson:"es_index_refresh_type"`
	Remarks            string   `json:"remarks,omitempty" bson:"remarks,omitempty"`
}

type NoticeMsgConfigFeishu

type NoticeMsgConfigFeishu struct {
	WebHookUrl string `json:"web_hook_url" bson:"web_hook_url"`
	Seceret    string `json:"seceret,omitempty" bson:"seceret,omitempty"`
	Remarks    string `json:"remarks,omitempty" bson:"remarks,omitempty"`
}

type NoticeMsgConfigKafka

type NoticeMsgConfigKafka struct {
	KafkaBootstrapServers string `json:"server" bson:"server"`
	KafkaTopic            string `json:"topic" bson:"topic"`
	KafkaOtherConf        string `json:"other_config,omitempty" bson:"other_config,omitempty"`
	Remarks               string `json:"remarks,omitempty" bson:"remarks,omitempty"`
}

type NoticeMsgConfigSyslog

type NoticeMsgConfigSyslog struct {
	SyslogServer string `json:"syslog_server" bson:"syslog_server"`
	Protocol     string `json:"protocol" bson:"protocol"`
	Facility     int    `json:"facility" bson:"facility"`
	Remarks      string `json:"remarks,omitempty" bson:"remarks,omitempty"`
}

type NoticeRunConfig

type NoticeRunConfig struct {
	NoticeId   *string  `json:"notice_id,omitempty" bson:"notice_id,omitempty"`
	Type       string   `json:"notice_type" bson:"notice_type"`
	LevelList  []string `json:"notice_level_list" bson:"notice_level_list"`
	Status     int      `json:"status" bson:"status"`
	MsgType    string   `json:"notice_config_type" bson:"notice_config_type"`
	Abstract   string   `json:"notice_config_abstract" bson:"notice_config_abstract"`
	Desc       string   `json:"notice_type_desc" bson:"notice_type_desc"`
	UpdateTime int64    `json:"update_time" bson:"update_time"`
	UpdateUser string   `json:"update_user" bson:"update_user"`
}

type OutWorker

type OutWorker interface {
	Init(*OutputerConfig) error
	HitModel(DataHitModelInfo) bool //是否开启model
	SendMsg(*DataModel)
	Close()
}

type OutputerConfig

type OutputerConfig struct {
	NoticeConfigDbDataFormat `json:",inline" bson:",inline"`
}

type PluginInfo

type PluginInfo struct {
	// 不可修改,字段同时存在于zip包内
	// plugin type+name 组成唯一标识
	PluginName string `json:"plugin_name" bson:"plugin_name"`
	PluginType string `json:"plugin_type" bson:"plugin_type"`

	Description string `json:"description" bson:"description"`
	Runtime     string `json:"runtime" bson:"runtime"`
	Author      string `json:"author" bson:"author"`

	Sha256Sum string    `json:"sha256sum" bson:"sha256sum"`
	UploadAt  time.Time `json:"upload_at" bson:"upload_at"`
}

type SyslogWorker

type SyslogWorker struct {
	Queue chan *DataModel
	// contains filtered or unexported fields
}

func (*SyslogWorker) Close

func (b *SyslogWorker) Close()

func (*SyslogWorker) HitModel

func (b *SyslogWorker) HitModel(model DataHitModelInfo) bool

func (*SyslogWorker) Init

func (b *SyslogWorker) Init(conf *OutputerConfig) error

func (*SyslogWorker) SendMsg

func (b *SyslogWorker) SendMsg(dm *DataModel)

func (*SyslogWorker) WaitForInputMsg

func (b *SyslogWorker) WaitForInputMsg()

type TestPluginReq

type TestPluginReq struct {
	HubAddress string            `json:"hub_address"`
	PluginType string            `json:"plugin_type"`
	PluginName string            `json:"plugin_name"`
	Config     map[string]string `json:"config"`
	Data       interface{}       `json:"data"`
	Sha256Sum  string            `json:"sha256sum"`
}

type WorkSpace

type WorkSpace struct {
	NameSpace   string            `bson:"NameSpace"`
	ClusterName string            `bson:"ClusterName"`
	CreateAt    int64             `bson:"CreateAt"`
	Users       map[string]string `bson:"Users"`
}

type Worker

type Worker struct {
	Conf  *OutputerConfig
	Queue chan *DataModel
}

Jump to

Keyboard shortcuts

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