From 5a884ca6ade38dc088f5c406b27ac56425c30e81 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Mon, 18 May 2026 17:59:00 +0800 Subject: [PATCH] fix lint issues before merge --- core/port_scan.go | 4 ++-- plugins/local/cleaner.go | 6 +++--- plugins/services/activemq.go | 2 +- plugins/services/cassandra.go | 5 +++-- plugins/services/mssql_raw.go | 1 - plugins/services/oracle_raw.go | 10 +++++++--- plugins/web/webtitle.go | 2 +- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/core/port_scan.go b/core/port_scan.go index db81b5d..3fbf7a6 100644 --- a/core/port_scan.go +++ b/core/port_scan.go @@ -421,10 +421,10 @@ func matchFold(a, b string) bool { // 格式: addr service [Product:xxx ||Version:xxx] Banner:(xxx) func buildServiceLogMessage(addr string, serviceInfo *ServiceInfo, isWeb bool) string { var msg strings.Builder - msg.WriteString(fmt.Sprintf("%-21s", addr)) + fmt.Fprintf(&msg, "%-21s", addr) if serviceInfo.Name != "unknown" { - msg.WriteString(fmt.Sprintf(" %-8s", serviceInfo.Name)) + fmt.Fprintf(&msg, " %-8s", serviceInfo.Name) } // 构建 [Product:xxx ||Version:xxx] 格式 diff --git a/plugins/local/cleaner.go b/plugins/local/cleaner.go index 4d4d317..1b7dea1 100644 --- a/plugins/local/cleaner.go +++ b/plugins/local/cleaner.go @@ -58,7 +58,7 @@ func (p *CleanerPlugin) cleanFiles(output *strings.Builder, dir string, names [] for _, name := range names { path := filepath.Join(dir, name) if err := os.Remove(path); err == nil { - output.WriteString(fmt.Sprintf("[清理] %s\n", path)) + fmt.Fprintf(output, "[清理] %s\n", path) cleaned++ } } @@ -70,7 +70,7 @@ func (p *CleanerPlugin) cleanGlob(output *strings.Builder, dir, pattern string) cleaned := 0 for _, f := range matches { if err := os.Remove(f); err == nil { - output.WriteString(fmt.Sprintf("[清理] %s\n", f)) + fmt.Fprintf(output, "[清理] %s\n", f) cleaned++ } } @@ -87,7 +87,7 @@ func (p *CleanerPlugin) cleanUnix(output *strings.Builder) int { } for _, hf := range histFiles { if p.scrubHistory(hf) { - output.WriteString(fmt.Sprintf("[清理] %s 中的 fscan 记录\n", hf)) + fmt.Fprintf(output, "[清理] %s 中的 fscan 记录\n", hf) cleaned++ } } diff --git a/plugins/services/activemq.go b/plugins/services/activemq.go index 02a2b5e..77374ab 100644 --- a/plugins/services/activemq.go +++ b/plugins/services/activemq.go @@ -229,7 +229,7 @@ func (p *ActiveMQPlugin) identifyService(ctx context.Context, info *common.HostI return &ScanResult{ Success: false, Service: "activemq", - Error: fmt.Errorf("Failed to read response: %w", err), + Error: fmt.Errorf("failed to read response: %w", err), } } if n == 0 { diff --git a/plugins/services/cassandra.go b/plugins/services/cassandra.go index 14427a3..dddbed6 100644 --- a/plugins/services/cassandra.go +++ b/plugins/services/cassandra.go @@ -169,9 +169,10 @@ var cqlStreamID int16 func cqlSend(conn net.Conn, opcode byte, body []byte) error { id := cqlStreamID - cqlStreamID++ - if cqlStreamID > 32767 { + if cqlStreamID == 32767 { cqlStreamID = 0 + } else { + cqlStreamID++ } // frame: [1B version|flags] [2B stream] [1B opcode] [4B length] [body] diff --git a/plugins/services/mssql_raw.go b/plugins/services/mssql_raw.go index 9c2e869..9ae00fd 100644 --- a/plugins/services/mssql_raw.go +++ b/plugins/services/mssql_raw.go @@ -323,7 +323,6 @@ func mssqlParseLoginTokens(payload []byte, result *mssqlRawResult) (bool, error) return false, fmt.Errorf("mssql: truncated done token") } status := binary.LittleEndian.Uint16(payload[pos : pos+2]) - pos += 12 return status&(tdsDoneError|tdsDoneSrvError) == 0, nil default: return false, fmt.Errorf("mssql: unexpected login token 0x%02x", token) diff --git a/plugins/services/oracle_raw.go b/plugins/services/oracle_raw.go index 48bb2bd..35d6a59 100644 --- a/plugins/services/oracle_raw.go +++ b/plugins/services/oracle_raw.go @@ -341,8 +341,13 @@ func (s *oracleSession) putString(v string) { func (s *oracleSession) putInt(v interface{}, size uint8, bigEndian, compress bool) { num := toInt64(v) if compress { + neg := num < 0 + encoded := uint64(num) + if neg { + encoded = uint64(-(num + 1)) + 1 + } temp := make([]byte, 8) - binary.BigEndian.PutUint64(temp, uint64(num)) + binary.BigEndian.PutUint64(temp, encoded) temp = bytes.TrimLeft(temp, "\x00") if size > uint8(len(temp)) { size = uint8(len(temp)) @@ -351,8 +356,7 @@ func (s *oracleSession) putInt(v interface{}, size uint8, bigEndian, compress bo s.out.WriteByte(0) return } - if num < 0 { - num = -num + if neg { size |= 0x80 } s.out.WriteByte(size) diff --git a/plugins/web/webtitle.go b/plugins/web/webtitle.go index d9258b6..9c6f69b 100644 --- a/plugins/web/webtitle.go +++ b/plugins/web/webtitle.go @@ -243,7 +243,7 @@ func (p *WebTitlePlugin) formatHeaders(headers http.Header) string { var builder strings.Builder for name, values := range headers { for _, value := range values { - builder.WriteString(fmt.Sprintf("%s: %s\n", name, value)) + fmt.Fprintf(&builder, "%s: %s\n", name, value) } } return builder.String()