From fd882c72e54f971eebcf8309731884e7077462fd Mon Sep 17 00:00:00 2001 From: Jose Carlos Luna <Jose.Carlos.Luna@cern.ch> Date: Tue, 14 May 2024 09:09:24 +0200 Subject: [PATCH] Token alerting & logging - Include Type of token in alerts - Remove lowercase type on logs, just keep the token alert type --- alert/alert.go | 3 +-- server/dns/dns.go | 1 + server/http/http.go | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/alert/alert.go b/alert/alert.go index e03904d..4ba3f81 100644 --- a/alert/alert.go +++ b/alert/alert.go @@ -25,6 +25,7 @@ type Canary struct { Key string Tag string Level string + Type string } type HTTPCanary struct { @@ -105,7 +106,6 @@ func PostSlackHook(message string) { func HTTPAlert(canaryinfo HTTPCanary, alertType string) { if alertType == "log" || alertType == "all" { slog.Info("token-alert", - "type", "token-alert", "Key", canaryinfo.Canary.Key, "Tag", canaryinfo.Canary.Tag, "Level", canaryinfo.Canary.Level, @@ -132,7 +132,6 @@ func HTTPAlert(canaryinfo HTTPCanary, alertType string) { func DNSAlert(canaryinfo DNSCanary, alertType string) { if alertType == "log" || alertType == "all" { slog.Info("token-alert", - "type", "token-alert", "Key", canaryinfo.Canary.Key, "Tag", canaryinfo.Canary.Tag, "Level", canaryinfo.Canary.Level, diff --git a/server/dns/dns.go b/server/dns/dns.go index bf2ec16..90b511f 100644 --- a/server/dns/dns.go +++ b/server/dns/dns.go @@ -27,6 +27,7 @@ func getCanaryInfo(t tokens.CanaryRecord, w dns.ResponseWriter) alert.DNSCanary Key: t.Key, Tag: t.Tag, Level: t.Level, + Type: "token-dns", }, RemoteAddr: w.RemoteAddr().String(), LocalAddr: w.LocalAddr().String(), diff --git a/server/http/http.go b/server/http/http.go index d40a203..3bf1a09 100644 --- a/server/http/http.go +++ b/server/http/http.go @@ -53,6 +53,7 @@ func getCanaryInfo(t tokens.CanaryRecord, r *http.Request) alert.HTTPCanary { Key: t.Key, Tag: t.Tag, Level: t.Level, + Type: "token-http", }, UserAgent: r.UserAgent(), FullUrl: getFullUrl(r), -- GitLab