parser

package
v1.4.4-alpha1202-diff-... Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 9 Imported by: 5

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
	// 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) IsFlowControl

func (b *BaseTag) IsFlowControl() bool

func (*BaseTag) IsNode

func (*BaseTag) IsNode()

func (*BaseTag) String

func (b *BaseTag) String() string

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
	// contains filtered or unexported fields
}

func (*GenerateConfig) Debug

func (g *GenerateConfig) Debug()

type Generator

type Generator struct {
	*GenerateConfig

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

func NewGenerator

func NewGenerator(ctx context.Context, nodes []Node, table map[string]*TagMethod) *Generator

func (*Generator) Cancel

func (g *Generator) Cancel()

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)

func (*Generator) Wait

func (g *Generator) Wait()

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()
	String() string
}

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) IsFlowControl

func (s StringNode) IsFlowControl() bool

func (StringNode) IsNode

func (s StringNode) IsNode()

func (StringNode) String

func (s StringNode) String() string

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) GetCache

func (f *TagExecNode) GetCache(index int) (*FuzzResult, 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
	IsFlowControl bool
	Fun           func(string) ([]*FuzzResult, error)
	YieldFun      func(ctx context.Context, params string, yield func(*FuzzResult)) error
	Expand        map[string]any
	Alias         []string
	Description   string
}

type TagNode

type TagNode interface {
	IsNode()
	Exec(ctx context.Context, raw *FuzzResult, yield func(*FuzzResult), methodTable map[string]*TagMethod) error
	//Exec(*FuzzResult, func(*FuzzResult), ...map[string]*TagMethod) error
	AddData(node ...Node)
	AddLabel(label string)
	String() string
	GetData() []Node
	GetLabels() []string
	IsFlowControl() bool
}

Jump to

Keyboard shortcuts

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