Skip to content

Commit 8063480

Browse files
committed
added protocol to the network service names
1 parent 1b760f5 commit 8063480

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

engine/plugins/service_discovery/http_probes/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (hp *httpProbing) query(e *et.Event, entity *dbt.Entity, target string, por
112112

113113
func (hp *httpProbing) store(e *et.Event, resp *amasshttp.Response, entity *dbt.Entity, port int) []*support.Finding {
114114
addr := entity.Asset.Key()
115-
serv := support.ServiceWithIdentifier(addr, port)
115+
serv := support.ServiceWithIdentifier(addr, "tcp", port)
116116

117117
serv.Type = "web-service"
118118
serv.Output = resp.Body

engine/plugins/support/normalization.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package support
77
import (
88
"crypto/x509"
99
"encoding/hex"
10+
"fmt"
1011
"hash/fnv"
1112
"net/url"
1213
"strconv"
@@ -201,12 +202,10 @@ func TimeToJSONString(t *time.Time) string {
201202
return t.UTC().Format("2006-01-02T15:04:05Z07:00")
202203
}
203204

204-
func ServiceWithIdentifier(address string, port int) *oamplat.Service {
205-
pstr := strconv.Itoa(port)
206-
name := address + ":" + pstr
207-
hashstr := Hash64Hex(name)
205+
func ServiceWithIdentifier(address, protocol string, port int) *oamplat.Service {
206+
name := fmt.Sprintf("%s:%s:%d", address, strings.ToLower(protocol), port)
208207

209-
return &oamplat.Service{ID: name + ":" + hashstr}
208+
return &oamplat.Service{ID: name + "-" + Hash64Hex(name)}
210209
}
211210

212211
func Hash64Hex(s string) string {

0 commit comments

Comments
 (0)