es

package
v0.0.0-...-0b9a7cd Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ShowBulkIndexStatistic bool

Functions

func CheckElasticConn

func CheckElasticConn() bool

CheckElasticConn 检查ES连接是否正常

func GetAggregateLongResult

func GetAggregateLongResult(aggr types.Aggregate) (result map[string]int)

GetAggregateLongResult 获取key为long(比如端口号)的聚合结果

func GetAggregateStringResult

func GetAggregateStringResult(aggr types.Aggregate) (result map[string]int)

GetAggregateStringResult 获取key为string的聚合结果

func GetElasticConfig

func GetElasticConfig() elasticsearch.Config

GetElasticConfig 获取es配置

func GetTypedClient

func GetTypedClient() *elasticsearch.TypedClient

GetTypedClient 获取es连接对象

func ImportAssetsFromFile

func ImportAssetsFromFile(indexName string, filename string) bool

ImportAssetsFromFile 导入JSON格式的资产数据

func ImportDomainAssets

func ImportDomainAssets(workspaceResult map[int]string)

ImportDomainAssets 从mysql中导入指定workspace的Domain资产

func ImportIpAssets

func ImportIpAssets(workspaceResult map[int]string)

ImportIpAssets 从mysql中导入指定workspace的IP资产

func ParseQuery

func ParseQuery(expr string) (query types.Query, err error)

ParseQuery 将查询语法解析为elasticsearch的dsl语法

func SID

func SID(plainText string) string

SID 生成唯一标识

func SyncDomainAssets

func SyncDomainAssets(workspaceId int, domains []db.Domain) bool

SyncDomainAssets 同步Domain资产到es

func SyncIpAssets

func SyncIpAssets(workspaceId int, ips []db.Ip) bool

SyncIpAssets 同步IP资产到es

Types

type Assets

type Assets struct {
	IndexName string
	Ctx       context.Context
}

func NewAssets

func NewAssets(indexName string) *Assets

NewAssets 创建对象

func (*Assets) Aggregation

func (a *Assets) Aggregation(query types.Query) (result map[string]map[string]int, err error)

Aggregation 根据指定条件获取聚合数据

func (*Assets) BulkIndexDoc

func (a *Assets) BulkIndexDoc(docs []Document) bool

BulkIndexDoc 批量索文档

func (*Assets) CheckDoc

func (a *Assets) CheckDoc(docId string) bool

CheckDoc 检查文档是否存在

func (*Assets) CreateIndex

func (a *Assets) CreateIndex() bool

CreateIndex 创建索引

func (*Assets) CreateIndexWithJsonMapping

func (a *Assets) CreateIndexWithJsonMapping() bool

func (*Assets) DeleteDoc

func (a *Assets) DeleteDoc(docId string) (status bool)

DeleteDoc 根据id删除一个文档对象

func (*Assets) DeleteIndex

func (a *Assets) DeleteIndex() bool

DeleteIndex 删除索引

func (*Assets) GetDoc

func (a *Assets) GetDoc(docId string) (doc Document, status bool)

GetDoc 根据id获取一个文档对象

func (*Assets) GetIndexMapping

func (a *Assets) GetIndexMapping() *types.TypeMapping

GetIndexMapping 定义索引的mapping

func (*Assets) GetIndexMappingWithJson

func (a *Assets) GetIndexMappingWithJson() string

func (*Assets) IndexDoc

func (a *Assets) IndexDoc(doc Document) bool

IndexDoc 索引文档

func (*Assets) ListAllIndices

func (a *Assets) ListAllIndices() (indexInfo map[string]string)

ListAllIndices 获取所有的可用索引

func (*Assets) Search

func (a *Assets) Search(query types.Query, page, rowsPerPage int) (res *search.Response, err error)

Search 查询,根据查询条件返回指定数量的文档,查询使用是bool查询

type Document

type Document struct {
	Id         string    `json:"id"`
	Host       string    `json:"host"`
	Ip         []string  `json:"ip"`
	Port       int       `json:"port"`
	Domain     string    `json:"domain"`
	Location   []string  `json:"location"`
	Status     int       `json:"status"`
	Service    string    `json:"service"`
	Banner     string    `json:"banner"`
	Server     string    `json:"server"`
	Title      string    `json:"title"`
	Header     string    `json:"header"`
	Body       string    `json:"body"`
	Cert       string    `json:"cert"`
	IconHash   int64     `json:"icon_hash"`
	Org        string    `json:"org"`
	Source     []string  `json:"source"`
	Comment    string    `json:"comment"`
	CreateTime time.Time `json:"create_time"`
	UpdateTime time.Time `json:"update_time"`
}

Jump to

Keyboard shortcuts

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