Files
ARTEX/db/asset_dsl_limit_test.go
T
Coff0xc 16b04cfb48 fix(db): bound asset DSL length and parenthesis depth
ParseDSL recursed on every '(' with no depth or size cap, so a
query of nested parentheses could grow the goroutine stack until
the process died. Cap input at 4 KiB and nesting at 32.
2026-11-19 14:25:04 +01:00

24 lines
609 B
Go

package db
import (
"strings"
"testing"
)
func TestParseDSLRejectsDeepNesting(t *testing.T) {
deep := strings.Repeat("(", dslMaxDepth+1) + "a" + strings.Repeat(")", dslMaxDepth+1)
if _, err := ParseDSL(deep); err == nil {
t.Fatal("deep nesting accepted")
}
ok := strings.Repeat("(", dslMaxDepth) + "a" + strings.Repeat(")", dslMaxDepth)
if _, err := ParseDSL(ok); err != nil {
t.Fatalf("depth %d refused: %v", dslMaxDepth, err)
}
}
func TestParseDSLRejectsOversize(t *testing.T) {
if _, err := ParseDSL(strings.Repeat("a", dslMaxLen+1)); err == nil {
t.Fatal("oversize query accepted")
}
}