Harden scan robustness and tests

This commit is contained in:
ZacharyZcR
2026-06-14 22:23:48 +08:00
parent 5ad914a1bb
commit c49c23c7f0
100 changed files with 4483 additions and 412 deletions
+6
View File
@@ -5,6 +5,7 @@ package services
import (
"strings"
"testing"
"unicode/utf8"
)
func TestTFTPReadRequestAndResponse(t *testing.T) {
@@ -18,4 +19,9 @@ func TestTFTPReadRequestAndResponse(t *testing.T) {
if !ok || !strings.Contains(banner, "not found") {
t.Fatalf("unexpected tftp banner: %q ok=%v", banner, ok)
}
banner, ok = parseTFTPResponse(append([]byte{0x00, 0x05, 0x00, 0x01}, []byte(strings.Repeat("界", 165))...))
if !ok || !utf8.ValidString(banner) || !strings.HasSuffix(banner, "...") {
t.Fatalf("unexpected tftp utf8 banner: %q ok=%v", banner, ok)
}
}