entry

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 15 Imported by: 0

README

错误级别说明

目前设置以下级别:

编号 程序显示 说明
9999 UnknownError 未知错误(内部错误,日常不会出现)
10000 Legal 合法访问
10001 Illegal_WellknownView Openapi文件中没有定义过的静态文件,但被wellknown.yaml文件定义为常见URL
10002 Illegal_StaticView Openapi文件中没有定义过的静态文件
10003 Not_HTTP_View 非Http访问,通常为攻击性扫描
10004 Illegal_UnknownUrl Openapi文件中没有定义过的非静态文件(危险级别较静态文件高)
10005 Illegal_Method Openapi中定义过url,但是访问方法错误
10006 Illegal_EmptyArgs Openapi中定义过该url和对应的访问方法,但未提交任何参数
10007 Illegal_UnexpectedArgs Openapi中定义过该url和对应的方法,但访问提交的参数不符合定义中规定的参数范围
10008 Illegal_DiffusedArgs Openapi中定义过该url和对应的方法,但访问提交的参数被判定为滥用

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseRequest

func ParseRequest(req string, entry *LogEntry)

Types

type ConfigDetector added in v0.9.0

type ConfigDetector interface {
	IsWellknownView(path, method string) bool
	IsStaticPath(path string) bool
	HasFeatureDB() bool
}

type LogEntry

type LogEntry struct {
	Url        string     `json:"u"`
	Method     string     `json:"m,omitempty"`
	Protocol   string     `json:"p,omitempty"`
	Client     string     `json:"c,omitempty"` //client ip
	StatusCode int        `json:"s,omitempty"`
	Legal      bool       `json:"l,omitempty"`
	Query      url.Values `json:"q,omitempty"`
	//OpenAPI参数错误
	ParameterErrors map[int]*ParameterError `json:"pe,omitempty"`
	//
	ErrorType etype.EntryError `json:"e,omitempty"`
	Created   time.Time        `json:"t"`
	Count     int64            //used for stat in rule
	Notified  bool             `json:"n,omitempty"`
	Version   int              `json:"v,omitempty"`
}

func ParseString

func ParseString(line string) *LogEntry

func (*LogEntry) Description

func (e *LogEntry) Description() string

func (*LogEntry) DetechError added in v0.9.0

func (rec *LogEntry) DetechError(cfg ConfigDetector, api *openapi3.T, baseUrl string)

func (*LogEntry) DetectDeepErrorByDef added in v0.9.0

func (l *LogEntry) DetectDeepErrorByDef(path, mName string, def *openapi3.Operation, parsInPath map[string]string)

进行深度探测,调用featuredb包进行深入的聚类分析

func (*LogEntry) DetectErrorByDef

func (l *LogEntry) DetectErrorByDef(def *openapi3.Operation, parsInPath map[string]string)

详细探测错误的类型,根据OpenAPI定义中的参数的具体设置范围,探测请求的范围

func (*LogEntry) FillByRecord

func (e *LogEntry) FillByRecord(recs []string)

func (*LogEntry) GetErrorTypeByParameterErrors added in v0.9.0

func (e *LogEntry) GetErrorTypeByParameterErrors() etype.EntryError

func (*LogEntry) SeperatePath

func (l *LogEntry) SeperatePath()

func (*LogEntry) String

func (e *LogEntry) String() string

func (*LogEntry) WriteTo

func (e *LogEntry) WriteTo(w io.Writer, newLine string) error

type LogEntryResponse

type LogEntryResponse struct {
	Entry *LogEntry
	Error error
}

type ParameterError

type ParameterError struct {
	Type   bool `json:"type,omitempty" yaml:"type,omitempty"`
	Format bool `json:"format,omitempty" yaml:"format,omitempty"`
	Enum   bool `json:"enum,omitempty" yaml:"enum,omitempty"`

	Name     string
	In       string
	Required bool `json:"required,omitempty" yaml:"required,omitempty"`

	// Array-related, here for struct compactness
	UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
	// Number-related, here for struct compactness
	ExclusiveMin bool `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"`
	ExclusiveMax bool `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"`
	// Properties
	Nullable        bool `json:"nullable,omitempty" yaml:"nullable,omitempty"`
	AllowEmptyValue bool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`
	Deprecated      bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`

	// Number
	Min        bool `json:"minimum,omitempty" yaml:"minimum,omitempty"`
	Max        bool `json:"maximum,omitempty" yaml:"maximum,omitempty"`
	MultipleOf bool `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`

	// String
	MinLength bool `json:"minLength,omitempty" yaml:"minLength,omitempty"`
	MaxLength bool `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
	Pattern   bool `json:"pattern,omitempty" yaml:"pattern,omitempty"`

	// Array
	MinItems bool `json:"minItems,omitempty" yaml:"minItems,omitempty"`
	MaxItems bool `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`
}

func (*ParameterError) HasError

func (e *ParameterError) HasError() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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