From ae31e7f24921740d5ca818ffee7389b3c92ca1a9 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Thu, 5 Jul 2018 18:18:31 -0400 Subject: [PATCH] test and fix Signed-off-by: Jess Frazelle --- k8scan/main.go | 4 ++-- k8scan/main_test.go | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 k8scan/main_test.go diff --git a/k8scan/main.go b/k8scan/main.go index 02bc8c5..5977d4c 100644 --- a/k8scan/main.go +++ b/k8scan/main.go @@ -143,7 +143,7 @@ func isKubernetesDashboard(ip string, port int) bool { } body := strings.ToLower(string(b)) - if strings.Contains(body, "kubernetes") || + if (strings.Contains(body, "kubernetes") && strings.Contains(body, "pod")) || (strings.Contains(body, "versions") && strings.Contains(body, "serverAddress")) { logrus.Infof("uri: %s", uri) return true @@ -157,7 +157,7 @@ type ARINResponse struct { } type NetJSON struct { - Organization OrganizationJSON `json:"orgReg,omitempty"` + Organization OrganizationJSON `json:"orgRef,omitempty"` } type OrganizationJSON struct { diff --git a/k8scan/main_test.go b/k8scan/main_test.go new file mode 100644 index 0000000..aa7dd0d --- /dev/null +++ b/k8scan/main_test.go @@ -0,0 +1,20 @@ +package main + +import "testing" + +func TestARINResponse(t *testing.T) { + info, err := getIPInfo("104.40.92.107") + if err != nil { + t.Fatal(err) + } + + if info.Net.Organization.Handle != "MSFT" { + t.Fatalf("expected handle to be MSFT, got %s", info.Net.Organization.Handle) + } + if info.Net.Organization.Name != "Microsoft Corporation" { + t.Fatalf("expected handle to be Microsoft Corporation, got %s", info.Net.Organization.Name) + } + if info.Net.Organization.Reference != "https://whois.arin.net/rest/org/MSFT" { + t.Fatalf("expected reference to be https://whois.arin.net/rest/org/MSFT, got %s", info.Net.Organization.Reference) + } +}