mirror of
https://github.com/kyverno/kyverno.git
synced 2025-01-20 18:52:16 +00:00
25 lines
541 B
Go
25 lines
541 B
Go
|
package fuzz
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
|
||
|
fuzz "github.com/AdaLogics/go-fuzz-headers"
|
||
|
)
|
||
|
|
||
|
func GetK8sString(ff *fuzz.ConsumeFuzzer) (string, error) {
|
||
|
allowedChars := []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.")
|
||
|
stringLength, err := ff.GetInt()
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
var sb strings.Builder
|
||
|
for i := 0; i < stringLength%63; i++ {
|
||
|
charIndex, err := ff.GetInt()
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
sb.WriteString(string(allowedChars[charIndex%len(allowedChars)]))
|
||
|
}
|
||
|
return sb.String(), nil
|
||
|
}
|