Documentation
¶
Overview ¶
Package waf 实现基于 Coraza 与 OWASP 核心规则集(CRS)的 Web 应用防火墙, 以实例形式供 Web 服务的站点引用。
Index ¶
- Constants
- func CRSFiles() []string
- type Instance
- type InstanceInfo
- type InstanceView
- type Module
- func (m *Module) ID() string
- func (m *Module) ImportLucky(doc luckyimport.Document, opts luckyimport.Options) (*luckyimport.Report, error)
- func (m *Module) Init(env module.Env) error
- func (m *Module) Instances() []InstanceInfo
- func (m *Module) Middleware(key string, next http.Handler) http.Handler
- func (m *Module) Routes(r module.Router)
- func (m *Module) Start(context.Context) error
- func (m *Module) Stop() error
- func (m *Module) Summary() []module.SummaryItem
- func (m *Module) Title() string
- type RuleSet
Constants ¶
const ( RuleCRS = "crs" RuleCustom = "custom" )
规则集类型
const ( ModeBlock = "block" ModeDetect = "detect" )
工作模式
const ID = "waf"
ID 是模块标识。
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Instance ¶
type Instance struct {
Key string `json:"key"`
Name string `json:"name"`
Enable bool `json:"enable"`
Mode string `json:"mode"`
// Paranoia 为 CRS 偏执等级 1~4,越高越严格、误报越多
Paranoia int `json:"paranoia"`
InboundThreshold int `json:"inboundThreshold"`
OutboundThreshold int `json:"outboundThreshold"`
RuleSets []RuleSet `json:"ruleSets"`
Remark string `json:"remark"`
}
Instance 是一个 WAF 实例。
type InstanceInfo ¶
InstanceInfo 是供其他模块选择实例的简要信息。
type InstanceView ¶
type InstanceView struct {
Instance
Error string `json:"error,omitempty"`
Blocked int64 `json:"blocked"`
Matched int64 `json:"matched"`
}
InstanceView 是带统计的实例。
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module 是 WAF 模块。
func (*Module) ImportLucky ¶
func (m *Module) ImportLucky(doc luckyimport.Document, opts luckyimport.Options) (*luckyimport.Report, error)
ImportLucky 实现 luckyimport.Importer。沿用 Lucky 的实例 key,使 Web 服务站点的引用保持有效。
func (*Module) Middleware ¶
Middleware 返回经过指定实例检查的处理器。实例不存在、停用或编译失败时直接放行, 每次请求时读取最新实例,修改 WAF 配置后无需重启 Web 服务。
func (*Module) Summary ¶
func (m *Module) Summary() []module.SummaryItem
Summary 实现 module.Summarizer。