Documentation
¶
Overview ¶
Package parser 实现了指纹规则的解析和评估功能。 该包提供了将YAML格式的指纹规则转换为可执行规则对象的功能, 并支持对HTTP请求响应进行指纹匹配评估。
Package parser 实现栈结构 ¶
Package parser 实现栈结构 ¶
Package parser 实现词法分析 ¶
Package parser 实现词法分析栈结构
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckBalance ¶
CheckBalance verifies if parentheses in token sequence are balanced Returns error if unbalanced, nil otherwise 主要功能:检查token序列中的括号是否匹配 不匹配时返回error,匹配时返回nil
Types ¶
type AdvisoryConfig ¶
AdvisoryConfig 提供漏洞配置信息
type Extractor ¶
type Extractor struct { Part string `yaml:"part"` Group string `yaml:"group"` Regex string `yaml:"regex"` }
Extractor 定义了从响应中提取信息的规则
type FingerPrint ¶
type FingerPrint struct { Info FingerPrintInfo `yaml:"info"` Http []HttpRule `yaml:"http"` Version []HttpRule `yaml:"version,omitempty"` }
FingerPrint 定义了完整的指纹规则结构
func InitFingerPrintFromData ¶
func InitFingerPrintFromData(reader []byte) (*FingerPrint, error)
InitFingerPrintFromData 从字节数据初始化指纹配置 参数:
- reader: 包含YAML格式指纹配置的字节数据
返回:
- *FingerPrint: 解析后的指纹对象
- error: 解析过程中的错误
type FingerPrintInfo ¶
type FingerPrintInfo struct { Name string `yaml:"name"` Author string `yaml:"author"` Example []string `yaml:"example,omitempty"` Desc string `yaml:"desc,omitempty"` Severity string `yaml:"severity"` Metadata map[string]string `yaml:"metadata"` }
FingerPrintInfo 定义了指纹的基本信息
type HttpRule ¶
type HttpRule struct { Method string `yaml:"method"` Path string `yaml:"path"` Matchers []string `yaml:"matchers"` Data string `yaml:"data,omitempty"` Extractor Extractor `yaml:"extractor,omitempty"` // contains filtered or unexported fields }
HttpRule 定义了HTTP请求匹配规则
type Rule ¶
type Rule struct {
// contains filtered or unexported fields
}
Rule 表示一个规则,包含多个表达式
func TransFormExp ¶
TransFormExp 将token序列转换为表达式规则 输入tokens切片,返回Rule对象和error 主要功能:解析tokens并构建DSL表达式、逻辑表达式和括号表达式
func (*Rule) AdvisoryEval ¶
func (r *Rule) AdvisoryEval(config *AdvisoryConfig) bool
AdvisoryEval 评估建议规则是否匹配 输入建议配置对象,返回布尔值表示是否匹配 主要用于版本号比较的规则评估
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack represents a LIFO (Last In First Out) data structure 使用Go标准库中的list实现栈结构
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token represents a lexical unit in the expression parsing 表示表达式解析中的词法单元
func ParseAdvisorTokens ¶
ParseAdvisorTokens parses advisor expressions, similar to ParseTokens but supports version keyword
func ParseTokens ¶
ParseTokens converts input string to token sequence, supporting text content(quoted), comparison ops(=,==,!=,~=), logical ops(&&,||), parentheses and keywords(body,header,icon)