mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 11:40:13 +00:00
实装fuzzy compare
This commit is contained in:
parent
6f1ca49408
commit
5fdbd5e05d
@ -260,6 +260,7 @@ func (p *Pool) PreCompare(resp *ihttp.Response) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) comparing() {
|
func (p *Pool) comparing() {
|
||||||
|
Loop:
|
||||||
for bl := range p.tempCh {
|
for bl := range p.tempCh {
|
||||||
if !bl.IsValid {
|
if !bl.IsValid {
|
||||||
// precompare 确认无效数据直接送入管道
|
// precompare 确认无效数据直接送入管道
|
||||||
@ -267,26 +268,23 @@ func (p *Pool) comparing() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.base.Compare(bl) == 1 {
|
if base, ok := p.baselines[bl.Status]; ok && base.Compare(bl) == 1 {
|
||||||
// 如果是同一个包则设置为无效包
|
// 挑选对应状态码的baseline进行compare
|
||||||
bl.IsValid = false
|
p.PutToInvalid(bl, "compare failed")
|
||||||
p.outputCh <- bl
|
|
||||||
continue
|
|
||||||
} else if base, ok := p.baselines[bl.Status]; ok && base.Compare(bl) == 1 {
|
|
||||||
bl.IsValid = false
|
|
||||||
bl.IsFuzzy = true
|
|
||||||
p.outputCh <- bl
|
|
||||||
p.fuzzyCh <- bl
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
bl.Collect()
|
bl.Collect()
|
||||||
// todo fuzzy compare
|
for _, f := range bl.Frameworks {
|
||||||
if p.base.FuzzyCompare(bl) {
|
if f.Tag == "waf/cdn" {
|
||||||
bl.IsValid = false
|
p.PutToInvalid(bl, "waf")
|
||||||
bl.IsFuzzy = true
|
continue Loop
|
||||||
p.outputCh <- bl
|
}
|
||||||
p.fuzzyCh <- bl
|
}
|
||||||
|
|
||||||
|
if base, ok := p.baselines[bl.Status]; ok && base.FuzzyCompare(bl) {
|
||||||
|
p.PutToInvalid(bl, "fuzzy compare failed")
|
||||||
|
p.PutToFuzzy(bl)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,6 +306,17 @@ func (p *Pool) addFuzzyBaseline(bl *pkg.Baseline) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Pool) PutToInvalid(bl *pkg.Baseline, reason string) {
|
||||||
|
bl.IsValid = false
|
||||||
|
bl.Reason = reason
|
||||||
|
p.outputCh <- bl
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pool) PutToFuzzy(bl *pkg.Baseline) {
|
||||||
|
bl.IsFuzzy = true
|
||||||
|
p.fuzzyCh <- bl
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Pool) resetFailed() {
|
func (p *Pool) resetFailed() {
|
||||||
p.failedCount = 0
|
p.failedCount = 0
|
||||||
p.failedBaselines = nil
|
p.failedBaselines = nil
|
||||||
|
@ -2,10 +2,11 @@ package pkg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/chainreactors/gogo/v2/pkg/fingers"
|
"github.com/chainreactors/gogo/v2/pkg/fingers"
|
||||||
|
"github.com/chainreactors/parsers"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Frameworks []*fingers.Framework
|
type Frameworks []*parsers.Framework
|
||||||
|
|
||||||
func (fs Frameworks) ToString() string {
|
func (fs Frameworks) ToString() string {
|
||||||
frameworkStrs := make([]string, len(fs))
|
frameworkStrs := make([]string, len(fs))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user