getanteon / anteon

Anteon (formerly Ddosify) - Effortless Kubernetes Monitoring and Performance Testing. Available on CLI, Self-Hosted, and Cloud
https://getanteon.com
GNU Affero General Public License v3.0
8.44k stars 384 forks source link

Go random generator crashes when "heavily" using {{_randomString}} #121

Closed H25E closed 1 year ago

H25E commented 1 year ago

I'm doing some testing with your software. On a test with 1650 POSTS requests per second, where on the body of the request {{_randomString}} it's used twice, I get the following output after a few minutes:

✔️  Successful Run: 570695  99%       ❌ Failed Run: 61       1%       ⏱️  Avg. Duration: 0.47102s
panic: runtime error: index out of range [-1]

goroutine 4020490 [running]:
math/rand.(*rngSource).Uint64(...)
        /opt/hostedtoolcache/go/1.18.9/x64/src/math/rand/rng.go:249
math/rand.(*rngSource).Int63(0xc008ef2cf8?)
        /opt/hostedtoolcache/go/1.18.9/x64/src/math/rand/rng.go:234 +0x92
math/rand.(*Rand).Int63(...)
        /opt/hostedtoolcache/go/1.18.9/x64/src/math/rand/rand.go:84
math/rand.(*Rand).Int31(...)
        /opt/hostedtoolcache/go/1.18.9/x64/src/math/rand/rand.go:98
math/rand.(*Rand).Int31n(0xc000279110, 0x1a)
        /opt/hostedtoolcache/go/1.18.9/x64/src/math/rand/rand.go:133 +0x59
math/rand.(*Rand).Intn(0x0?, 0x0?)
        /opt/hostedtoolcache/go/1.18.9/x64/src/math/rand/rand.go:171 +0x2e
github.com/ddosify/go-faker/faker.Faker.IntBetween({0x0?}, 0x61, 0x0?)
        /home/runner/go/pkg/mod/github.com/ddosify/go-faker@v0.1.1/faker/faker.go:652 +0x57
github.com/ddosify/go-faker/faker.Faker.RandomLetter({0x1?})
        /home/runner/go/pkg/mod/github.com/ddosify/go-faker@v0.1.1/faker/faker.go:634 +0x25
github.com/ddosify/go-faker/faker.Faker.RandomStringWithLength({0x0?}, 0xa)
        /home/runner/go/pkg/mod/github.com/ddosify/go-faker@v0.1.1/faker/faker.go:628 +0x76
github.com/ddosify/go-faker/faker.Faker.RandomString({0x2?})
        /home/runner/go/pkg/mod/github.com/ddosify/go-faker@v0.1.1/faker/faker.go:622 +0x1e
reflect.Value.call({0x746840?, 0xc0002d6600?, 0x1000000003002?}, {0x7b5c7d, 0x4}, {0x0, 0x0, 0x2?})
        /opt/hostedtoolcache/go/1.18.9/x64/src/reflect/value.go:556 +0x845
reflect.Value.Call({0x746840?, 0xc0002d6600?, 0xc0000a9546?}, {0x0, 0x0, 0x0})
        /opt/hostedtoolcache/go/1.18.9/x64/src/reflect/value.go:339 +0xbf
go.ddosify.com/ddosify/core/scenario/scripting/injection.(*EnvironmentInjector).getFakeData(0xc0000a9543?, {0xc0000a9546, 0xc})
        /home/runner/work/ddosify/ddosify/core/scenario/scripting/injection/environment.go:37 +0xde
go.ddosify.com/ddosify/core/scenario/scripting/injection.(*EnvironmentInjector).InjectDynamic.func1({0xc0000a9543, 0x11})
        /home/runner/work/ddosify/ddosify/core/scenario/scripting/injection/environment.go:138 +0x73
regexp.(*Regexp).ReplaceAllStringFunc.func1({0xc0095cc650, 0x3, 0x8}, {0xc0095cc640?, 0xc002a00400?, 0x0?})
        /opt/hostedtoolcache/go/1.18.9/x64/src/regexp/regexp.go:602 +0x91
regexp.(*Regexp).replaceAll(0xc0002a3ea0, {0x0, 0x0, 0x0}, {0xc0000a9540, 0x34}, 0x2, 0xc008ef3750)
        /opt/hostedtoolcache/go/1.18.9/x64/src/regexp/regexp.go:640 +0x3ee
regexp.(*Regexp).ReplaceAllStringFunc(0xc006f645c0?, {0xc0000a9540?, 0x40?}, 0x3?)
        /opt/hostedtoolcache/go/1.18.9/x64/src/regexp/regexp.go:601 +0x5d
go.ddosify.com/ddosify/core/scenario/scripting/injection.(*EnvironmentInjector).InjectDynamic(0xc0002ba940, {0xc0000a9540, 0x34})
        /home/runner/work/ddosify/ddosify/core/scenario/scripting/injection/environment.go:191 +0x157
go.ddosify.com/ddosify/core/scenario/requester.(*HttpRequester).prepareReq(0xc0000d56c0, 0x0?, 0xc0095cc5f8?)
        /home/runner/work/ddosify/ddosify/core/scenario/requester/http.go:307 +0x105
go.ddosify.com/ddosify/core/scenario/requester.(*HttpRequester).Send(0xc0000d56c0, 0xc0078e6db0)
        /home/runner/work/ddosify/ddosify/core/scenario/requester/http.go:191 +0x1b7
go.ddosify.com/ddosify/core/scenario.(*ScenarioService).Do(0xc0002c4ee0, 0x0, {0x0?, 0xc00034a420?, 0xbc7c00?})
        /home/runner/work/ddosify/ddosify/core/scenario/service.go:119 +0x3e2
go.ddosify.com/ddosify/core.(*engine).runWorker(0xc000360000, {0x0?, 0xc00ad671a0?, 0xbc7c00?})
        /home/runner/work/ddosify/ddosify/core/engine.go:159 +0xe5
go.ddosify.com/ddosify/core.(*engine).runWorkers.func1({0xc003e677d0?, 0x646806?, 0xbc7c00?})
        /home/runner/work/ddosify/ddosify/core/engine.go:146 +0x33
created by go.ddosify.com/ddosify/core.(*engine).runWorkers
        /home/runner/work/ddosify/ddosify/core/engine.go:145 +0x2e

Tested on debian 11.

kursataktas commented 1 year ago

Hi @H25E

Could you please share the full cli command or config file

H25E commented 1 year ago
{
        "iteration_count": 5000000,
        "duration": 3000,
        "steps": [
                {
                        "id": 1,
                        "url": "https://something.com/",
                        "name": "bad login",
                        "method": "POST",
                        "payload": "id={{_randomString}}&pwd={{_randomString}}&some_other_static_stuff",
                        "headers": {
                                "Accept": "*/*",
                                "Accept-Encoding": "gzip, deflate, br",
                                "Accept-Language": "en-US,en;q=0.5",
                                "Cache-Control": "no-cache",
                                "Connection": "close",
                                "Content-Length": "64",
                                "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
                                "Host": "something.com",
                                "Origin": "https://something.com",
                                "Pragma": "no-cache",
                                "Referer": "https://another.com/",
                                "Sec-Fetch-Dest": "empty",
                                "Sec-Fetch-Mode": "cors",
                                "Sec-Fetch-Site": "same-site",
                                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/109.0"
                        }
                }
        ],
        "others": {
                "keep-alive": false,
                "disable-compression": false,
                "h2": true
        }
}
kursataktas commented 1 year ago

Thank you, We will investigate the issue and update this thread as soon as possible

fatihbaltaci commented 1 year ago

Hi @H25E, this is solved in the latest version of Ddosify. Thanks for reporting this issue. We're closing this now, but please don't hesitate to reopen if it happens again.