mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-26 05:01:53 +08:00
Harden scan robustness and tests
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
|
||||
package services
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func TestParseZooKeeperResponse(t *testing.T) {
|
||||
banner, ok := parseZooKeeperResponse([]byte("imok"))
|
||||
@@ -13,4 +17,10 @@ func TestParseZooKeeperResponse(t *testing.T) {
|
||||
if _, ok := parseZooKeeperResponse([]byte("hello")); ok {
|
||||
t.Fatal("unexpected match for non-zookeeper response")
|
||||
}
|
||||
|
||||
longResp := "zk_version\t" + strings.Repeat("界", 205)
|
||||
banner, ok = parseZooKeeperResponse([]byte(longResp))
|
||||
if !ok || !utf8.ValidString(banner) || len([]rune(banner)) != 203 {
|
||||
t.Fatalf("zookeeper truncation = %q ok=%v", banner, ok)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user