Use correct nmap filters 83/107383/1
authorPawel Wieczorek <p.wieczorek2@samsung.com>
Wed, 22 Apr 2020 15:41:29 +0000 (17:41 +0200)
committerPawel Wieczorek <p.wieczorek2@samsung.com>
Fri, 8 May 2020 11:41:44 +0000 (13:41 +0200)
Both closed and filtered ports should be droppped from scan results to
maintain compatibility with "check_for_nonssl_endpoints.sh" script.

Issue-ID: SECCOM-261
Change-Id: Ic422bebf6e46bcc42a3e5198e7702bb8b901287f
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
test/security/sslendpoints/main.go

index 38950c4..331979e 100644 (file)
@@ -7,6 +7,7 @@ import (
        "os"
        "path/filepath"
        "strconv"
+       "strings"
 
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
        "k8s.io/client-go/kubernetes"
@@ -123,7 +124,16 @@ func main() {
                nmap.WithServiceInfo(),
                nmap.WithTimingTemplate(nmap.TimingAggressive),
                nmap.WithFilterPort(func(p nmap.Port) bool {
-                       return p.Service.Tunnel == "ssl"
+                       if p.Service.Tunnel == "ssl" {
+                               return false
+                       }
+                       if strings.HasPrefix(p.State.State, "closed") {
+                               return false
+                       }
+                       if strings.HasPrefix(p.State.State, "filtered") {
+                               return false
+                       }
+                       return true
                }),
        )
        if err != nil {