@@ -93,11 +93,13 @@ func (sra *ServiceAuthentication) initialPorts(ports []v1.ServicePort) {
93
93
94
94
func (sra * ServiceAuthentication ) Discover (ctx context.Context , scansWg * sync.WaitGroup , antsPool * ants.Pool , client dynamic.NamespaceableResourceInterface ) {
95
95
96
+ // get all ports , each port equal different address
96
97
for _ , pr := range sra .spec .ports {
97
98
if slices .Contains (protocolFilter , string (pr .protocol )) {
98
99
continue
99
100
}
100
101
102
+ //use DNS name to scan - this is the most reliable way to scan
101
103
srvDnsName := sra .metadata .name + "." + sra .metadata .namespace
102
104
103
105
scansWg .Add (1 )
@@ -113,8 +115,8 @@ func (sra *ServiceAuthentication) Discover(ctx context.Context, scansWg *sync.Wa
113
115
logger .L ().Ctx (ctx ).Error (structuredErr .Error ())
114
116
return
115
117
}
116
- _ , deleteErr := client .Namespace (sra .metadata .namespace ).Apply (context .TODO (), sra .metadata .name , serviceObj , metav1.ApplyOptions {FieldManager : FieldManager })
117
118
119
+ _ , deleteErr := client .Namespace (sra .metadata .namespace ).Apply (context .TODO (), sra .metadata .name , serviceObj , metav1.ApplyOptions {FieldManager : FieldManager })
118
120
if deleteErr != nil {
119
121
logger .L ().Ctx (ctx ).Error (deleteErr .Error ())
120
122
}
@@ -128,11 +130,13 @@ func (port *Port) Scan(ctx context.Context, ip string) {
128
130
port .authenticated = result .IsAuthenticated
129
131
130
132
if result .ApplicationLayer == "" {
133
+ // if we can't get the application layer, then we change to Unknown
131
134
port .applicationLayer = "Unknown"
132
135
port .authenticated = true
133
136
}
134
137
135
138
if err != nil {
139
+ //if we have an error, we log it and set all layers to Unknown
136
140
logger .L ().Ctx (ctx ).Error (err .Error ())
137
141
result .ApplicationLayer = "Unknown"
138
142
result .PresentationLayer = "Unknown"
@@ -142,6 +146,8 @@ func (port *Port) Scan(ctx context.Context, ip string) {
142
146
}
143
147
144
148
func (csl currentServiceList ) deleteServices (ctx context.Context , client dynamic.NamespaceableResourceInterface ) error {
149
+ // get all services from the current cycle and compare them with the current CRDs
150
+
145
151
authServices , err := client .List (context .TODO (), metav1.ListOptions {})
146
152
if err != nil {
147
153
return err
0 commit comments