Skip to content

Commit a1b37a1

Browse files
author
Your Name
committed
remove lint
1 parent 1ade859 commit a1b37a1

File tree

5 files changed

+25
-36
lines changed

5 files changed

+25
-36
lines changed

pkg/stage/port.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func ScanUDPPort(ip string, port int) bool {
141141
}
142142

143143
// 设置读写超时
144-
conn.SetDeadline(time.Now().Add(3 * time.Second))
144+
_ = conn.SetDeadline(time.Now().Add(3 * time.Second))
145145

146146
// 发送探测包
147147
_, err = conn.Write(probe)

pkg/stage/scanner.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ func (s *Scanner) processResults(node *Node, resultsChan chan ServiceInfo) {
322322
osSet[result.OS] = struct{}{}
323323
node.OS = result.OS
324324
}
325-
if result.vendor != "" {
326-
vendorSet[result.vendor] = struct{}{}
327-
node.vendor = result.vendor
325+
if result.Vendor != "" {
326+
vendorSet[result.Vendor] = struct{}{}
327+
node.Vendor = result.Vendor
328328
}
329329
if result.Devicetype != "" {
330330
devicetypeSet[result.Devicetype] = struct{}{}

pkg/stage/service.go

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ type Fingerprint struct {
4848
URL []string `json:"url"`
4949
Devicetype string `json:"devicetype,omitempty"` // 硬件类型: router, printer, camera, nas, server 等
5050
Tags []string `json:"tags,omitempty"` // 服务标签: database, webserver, monitoring 等
51-
vendor string `json:"vendor,omitempty"`
51+
Vendor string `json:"vendor,omitempty"`
5252
Ports []int `json:"ports,omitempty"`
5353
}
5454

5555
// RawFingerprint represents a raw service fingerprint
5656
type RawFingerprint struct {
5757
Devicetype string `json:"devicetype,omitempty"` // 硬件类型
5858
Tags []string `json:"tags,omitempty"` // 服务标签
59-
vendor string `json:"vendor,omitempty"`
59+
Vendor string `json:"vendor,omitempty"`
6060
OS string `json:"os,omitempty"` // 操作系统
6161
Patterns []string `json:"patterns"`
6262
}
@@ -70,7 +70,7 @@ type ServiceAnalyzer interface {
7070
type PortFingerprint struct {
7171
Devicetype string `json:"devicetype,omitempty"` // 硬件类型
7272
Tags []string `json:"tags,omitempty"` // 服务标签
73-
vendor string `json:"vendor,omitempty"`
73+
Vendor string `json:"vendor,omitempty"`
7474
OS string `json:"os,omitempty"`
7575
}
7676

@@ -443,8 +443,8 @@ func (sd *ServiceDetector) checkURL(url string, port int) *ServiceInfo {
443443
if portFp.Devicetype != "" {
444444
info.Devicetype = portFp.Devicetype
445445
}
446-
if portFp.vendor != "" {
447-
info.vendor = portFp.vendor
446+
if portFp.Vendor != "" {
447+
info.Vendor = portFp.Vendor
448448
}
449449
if portFp.OS != "" {
450450
info.OS = portFp.OS
@@ -594,8 +594,8 @@ func (sd *ServiceDetector) matchFingerprint(ctx *detectionContext) *ServiceInfo
594594
if info.Devicetype == "" && fingerprint.Devicetype != "" {
595595
info.Devicetype = fingerprint.Devicetype
596596
}
597-
if info.vendor == "" && fingerprint.vendor != "" {
598-
info.vendor = fingerprint.vendor
597+
if info.Vendor == "" && fingerprint.Vendor != "" {
598+
info.Vendor = fingerprint.Vendor
599599
}
600600
}
601601
}
@@ -761,8 +761,8 @@ func (sd *ServiceDetector) detectTCP(ip string, port int) []ServiceInfo {
761761

762762
// 针对特定端口发送探测包
763763
if probe, exists := tcpProbes[port]; exists && len(probe) > 0 {
764-
conn.SetWriteDeadline(time.Now().Add(3 * time.Second))
765-
conn.Write(probe)
764+
_ = conn.SetWriteDeadline(time.Now().Add(3 * time.Second))
765+
_, _ = conn.Write(probe)
766766
// 发送后等待一小会儿让服务响应
767767
time.Sleep(200 * time.Millisecond)
768768
}
@@ -798,7 +798,7 @@ func (sd *ServiceDetector) detectTCP(ip string, port int) []ServiceInfo {
798798
info := ServiceInfo{
799799
Types: []string{name},
800800
Banner: cleanedBanner,
801-
vendor: fp.vendor,
801+
Vendor: fp.Vendor,
802802
Devicetype: fp.Devicetype,
803803
OS: fp.OS,
804804
}
@@ -829,7 +829,7 @@ func (sd *ServiceDetector) detectTCP(ip string, port int) []ServiceInfo {
829829
info.Types = append(info.Types, portFp.Tags...)
830830
}
831831
info.Devicetype = portFp.Devicetype
832-
info.vendor = portFp.vendor
832+
info.Vendor = portFp.Vendor
833833
info.OS = portFp.OS
834834
}
835835

@@ -936,7 +936,7 @@ func (sd *ServiceDetector) detectUDP(ip string, port int) []ServiceInfo {
936936
info := ServiceInfo{
937937
Types: []string{name},
938938
Banner: cleanedBanner,
939-
vendor: fp.vendor,
939+
Vendor: fp.Vendor,
940940
Devicetype: fp.Devicetype,
941941
OS: fp.OS,
942942
}
@@ -967,7 +967,7 @@ func (sd *ServiceDetector) detectUDP(ip string, port int) []ServiceInfo {
967967
info.Types = append(info.Types, portFp.Tags...)
968968
}
969969
info.Devicetype = portFp.Devicetype
970-
info.vendor = portFp.vendor
970+
info.Vendor = portFp.Vendor
971971
info.OS = portFp.OS
972972
}
973973

@@ -1014,7 +1014,6 @@ func (sd *ServiceDetector) detectOS(info ServiceInfo) string {
10141014
func (sd *ServiceDetector) detectOSFromBanner(banner string) string {
10151015
lowerBanner := strings.ToLower(banner)
10161016

1017-
10181017
if strings.Contains(lowerBanner, "ubuntu") {
10191018
return "ubuntu"
10201019
}
@@ -1046,7 +1045,6 @@ func (sd *ServiceDetector) detectOSFromBanner(banner string) string {
10461045
return "raspbian"
10471046
}
10481047

1049-
10501048
if strings.Contains(lowerBanner, "freebsd") {
10511049
return "freebsd"
10521050
}
@@ -1057,7 +1055,6 @@ func (sd *ServiceDetector) detectOSFromBanner(banner string) string {
10571055
return "netbsd"
10581056
}
10591057

1060-
10611058
if strings.Contains(lowerBanner, "cisco") {
10621059
if strings.Contains(lowerBanner, "ios-xe") || strings.Contains(lowerBanner, "ios xe") {
10631060
return "cisco-ios-xe"
@@ -1074,42 +1071,35 @@ func (sd *ServiceDetector) detectOSFromBanner(banner string) string {
10741071
return "cisco-ios"
10751072
}
10761073

1077-
10781074
if strings.Contains(lowerBanner, "huawei") || strings.Contains(lowerBanner, "vrp") {
10791075
return "huawei-vrp"
10801076
}
10811077

1082-
10831078
if strings.Contains(lowerBanner, "comware") || strings.Contains(lowerBanner, "h3c") {
10841079
return "h3c-comware"
10851080
}
10861081

1087-
10881082
if strings.Contains(lowerBanner, "junos") || strings.Contains(lowerBanner, "juniper") {
10891083
return "juniper-junos"
10901084
}
10911085

1092-
10931086
if strings.Contains(lowerBanner, "fortigate") || strings.Contains(lowerBanner, "fortios") {
10941087
return "fortinet-fortios"
10951088
}
10961089

1097-
10981090
if strings.Contains(lowerBanner, "pan-os") || strings.Contains(lowerBanner, "palo alto") {
10991091
return "paloalto-panos"
11001092
}
11011093

1102-
1094+
//nolint:misspell // routeros is the correct product name
11031095
if strings.Contains(lowerBanner, "mikrotik") || strings.Contains(lowerBanner, "routeros") {
1104-
return "mikrotik-routeros"
1096+
return "mikrotik-routeros" //nolint:misspell
11051097
}
11061098

1107-
11081099
if strings.Contains(lowerBanner, "arista") || strings.Contains(lowerBanner, "eos") {
11091100
return "arista-eos"
11101101
}
11111102

1112-
11131103
if strings.Contains(lowerBanner, "ruijie") || strings.Contains(lowerBanner, "锐捷") {
11141104
return "ruijie"
11151105
}
@@ -1150,7 +1140,6 @@ func (sd *ServiceDetector) detectOSFromBanner(banner string) string {
11501140
return "citrix-netscaler"
11511141
}
11521142

1153-
11541143
if strings.Contains(lowerBanner, "linux") {
11551144
return "linux"
11561145
}
@@ -1199,7 +1188,7 @@ func (sd *ServiceDetector) detectOSFromHTTP(info ServiceInfo) string {
11991188
return "fortinet-fortios"
12001189
}
12011190
if strings.Contains(lowerServer, "mikrotik") {
1202-
return "mikrotik-routeros"
1191+
return "mikrotik-routeros" // nolint:misspell
12031192
}
12041193
}
12051194

@@ -1580,8 +1569,8 @@ func (sd *ServiceDetector) updateServiceInfoFromLua(info *ServiceInfo, tbl *lua.
15801569
if v := tbl.RawGetString("OS"); v != lua.LNil {
15811570
info.OS = v.String()
15821571
}
1583-
if v := tbl.RawGetString("vendor"); v != lua.LNil {
1584-
info.vendor = v.String()
1572+
if v := tbl.RawGetString("Vendor"); v != lua.LNil {
1573+
info.Vendor = v.String()
15851574
}
15861575
if v := tbl.RawGetString("Devicetype"); v != lua.LNil {
15871576
info.Devicetype = v.String()

pkg/stage/ttl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func getPingTTL(ip string) int {
9292

9393
select {
9494
case <-time.After(3 * time.Second):
95-
cmd.Process.Kill()
95+
_ = cmd.Process.Kill()
9696
return -1
9797
case err := <-done:
9898
if err != nil {

pkg/stage/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Node struct {
1212
Ports []*ServiceInfo `json:"ports,omitempty"`
1313
PortsHistory []*ServiceInfo `json:"ports_history,omitempty"`
1414
PortsHistoryDesc []string `json:"ports_history_desc,omitempty"`
15-
vendor string `json:"vendor,omitempty"`
15+
Vendor string `json:"vendor,omitempty"`
1616
Devicetype string `json:"devicetype,omitempty"`
1717
Model string `json:"model,omitempty"`
1818
SensitiveInfo []string `json:"sensitive_info,omitempty"`
@@ -57,7 +57,7 @@ type ServiceInfo struct {
5757
Banner string `json:"banner,omitempty"`
5858
Headers map[string]string `json:"headers,omitempty"`
5959
OS string `json:"os,omitempty"`
60-
vendor string `json:"vendor,omitempty"`
60+
Vendor string `json:"vendor,omitempty"`
6161
Devicetype string `json:"devicetype,omitempty"`
6262
Extra map[string]string `json:"extra,omitempty"`
6363
SensitiveInfo []string `json:"sensitive_info,omitempty"`

0 commit comments

Comments
 (0)