Skip to content

Commit af0c249

Browse files
M09Icclaude
andcommitted
fix: prevent fuzzy-failed results from leaking to stdout and output file
- Set bl.IsValid=false before putToFuzzy snapshot in BaseCompare, so the snapshot no longer passes the IsValid check in Output() - Gate file output on the same condition as console output: bl.IsValid || (r.Fuzzy && bl.IsFuzzy) - Bump deps: utils, utils/parsers, fingers (types migrated to parsers) - Remove local replace directives Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4e84549 commit af0c249

17 files changed

Lines changed: 61 additions & 48 deletions

core/baseline/baseline.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"github.com/chainreactors/fingers/common"
66
"github.com/chainreactors/logs"
7-
"github.com/chainreactors/parsers"
7+
"github.com/chainreactors/utils/parsers"
88
"github.com/chainreactors/spray/core/ihttp"
99
"github.com/chainreactors/spray/pkg"
1010
"github.com/chainreactors/utils/encode"

core/baseline/baseline_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package baseline
22

33
import (
44
"fmt"
5-
"github.com/chainreactors/parsers"
5+
"github.com/chainreactors/utils/parsers"
66
"github.com/chainreactors/words/rule"
77
"github.com/expr-lang/expr"
88
"io/ioutil"

core/pool/brutepool.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"github.com/chainreactors/logs"
8-
"github.com/chainreactors/parsers"
8+
"github.com/chainreactors/utils/parsers"
99
"github.com/chainreactors/spray/core/baseline"
1010
"github.com/chainreactors/spray/core/ihttp"
1111
"github.com/chainreactors/spray/pkg"
@@ -821,6 +821,7 @@ func (pool *BrutePool) BaseCompare(bl *baseline.Baseline) bool {
821821

822822
if ok && status == 0 && pool.sameDefaultResponse(base, bl) {
823823
pool.Statistor.FuzzyNumber++
824+
bl.IsValid = false
824825
bl.Reason = pkg.ErrFuzzyCompareFailed.Error()
825826
pool.putToFuzzy(bl)
826827
return false

core/pool/checkpool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"fmt"
66
"github.com/chainreactors/logs"
7-
"github.com/chainreactors/parsers"
7+
"github.com/chainreactors/utils/parsers"
88
"github.com/chainreactors/spray/core/baseline"
99
"github.com/chainreactors/spray/core/ihttp"
1010
"github.com/chainreactors/spray/pkg"

core/pool/pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package pool
22

33
import (
44
"context"
5-
"github.com/chainreactors/parsers"
5+
"github.com/chainreactors/utils/parsers"
66
"github.com/chainreactors/spray/core/baseline"
77
"github.com/chainreactors/spray/core/ihttp"
88
"github.com/chainreactors/spray/pkg"

core/pool/pool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"time"
1212

1313
"github.com/chainreactors/fingers/common"
14-
"github.com/chainreactors/parsers"
14+
"github.com/chainreactors/utils/parsers"
1515
"github.com/chainreactors/spray/core/baseline"
1616
"github.com/chainreactors/spray/core/ihttp"
1717
"github.com/chainreactors/spray/pkg"

core/pool/type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package pool
22

33
import (
4-
"github.com/chainreactors/parsers"
4+
"github.com/chainreactors/utils/parsers"
55
"github.com/chainreactors/spray/core/baseline"
66
)
77

core/run_with_args.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/chainreactors/files"
1111
"github.com/chainreactors/logs"
12+
"github.com/chainreactors/utils/parsers"
1213
"github.com/chainreactors/spray/core/ihttp"
1314
"github.com/chainreactors/spray/pkg"
1415
"github.com/chainreactors/utils/iutils"
@@ -21,6 +22,7 @@ type RunOptions struct {
2122
Version string
2223
BeforePrepare func(*Option) error
2324
AfterPrepare func(*Option) error
25+
OnResult func(*parsers.SprayResult)
2426
}
2527

2628
func Help() string {
@@ -157,7 +159,10 @@ func RunWithArgs(ctx context.Context, args []string, opts RunOptions) error {
157159
return err
158160
}
159161
defer runner.CloseFiles()
160-
if option.ReadAll {
162+
if opts.OnResult != nil {
163+
runner.ResultCallback = opts.OnResult
164+
}
165+
if option.ReadAll || runner.CrawlPlugin {
161166
ihttp.DefaultMaxBodySize = -1
162167
}
163168

core/runner.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/chainreactors/files"
1111
"github.com/chainreactors/logs"
12+
"github.com/chainreactors/utils/parsers"
1213
"github.com/chainreactors/proxyclient"
1314
"github.com/chainreactors/spray/core/baseline"
1415
"github.com/chainreactors/spray/core/ihttp"
@@ -71,10 +72,11 @@ type Runner struct {
7172
Probes []string
7273
Total int // wordlist total number
7374
Color bool
74-
Jsonify bool
75-
statsMu sync.Mutex
76-
stats RunnerStats
77-
outputMu sync.Mutex
75+
Jsonify bool
76+
ResultCallback func(*parsers.SprayResult)
77+
statsMu sync.Mutex
78+
stats RunnerStats
79+
outputMu sync.Mutex
7880
}
7981

8082
func (r *Runner) Stats() RunnerStats {
@@ -510,7 +512,7 @@ func (r *Runner) Output(bl *baseline.Baseline) {
510512
}
511513
}
512514

513-
if r.OutputFile != nil {
515+
if r.OutputFile != nil && (bl.IsValid || (r.Fuzzy && bl.IsFuzzy)) {
514516
if r.FileOutput == "json" {
515517
r.OutputFile.SafeWrite(bl.ToJson() + "\n")
516518
} else if r.FileOutput == "csv" {
@@ -538,6 +540,9 @@ func (r *Runner) OutputHandler() {
538540
r.DumpFile.SafeSync()
539541
}
540542
if bl.IsValid {
543+
if r.ResultCallback != nil && bl.SprayResult != nil {
544+
r.ResultCallback(bl.SprayResult)
545+
}
541546
r.Output(bl)
542547
if bl.Recu {
543548
r.AddRecursive(bl)

go.mod

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ go 1.25.4
44

55
require (
66
github.com/chainreactors/files v0.0.0-20240716182835-7884ee1e77f0
7-
github.com/chainreactors/fingers v1.2.1-0.20260608084741-385e7d586d6f
7+
github.com/chainreactors/fingers v1.2.1-0.20260629043342-2229ee623248
88
github.com/chainreactors/logs v0.0.0-20260624034259-9aaea4aa52cc
9-
github.com/chainreactors/neutron v0.0.0-20260608084636-c81691731908
10-
github.com/chainreactors/parsers v0.0.0-20260608085142-3d2c51baa8fe
9+
github.com/chainreactors/neutron v0.0.0-20260612092850-1a0a5a8b4280
1110
github.com/chainreactors/proton v0.2.1-0.20260608085216-03df34ba928d
1211
github.com/chainreactors/proxyclient v1.1.1-0.20260529172347-2a80e08d5593
13-
github.com/chainreactors/utils v0.0.0-20260529172343-6465cb8568b2
12+
github.com/chainreactors/utils v0.0.0-20260629043228-93bdd2142c9a
13+
github.com/chainreactors/utils/parsers v0.0.0-20260629043228-93bdd2142c9a
1414
github.com/chainreactors/words v0.0.0-20260520145736-270600e60fb4
1515
github.com/charmbracelet/lipgloss v1.1.0
1616
github.com/expr-lang/expr v1.16.9
1717
github.com/gookit/config/v2 v2.2.5
1818
github.com/imroc/req/v3 v3.57.0
1919
github.com/jessevdk/go-flags v1.6.1
2020
github.com/panjf2000/ants/v2 v2.9.1
21+
github.com/refraction-networking/utls v1.8.1
2122
github.com/valyala/fasthttp v1.53.0
2223
github.com/vbauerster/mpb/v8 v8.7.3
2324
golang.org/x/time v0.12.0
@@ -26,7 +27,7 @@ require (
2627

2728
require (
2829
dario.cat/mergo v1.0.0 // indirect
29-
github.com/Knetic/govaluate v3.0.0+incompatible // indirect
30+
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
3031
github.com/STARRY-S/zip v0.2.3 // indirect
3132
github.com/VividCortex/ewma v1.2.0 // indirect
3233
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
@@ -79,7 +80,6 @@ require (
7980
github.com/pkg/errors v0.9.1 // indirect
8081
github.com/quic-go/qpack v0.6.0 // indirect
8182
github.com/quic-go/quic-go v0.57.1 // indirect
82-
github.com/refraction-networking/utls v1.8.1 // indirect
8383
github.com/rivo/uniseg v0.4.7 // indirect
8484
github.com/sorairolake/lzip-go v0.3.8 // indirect
8585
github.com/spaolacci/murmur3 v1.1.0 // indirect
@@ -103,6 +103,5 @@ require (
103103
golang.org/x/term v0.39.0 // indirect
104104
golang.org/x/text v0.33.0 // indirect
105105
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
106-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
107106
gopkg.in/yaml.v3 v3.0.1 // indirect
108107
)

0 commit comments

Comments
 (0)