parser

package
v1.3.3-beta3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IndexAllSubstrings

func IndexAllSubstrings(s string, patterns ...string) (result [][2]int)

IndexAllSubstrings 只遍历一次查找所有子串位置 返回值是一个二维数组,每个元素是一个[2]int类型匹配结果,其中第一个元素是规则index,第二个元素是索引位置

Types

type BaseTag

type BaseTag struct {
	Data    []Node
	Labels  []string
	Methods *map[string]*TagMethod
	// contains filtered or unexported fields
}

func (*BaseTag) AddData

func (b *BaseTag) AddData(node ...Node)

func (*BaseTag) AddLabel

func (b *BaseTag) AddLabel(label string)

func (*BaseTag) DoOnce

func (b *BaseTag) DoOnce(f func())

DoOnce 用来对子结构体的初始化,可以在Exec函数中调用

func (*BaseTag) GetData

func (b *BaseTag) GetData() []Node

func (*BaseTag) GetLabels

func (b *BaseTag) GetLabels() []string

func (*BaseTag) IsNode

func (*BaseTag) IsNode()

type Escaper

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

func NewDefaultEscaper

func NewDefaultEscaper(chars ...string) *Escaper

func NewEscaper

func NewEscaper(escapeSymbol string, charsMap map[string]string) *Escaper

func (*Escaper) Escape

func (e *Escaper) Escape(s string) string

func (*Escaper) Unescape

func (e *Escaper) Unescape(s string) (string, error)

type ExecNode

type ExecNode interface {
	Reset()              // 重置生成器
	Exec() (bool, error) // 优先读取缓存,读完缓存后调用子生成器
	IsRep() bool
}

type FuzzResult

type FuzzResult struct {
	Source  []any // []*FuzzResult | [][]byte
	Data    any   // []byte | string
	ByTag   bool
	Verbose string
	Contact bool
	Error   error
}

func NewFuzzResult

func NewFuzzResult() *FuzzResult

func NewFuzzResultWithData

func NewFuzzResultWithData(d any) *FuzzResult

func NewFuzzResultWithDataVerbose

func NewFuzzResultWithDataVerbose(d any, v string) *FuzzResult

func (*FuzzResult) GetData

func (f *FuzzResult) GetData() []byte

func (*FuzzResult) GetVerbose

func (f *FuzzResult) GetVerbose() []string

type GenerateConfig

type GenerateConfig struct {
	AssertError bool
}

type Generator

type Generator struct {
	*GenerateConfig

	AssertError bool
	Error       error
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(nodes []Node, table map[string]*TagMethod) *Generator

func (*Generator) Next

func (g *Generator) Next() bool

func (*Generator) RawResult added in v1.3.3

func (g *Generator) RawResult() []*FuzzResult

func (*Generator) Result

func (g *Generator) Result() *FuzzResult

func (*Generator) SetTagsSync added in v1.2.9

func (g *Generator) SetTagsSync(b bool)

type MethodContext

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

func (*MethodContext) UpdateLabels

func (m *MethodContext) UpdateLabels(tag *TagExecNode)

UpdateLabels 更新全局labelTable,先删除当前tag的所有label映射,再增加

type Node

type Node interface {
	IsNode()
}

func Parse

func Parse(raw string, tagTypes ...*TagDefine) ([]Node, error)

type StringExecNode

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

String

func (*StringExecNode) Exec

func (s *StringExecNode) Exec() (bool, error)

func (*StringExecNode) FirstExec

func (s *StringExecNode) FirstExec() error

func (*StringExecNode) IsRep

func (s *StringExecNode) IsRep() bool

func (*StringExecNode) Reset

func (s *StringExecNode) Reset()

type StringNode

type StringNode string

func (StringNode) IsNode

func (s StringNode) IsNode()

type TagDefine

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

TagDefine 自定义tag类型

func NewTagDefine

func NewTagDefine(name, start, end string, tagStruct TagNode, raw ...bool) *TagDefine

NewTagDefine hooks参数用于判断数据是否需要解析tag

func (*TagDefine) NewTag

func (t *TagDefine) NewTag() TagNode

type TagExecNode

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

func NewTagGenerator

func NewTagGenerator(tag TagNode, ctx *MethodContext) *TagExecNode

func (*TagExecNode) Exec

func (f *TagExecNode) Exec() (bool, error)

func (*TagExecNode) FirstExec

func (f *TagExecNode) FirstExec(bp, exec, all bool) error

FirstExec 重置并执行

func (*TagExecNode) FirstExecWithBackpropagation added in v1.2.9

func (f *TagExecNode) FirstExecWithBackpropagation(bp, exec, all bool) error

func (*TagExecNode) IsRep

func (s *TagExecNode) IsRep() bool

func (*TagExecNode) Reset

func (s *TagExecNode) Reset()

type TagMethod

type TagMethod struct {
	Name        string
	IsDyn       bool
	Fun         func(string) ([]*FuzzResult, error)
	Expand      map[string]any
	Alias       []string
	Description string
}

type TagNode

type TagNode interface {
	IsNode()
	Exec(*FuzzResult, ...map[string]*TagMethod) ([]*FuzzResult, error)
	AddData(node ...Node)
	AddLabel(label string)

	GetData() []Node
	GetLabels() []string
}

Jump to

Keyboard shortcuts

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