perf: Cap RANDOM_STRING_N to 8182 (#1193)
This commit is contained in:
@@ -295,7 +295,7 @@ You may use the following placeholders in the body (`endpoints[].body`):
|
|||||||
- `[ENDPOINT_GROUP]` (resolved from `endpoints[].group`)
|
- `[ENDPOINT_GROUP]` (resolved from `endpoints[].group`)
|
||||||
- `[ENDPOINT_URL]` (resolved from `endpoints[].url`)
|
- `[ENDPOINT_URL]` (resolved from `endpoints[].url`)
|
||||||
- `[LOCAL_ADDRESS]` (resolves to the local IP and port like `192.0.2.1:25` or `[2001:db8::1]:80`)
|
- `[LOCAL_ADDRESS]` (resolves to the local IP and port like `192.0.2.1:25` or `[2001:db8::1]:80`)
|
||||||
- `[RANDOM_STRING_N]` (resolves to a random string of numbers and letters of length N)
|
- `[RANDOM_STRING_N]` (resolves to a random string of numbers and letters of length N (max: 8192))
|
||||||
|
|
||||||
|
|
||||||
### External Endpoints
|
### External Endpoints
|
||||||
|
|||||||
@@ -344,6 +344,9 @@ func (e *Endpoint) getParsedBody() string {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
body = randRegex.ReplaceAllStringFunc(body, func(match string) string {
|
body = randRegex.ReplaceAllStringFunc(body, func(match string) string {
|
||||||
n, _ := strconv.Atoi(match[15 : len(match)-1])
|
n, _ := strconv.Atoi(match[15 : len(match)-1])
|
||||||
|
if n > 8192 {
|
||||||
|
n = 8192 // Limit the length of the random string to 8192 bytes to avoid excessive memory usage
|
||||||
|
}
|
||||||
const availableCharacterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
const availableCharacterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
b := make([]byte, n)
|
b := make([]byte, n)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
|
|||||||
Reference in New Issue
Block a user