Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateRuleDirectory ¶
ValidateRuleDirectory 严格验证规则目录下的所有规则文件。
行为: - 遍历目录中的所有 YAML 规则文件 - 对每个文件调用 LoadRuleStrict 收集 YAML/Matcher 的所有错误 - 不会中断整个遍历,所有问题都会被返回
fatalErr 仅在目录本身不可访问等致命场景下返回; errs 列出所有规则文件级别的问题,用于 validate 模式报告。
Types ¶
type CompiledRule ¶ added in v1.7.0
CompiledRule is the runtime representation of a YAML Rule. The source Rule is retained for metadata and extraction, while the rule set owns only compiled runtime entries.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns a sequence of immutable rules snapshots for one rule directory.
func LoadDefaultRules ¶ added in v1.6.18
LoadDefaultRules ensures the default rule repository exists and loads it.
func NewManager ¶
NewManager loads the initial immutable rules snapshot from path.
func (*Manager) FindRuleByName ¶
FindRuleByName returns the first source rule in a category, if present.
func (*Manager) GetLastLoadTime ¶
GetLastLoadTime returns when the current snapshot was published.
func (*Manager) ReloadRules ¶
ReloadRules loads and publishes a new immutable rules snapshot. A failed reload leaves the last successfully loaded snapshot available to scanners.
type MatchPartGetter ¶
MatchPartGetter 定义了获取匹配部分的函数类型 CaseSensitive 大小写敏感
type MatchResult ¶
MatchResult 表示匹配结果
func (MatchResult) IsPlugin ¶
func (m MatchResult) IsPlugin() bool
type Rule ¶
type Rule struct {
Name string `json:"name,omitempty"`
Service string `yaml:"service" json:"service,omitempty"`
MatchersCondition string `yaml:"matchers-condition" json:"matchers_condition,omitempty"`
// 组件太多 采用层级匹配 优化匹配速度
Require []string `json:"require,omitempty"`
Matchers []*matchers.Matcher `json:"matchers,omitempty"`
Plugins []*Plugin `yaml:"plugins"`
Cpe map[string]interface{} `yaml:"cpe" json:"cpe,omitempty"`
}
func LoadRuleStrict ¶
LoadRuleStrict 与 LoadRule 类似,但用于严格校验: - 收集 YAML 解析错误 - 收集 matcher 编译错误 返回规则和累积错误(如果有)。
type RuleSet ¶ added in v1.7.0
type RuleSet struct {
// contains filtered or unexported fields
}
Finger 根据协议分组
func NewRuleSet ¶ added in v1.7.0
func NewRuleSet() *RuleSet
func ScanRuleDirectory ¶
func (RuleSet) CategoryCount ¶ added in v1.7.1
CategoryCount returns the number of rule categories in this immutable snapshot.
func (RuleSet) FirstRule ¶ added in v1.7.1
FirstRule returns the first source rule in a category, if present.
func (RuleSet) Match ¶ added in v1.7.0
func (f RuleSet) Match(service string, getMatchPart MatchPartGetter) []*MatchResult
Match 执行指纹匹配并返回包含规则的匹配结果