convention

package
v0.0.7-1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	IndPTypePlProc    = 0
	IndPTypeReact     = 1
	IndPTypePlGen     = 2
	IndPTypeReqSender = 3
	IndPTypePreproc   = 4
)

Variables

View Source
var FuncDecls = map[string]FuncDecl{
	PluginTypes[0]: {
		Params:  []Param{{Name: "payload", Type: "string"}},
		RetType: "string",
	},
	PluginTypes[1]: {
		Params:  []Param{{Name: "req", Type: "*fuzzTypes.Req"}, {Name: "resp", Type: "*fuzzTypes.Resp"}},
		RetType: "*fuzzTypes.Reaction",
	},
	PluginTypes[2]: {
		Params:  []Param{},
		RetType: "[]string",
	},
	PluginTypes[3]: {
		Params:  []Param{{Name: "sendMeta", Type: "*fuzzTypes.SendMeta"}},
		RetType: "*fuzzTypes.Resp",
	},
	PluginTypes[4]: {
		Params:  []Param{{Name: "fuzz", Type: "*fuzzTypes.Fuzz"}},
		RetType: "*fuzzTypes.Fuzz",
	},
}

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

View Source
var PluginFunNames = []string{"PayloadProcessor", "React", "PayloadGenerator", "SendRequest", "Preprocess"}
View Source
var PluginTypes = []string{"payloadProc", "reactor", "payloadGen", "reqSender", "preprocess"}
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 GenCodeByType

func GenCodeByType(pluginType string) string

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

func GenPlugInfoFun

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

GenPlugInfoFun 生成PluginInfo函数

func GetFullStruct

func GetFullStruct(structType string) any

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

func GetParamStrings

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

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

func GetPluginFunName

func GetPluginFunName(pluginType string) string

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

func GetPluginType

func GetPluginType(pluginFunName string) string

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

func GetReservedArgs

func GetReservedArgs(pType string) []any

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

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