diff options
author | Wim <wim@42.be> | 2021-12-19 14:39:24 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2021-12-19 14:39:24 +0100 |
commit | 8f7ab280e2ea4011ad3c495d7ef843d82dec2be5 (patch) | |
tree | 931b7b1f5dd7332e180e989cca88c83f12624c79 /hook/rockethook/rockethook.go | |
parent | dbedc994216fa2e932f1aefd3ea27832419b85ef (diff) | |
download | matterbridge-msglm-8f7ab280e2ea4011ad3c495d7ef843d82dec2be5.tar.gz matterbridge-msglm-8f7ab280e2ea4011ad3c495d7ef843d82dec2be5.tar.bz2 matterbridge-msglm-8f7ab280e2ea4011ad3c495d7ef843d82dec2be5.zip |
Fix codeql warnings
Diffstat (limited to 'hook/rockethook/rockethook.go')
-rw-r--r-- | hook/rockethook/rockethook.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/hook/rockethook/rockethook.go b/hook/rockethook/rockethook.go index 1ac8cb02..38f53e4a 100644 --- a/hook/rockethook/rockethook.go +++ b/hook/rockethook/rockethook.go @@ -7,6 +7,7 @@ import ( "log" "net" "net/http" + "regexp" ) // Message for rocketchat outgoing webhook. @@ -68,7 +69,6 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) { } msg := Message{} body, err := ioutil.ReadAll(r.Body) - log.Println(string(body)) if err != nil { log.Println(err) http.NotFound(w, r) @@ -89,7 +89,11 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) { msg.ChannelName = "#" + msg.ChannelName if c.Token != "" { if msg.Token != c.Token { - log.Println("invalid token " + msg.Token + " from " + r.RemoteAddr) + if regexp.MustCompile(`[^a-zA-Z0-9]+`).MatchString(msg.Token) { + log.Println("invalid token " + msg.Token + " from " + r.RemoteAddr) + } else { + log.Println("invalid token from " + r.RemoteAddr) + } http.NotFound(w, r) return } |