convention

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	IndPTypePlProc = iota
	IndPTypeReact
	IndPTypePlGen
	IndPTypeRequester
	IndPTypePreproc
	IndPTypeIterator
	IndPTypeIteratorMinor = 0
)

Variables

View Source
var FuncDecls = map[string]FuncDecl{
	PluginTypes[IndPTypePlProc]: {
		Params:  []Param{{Name: "payload", Type: "string"}},
		RetType: "string",
	},
	PluginTypes[IndPTypeReact]: {
		Params:  []Param{{Name: "req", Type: "*fuzzTypes.Req"}, {Name: "resp", Type: "*fuzzTypes.Resp"}},
		RetType: "*fuzzTypes.Reaction",
	},
	PluginTypes[IndPTypePlGen]: {
		Params:  []Param{},
		RetType: "[]string",
	},
	PluginTypes[IndPTypeRequester]: {
		Params:  []Param{{Name: "requestCtx", Type: "*fuzzTypes.RequestCtx"}},
		RetType: "*fuzzTypes.Resp",
	},
	PluginTypes[IndPTypePreproc]: {
		Params:  []Param{{Name: "fuzz", Type: "*fuzzTypes.Fuzz"}},
		RetType: "*fuzzTypes.Fuzz",
	},
	PluginTypes[IndPTypeIterator]: {
		Params:  []Param{{Name: "lengths", Type: "[]int"}, {"ind", "int"}},
		RetType: "[]int",
	},
	PluginMinorFun[IndPTypeIteratorMinor]: {
		Params:  []Param{{Name: "lengths", Type: "[]int"}},
		RetType: "int",
	},
}

FuncDecls 每种插件的约定函数原型

View Source
var PluginFunNames = []string{"PayloadProcessor", "React", "PayloadGenerator", "DoRequest", "Preprocess", "IterIndex"}
View Source
var PluginMinorFun = []string{"IterLen"}
View Source
var PluginTypes = []string{"payloadProc", "reactor", "payloadGen", "requester", "preprocess", "iterator"}
View Source
var Ranges = []fuzzTypes.Range{{500, 300}, {200, 100}, {404, 200}}

Functions

func CheckPluginFun

func CheckPluginFun(pluginType string, fd FuncDecl) (bool, string)

CheckPluginFun 判断插件函数的函数声明是否符合规范

func CheckPluginMinorFunc added in v0.1.0

func CheckPluginMinorFunc(pType string, fd FuncDecl) (bool, string)

func DefMinorFun added in v0.1.0

func DefMinorFun(pluginType string) string

DefMinorFun 次要函数,目前只有iterator插件的IterLen使用这个函数生成

func GenCodePType added in v0.1.0

func GenCodePType(pluginType string) string

GenCodePType 根据插件类型生成一个完整的可通过编译的代码骨架

func GenPlugInfoFun

func GenPlugInfoFun(pName, pType, goVer, usageFile string, params []ParaMeta) string

GenPlugInfoFun 生成PluginInfo函数

func GetContextArgs added in v0.1.0

func GetContextArgs(pType string) []any

GetContextArgs 根据插件类型返回预留参数

func GetFullStruct

func GetFullStruct(structType string) any

GetFullStruct 获取一个填写完整的结构体指针

func GetParamStrings

func GetParamStrings(os, pluginType string, params []Param) (formal string, actual string)

GetParamStrings 获取用于替换go模板文件中的参数占位符的字符串

func GetPluginFunName

func GetPluginFunName(pluginType string) string

GetPluginFunName 根据插件类型查找函数名

func GetPluginType

func GetPluginType(pluginFunName string) string

GetPluginType 根据函数名查找插件类型

func GetRetPtr

func GetRetPtr(retType string) any

GetRetPtr 取得指向插件返回值的指针

func GetStruct

func GetStruct(structType string) any

Types

type FuncDecl

type FuncDecl struct {
	Params  []Param
	RetType string
}

FuncDecl 函数声明

func BuildFd

func BuildFd(inf *PluginInfo) FuncDecl

BuildFd 根据插件实际信息返回一个FuncDecl结构

func GetFuncDecl

func GetFuncDecl(pluginType string) FuncDecl

type ParaMeta

type ParaMeta struct {
	Param    Param  `json:"param"`
	ParaInfo string `json:"para_info,omitempty"`
}

type Param

type Param struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

Param 参数

type PluginInfo

type PluginInfo struct {
	Name      string     `json:"name"`
	Type      string     `json:"type"`
	GoVersion string     `json:"go_version"`
	UsageInfo string     `json:"usage_info,omitempty"`
	Params    []ParaMeta `json:"params"`
}

Jump to

Keyboard shortcuts

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