From 6fe2b1cede37aa0238cccaf761a0305d00236134 Mon Sep 17 00:00:00 2001 From: M09Ic Date: Fri, 11 Nov 2022 11:55:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96compare=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pool.go | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/internal/pool.go b/internal/pool.go index 6d51f3a..6ecb0ed 100644 --- a/internal/pool.go +++ b/internal/pool.go @@ -274,30 +274,35 @@ func (p *Pool) BaseCompare(bl *pkg.Baseline) { p.OutputCh <- bl return } - var status int - base, ok := p.baselines[bl.Status] - if !ok { + var status = -1 + base, ok := p.baselines[bl.Status] // 挑选对应状态码的baseline进行compare + if !ok && p.base.Status == bl.Status { + // 当other的状态码与base相同时, 会使用base + ok = true base = p.base } - // 挑选对应状态码的baseline进行compare - if status = base.Compare(bl); status == 1 { - p.PutToInvalid(bl, "compare failed") - return - } - - bl.Collect() - for _, f := range bl.Frameworks { - if f.Tag == "waf/cdn" { - p.PutToInvalid(bl, "waf") + if ok { + if status = base.Compare(bl); status == 1 { + p.PutToInvalid(bl, "compare failed") return } } - if status == 0 && base.FuzzyCompare(bl) { - p.PutToInvalid(bl, "fuzzy compare failed") - p.PutToFuzzy(bl) - return + if status == 0 { + bl.Collect() + for _, f := range bl.Frameworks { + if f.Tag == "waf/cdn" { + p.PutToInvalid(bl, "waf") + return + } + } + + if ok && base.FuzzyCompare(bl) { + p.PutToInvalid(bl, "fuzzy compare failed") + p.PutToFuzzy(bl) + return + } } p.OutputCh <- bl