teawaf

package
v0.1.72 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 13 Imported by: 0

README

WAF

A basic WAF for TeaWeb.

Config Constructions

WAF
  Inbound
	  Rule Groups
		Rule Sets
		  Rules
			Checkpoint Param <Operator> Value
  Outbound
  	  Rule Groups
  	    ... 				

Apply WAF

Request  -->  WAF  -->   Backends
			/
Response  <-- WAF <----		

Coding

waf := teawaf.NewWAF()

// add rule groups here

err := waf.Init()
if err != nil {
	return
}
waf.Start()

// match http request
// (req *http.Request, responseWriter http.ResponseWriter)
goNext, ruleSet, _ := waf.MatchRequest(req, responseWriter)
if ruleSet != nil {
	log.Println("meet rule set:", ruleSet.Name, "action:", ruleSet.Action)
}
if !goNext {
	return
}

// stop the waf
// waf.Stop()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WAF

type WAF struct {
	Id             string             `yaml:"id" json:"id"`
	On             bool               `yaml:"on" json:"on"`
	Name           string             `yaml:"name" json:"name"`
	Inbound        []*rules.RuleGroup `yaml:"inbound" json:"inbound"`
	Outbound       []*rules.RuleGroup `yaml:"outbound" json:"outbound"`
	CreatedVersion string             `yaml:"createdVersion" json:"createdVersion"`

	ActionBlock *actions.BlockAction `yaml:"actionBlock" json:"actionBlock"` // action block config
	// contains filtered or unexported fields
}

func NewWAF

func NewWAF() *WAF

func NewWAFFromFile

func NewWAFFromFile(path string) (waf *WAF, err error)

func Template

func Template() *WAF

感谢以下规则来源: - Janusec: https://www.janusec.com/

func (*WAF) AddRuleGroup

func (this *WAF) AddRuleGroup(ruleGroup *rules.RuleGroup)

func (*WAF) ContainsGroupCode

func (this *WAF) ContainsGroupCode(code string) bool

func (*WAF) Copy

func (this *WAF) Copy() *WAF

func (*WAF) CountInboundRuleSets

func (this *WAF) CountInboundRuleSets() int

func (*WAF) CountOutboundRuleSets

func (this *WAF) CountOutboundRuleSets() int

func (*WAF) FindCheckpointInstance

func (this *WAF) FindCheckpointInstance(prefix string) checkpoints.CheckpointInterface

func (*WAF) FindRuleGroup

func (this *WAF) FindRuleGroup(ruleGroupId string) *rules.RuleGroup

func (*WAF) FindRuleGroupWithCode

func (this *WAF) FindRuleGroupWithCode(ruleGroupCode string) *rules.RuleGroup

func (*WAF) Init

func (this *WAF) Init() error

func (*WAF) MatchKeyword added in v0.1.7

func (this *WAF) MatchKeyword(keyword string) (matched bool, name string, tags []string)

match keyword

func (*WAF) MatchRequest

func (this *WAF) MatchRequest(rawReq *http.Request, writer http.ResponseWriter) (goNext bool, set *rules.RuleSet, err error)

func (*WAF) MatchResponse

func (this *WAF) MatchResponse(rawReq *http.Request, rawResp *http.Response, writer http.ResponseWriter) (goNext bool, set *rules.RuleSet, err error)

func (*WAF) MergeTemplate

func (this *WAF) MergeTemplate() (changedItems []string)

merge with template

func (*WAF) MoveInboundRuleGroup

func (this *WAF) MoveInboundRuleGroup(fromIndex int, toIndex int)

func (*WAF) MoveOutboundRuleGroup

func (this *WAF) MoveOutboundRuleGroup(fromIndex int, toIndex int)

func (*WAF) OnAction

func (this *WAF) OnAction(onActionCallback func(action actions.ActionString) (goNext bool))

func (*WAF) RemoveRuleGroup

func (this *WAF) RemoveRuleGroup(ruleGroupId string)

func (*WAF) Save

func (this *WAF) Save(path string) error

save to file path

func (*WAF) Start

func (this *WAF) Start()

start

func (*WAF) Stop

func (this *WAF) Stop()

call stop() when the waf was deleted

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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