base

package
v0.0.0-...-0f5f40a Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheItem

type CacheItem struct {
	PocName  string
	RuleName string
	Req      *client.TheRequest
	Resp     *client.TheResponse
}

CacheItem 缓存

type Expr

type Expr struct {
	Env      *expression.Environment
	StrValue string
}

Expr 表达式 一开始没有把表达式当作 string 所以给到了一个 struct 未来拓展

type GlobalCache

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

GlobalCache 全局的缓存

func NewGlobalCache

func NewGlobalCache() *GlobalCache

func (*GlobalCache) GetCache

func (g *GlobalCache) GetCache(req *client.TheRequest) (*client.TheResponse, error)

func (*GlobalCache) SetCache

func (g *GlobalCache) SetCache(
	pocName string,
	rule string,
	req *client.TheRequest,
	resp *client.TheResponse) error

type List

type List[T any] struct {
	// contains filtered or unexported fields
}

List 这是一个 list 的包装

func NewList

func NewList[T any]() *List[T]

func (*List[T]) Add

func (l *List[T]) Add(item T)

func (*List[T]) Clear

func (l *List[T]) Clear()

func (*List[T]) Get

func (l *List[T]) Get(index int) (T, error)

func (*List[T]) Items

func (l *List[T]) Items() []T

func (*List[T]) Length

func (l *List[T]) Length() int

func (*List[T]) Remove

func (l *List[T]) Remove(index int) error

type Map

type Map[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Map golang 的 map 是无序的 有时候其实是需要一个有序的 map 结构

func NewMap

func NewMap[K comparable, V any]() *Map[K, V]

func (*Map[K, V]) Clear

func (m *Map[K, V]) Clear()

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(key K)

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(key K) V

func (*Map[K, V]) Keys

func (m *Map[K, V]) Keys() []K

func (*Map[K, V]) Length

func (m *Map[K, V]) Length() int

func (*Map[K, V]) Set

func (m *Map[K, V]) Set(key K, value V)

func (*Map[K, V]) Sort

func (m *Map[K, V]) Sort(compare func(a, b K) bool)

func (*Map[K, V]) ToMap

func (m *Map[K, V]) ToMap() map[K]V

type Output

type Output struct {
	Search     string
	ValueName  string
	ValueValue string
}

Output 这里是 XRAY 的 OUTPUT 语法 通过 SEARCH 正则提取

type POC

type POC struct {
	Ctx context.Context
	// 这是 EXPRESSION 的环境
	Env *expression.Environment
	// 当前 POC 需要保存的信息
	Context *PocContext
	// 全局的缓存
	Caches *GlobalCache
	Target string
	Name   string
	// 目前仅支持 HTTP
	Transport  string
	Set        *Map[string, *Expr]
	Payload    *Payload
	Rules      *Map[string, *Rule]
	Expression *Expr
	// DETAIL 暂未实现
	Detail *Map[string, string]
}

POC XRAY 的 POC 总结构体

func (*POC) Clone

func (p *POC) Clone() (*POC, error)

func (*POC) DoReq

func (p *POC) DoReq(req *client.TheRequest) (*client.TheResponse, error)

func (*POC) GetAllResults

func (p *POC) GetAllResults() map[string]bool

func (*POC) GetLocal

func (p *POC) GetLocal(key string) expression.EValue

func (*POC) GetReq

func (p *POC) GetReq(rule string) *client.TheRequest

func (*POC) GetResp

func (p *POC) GetResp(rule string) *client.TheResponse

func (*POC) GetResult

func (p *POC) GetResult(rule string) bool

func (*POC) Locals

func (p *POC) Locals() map[string]expression.EValue

func (*POC) SetLocal

func (p *POC) SetLocal(key string, value expression.EValue)

func (*POC) SetReq

func (p *POC) SetReq(rule string, req *client.TheRequest)

func (*POC) SetResp

func (p *POC) SetResp(rule string, resp *client.TheResponse)

func (*POC) SetResult

func (p *POC) SetResult(rule string, result bool)

type Payload

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

Payload XRAY 的 PAYLOAD 语法后续考虑支持

func NewPayload

func NewPayload() *Payload

func (*Payload) Available

func (p *Payload) Available() bool

func (*Payload) Get

func (p *Payload) Get() *Map[string, *Map[string, *Expr]]

func (*Payload) Set

func (p *Payload) Set(key string, ma *Map[string, *Expr])

type PocContext

type PocContext struct {
	// 包装后的 HTTP CLIENT
	// 不建议直接使用 RAW CLIENT
	Client *client.HttpClient
	// 适用于当前 POC 运行环境的本地变量
	Local *Map[string, expression.EValue]
	// 记录每一个 rule 的 request 信息
	AllRequests *Map[string, *client.TheRequest]
	// 记录每一个 rule 的 response 信息
	AllResponses *Map[string, *client.TheResponse]
	// 记录每一个 rule 的执行结果
	AllResults *Map[string, bool]
}

PocContext 单个 POC 的 Context 这里的很多信息保存暂时未用到 考虑到未来做统计需要

func NewPocContext

func NewPocContext(c *client.HttpClient) (*PocContext, error)

type Request

type Request struct {
	Cache          bool
	Method         string
	Path           string
	Headers        *Map[string, string]
	FollowRedirect bool
	Body           string
}

Request 每个 RULE 对应的 REQUEST

type Rule

type Rule struct {
	Req        *Request
	Expression *Expr
	Output     *Output
}

Rule 规则

Jump to

Keyboard shortcuts

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