common

package
v0.0.0-...-1508665 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckCfgOperator = map[string]string{
	"contain_str":   "string",
	"not_contain":   "string",
	"equal_str":     "string",
	"not_equal_str": "string",
	"prefix_str":    "string",
	"suffix_str":    "string",
	"gt_num":        "number",
	"lt_num":        "number",
	"ge_num":        "number",
	"le_num":        "number",
	"eq_num":        "number",
}
View Source
var OperatorFunc = map[string]interface{}{
	"contain_str":     contain_str,
	"not_contain_str": not_contain_str,
	"equal_str":       equal_str,
	"not_equal_str":   not_equal_str,
	"prefix_str":      prefix_str,
	"suffix_str":      suffix_str,
	"gt_num":          gt_num,
	"lt_num":          lt_num,
	"ge_num":          ge_num,
	"le_num":          le_num,
	"eq_num":          eq_num,
}

Functions

func CheckCaseResultValid

func CheckCaseResultValid(caseResults *[]CaseResult, glbCfg *GlbConfig) error

func CheckCaseResultValidWithJson

func CheckCaseResultValidWithJson(cr *CaseResult, glbCfg *GlbConfig) (bool, error)

func CheckCaseResultValidWithMysql

func CheckCaseResultValidWithMysql(cr *CaseResult, glbCfg *GlbConfig) (bool, error)

func ConnectDb

func ConnectDb(glbCfg *GlbConfig) error

func GetAllFile

func GetAllFile(pathname string, files map[string]string) error

func ReadJson

func ReadJson(fname string, v interface{}) error

func RequestUri

func RequestUri(r *ReqCommon) ([]byte, error)

func WriteJson

func WriteJson(data []byte, fname string)

Types

type CaseResult

type CaseResult struct {
	Name        string `json:"case,omitempty"`
	RespCode    int64  `json:"respCode,omitempty"`
	Type        string `json:"type,omitempty"`
	RespBody    []byte `json:"respBody,omitempty"`
	Resp        RespWafApi
	CheckCfg    *RespCheckCfg `json:"-"`
	CheckResult bool          `json:"-"`
}

type DBConfig

type DBConfig struct {
	DBEngine string `json:"db_engine,omitempty"`
	DBHost   string `json:"db_host,omitempty"`
	DBPort   int64  `json:"db_port,omitempty"`
	DBName   string `json:"db_name,omitempty"`
	DBUser   string `json:"db_user,omitempty"`
	DBPass   string `json:"db_pass,omitempty"`
}

type GlbConfig

type GlbConfig struct {
	Debug       bool              `json:"debug,omitempty"`
	Enable      map[string]bool   `json:"enable,omitempty"`
	Method      string            `json:"method,omitempty"`
	Hosts       map[string]string `json:"hosts,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
	RespFilter  string            `json:"respFilter,omitempty"`
	LogRespBody bool              `json:"logRespBody,omitempty"`
	LogFile     string            `json:"logfile,omitempty"`
	DbCfg       DBConfig          `json:"dbCfg,omitempty"`
	DBEngine    *xorm.Engine      `json:"-"` //重新加载时手动关闭数据库引擎: DBengine.Close()
}

type ReqCommon

type ReqCommon struct {
	Type     string            `json:"type,omitempty"`
	Url      string            `json:"url,omitempty"`
	Method   string            `json:"method,omitempty"`
	Payload  interface{}       `json:"payload,omitempty"`
	Headers  map[string]string `json:"headers,omitempty"`
	CheckCfg RespCheckCfg      `json:"check,omitempty"`
}

type RespCheckCfg

type RespCheckCfg struct {
	Type      string `json:"type,omitempty"`
	Match     string `json:"match,omitempty"`
	Operator  string `json:"operator,omitempty"`
	ValueType string `json:"valueType,omitempty"`
	Value     string `json:"value,omitempty"`
}

type RespWafApi

type RespWafApi struct {
	Code   int64                  `json:"code,omitempty"`
	Msg    string                 `json:"msg,omitempty"`
	MsgZh  string                 `json:"msgZh,omitempty"`
	Status string                 `json:"status,omitempty"`
	Data   map[string]interface{} `json:"data,omitempty"`
}

type RespWafApiData

type RespWafApiData struct {
	PageIndex int         `json:"pageIndex,omitempty"`
	PageSize  int         `json:"pageSize,omitempty"`
	Count     string      `json:"count,omitempty"`
	Data      interface{} `json:"data,omitempty"`
}

type User

type User struct {
	Name string
	Age  int8
}

Jump to

Keyboard shortcuts

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