mirror of
https://github.com/projectdiscovery/nuclei
synced 2026-06-08 16:50:47 +00:00
50e3131d86
Clone the data map before modification to prevent race conditions when multiple goroutines call evaluateVarsWithInteractsh concurrently with a shared map. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
33 lines
631 B
Go
33 lines
631 B
Go
package fuzz
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/protocols"
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/interactsh"
|
|
)
|
|
|
|
func TestEvaluateVarsWithInteractsh_RaceCondition(t *testing.T) {
|
|
rule := &Rule{}
|
|
rule.options = &protocols.ExecutorOptions{
|
|
Interactsh: &interactsh.Client{},
|
|
}
|
|
|
|
sharedData := map[string]interface{}{
|
|
"var1": "value1",
|
|
"var2": "{{var1}}_suffix",
|
|
"var3": "prefix_{{var1}}",
|
|
}
|
|
|
|
var wg sync.WaitGroup
|
|
for i := 0; i < 10; i++ {
|
|
wg.Add(1)
|
|
go func() {
|
|
defer wg.Done()
|
|
rule.evaluateVarsWithInteractsh(sharedData, nil)
|
|
}()
|
|
}
|
|
wg.Wait()
|
|
}
|