Harden scan robustness and tests

This commit is contained in:
ZacharyZcR
2026-06-13 07:55:37 +08:00
parent 1595c92aed
commit 15a7670ba2
100 changed files with 4483 additions and 412 deletions
+17
View File
@@ -0,0 +1,17 @@
//go:build plugin_telnet || !plugin_selective
package services
import (
"strings"
"testing"
"unicode/utf8"
)
func TestTelnetExtractEvidenceTruncatesByRune(t *testing.T) {
p := NewTelnetPlugin()
got := p.extractEvidence("CMD_START\n" + strings.Repeat("界", 105) + "\nCMD_END")
if !utf8.ValidString(got) || len([]rune(got)) != 103 || !strings.HasSuffix(got, "...") {
t.Fatalf("extractEvidence() = %q", got)
}
}