4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-26 03:59:25 +00:00

Fix codeql warnings

This commit is contained in:
Wim
2021-12-19 14:39:24 +01:00
parent dbedc99421
commit 8f7ab280e2
3 changed files with 8 additions and 4 deletions

View File

@ -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
}