Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 9c6c0a856b7575aa1d544d813cd3ea58a171edff Author: Duco van Amstel <duco.vanamstel@gmail.com> Date: Wed Dec 05 23:40:55 2018 +0000 Enable gosec linter (#645) diff --git a/.golangci.yaml b/.golangci.yaml index eafe55d..ac3f34b 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1787 +1786 @@ linters: - errcheck - gochecknoglobals - gocyclo - - gosec - lll - maligned - prealloc diff --git a/gateway/gateway.go b/gateway/gateway.go index 2874ef2..0ee7a61 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -27 +27 @@ package gateway    import (   "bytes" - "crypto/sha1" + "crypto/sha1" //nolint:gosec   "fmt"   "io/ioutil"   "net/http" @@ -4667 +4667 @@ func (gw *Gateway) handleFiles(msg *config.Message) {   fi.Name = reg.ReplaceAllString(fi.Name, "_")   fi.Name += ext   - sha1sum := fmt.Sprintf("%x", sha1.Sum(*fi.Data))[:8] + sha1sum := fmt.Sprintf("%x", sha1.Sum(*fi.Data))[:8] //nolint:gosec     if gw.BridgeValues().General.MediaServerUpload != "" {   // Use MediaServerUpload. Upload using a PUT HTTP request and basicauth. diff --git a/hook/rockethook/rockethook.go b/hook/rockethook/rockethook.go index 063be74..1ac8cb0 100644 --- a/hook/rockethook/rockethook.go +++ b/hook/rockethook/rockethook.go @@ -387 +387 @@ type Config struct {  func New(url string, config Config) *Client {   c := &Client{In: make(chan Message), Config: config}   tr := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}, + TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}, //nolint:gosec   }   c.httpclient = &http.Client{Transport: tr}   _, _, err := net.SplitHostPort(c.BindAddress) diff --git a/matterclient/helpers.go b/matterclient/helpers.go index 74936ab..0549731 100644 --- a/matterclient/helpers.go +++ b/matterclient/helpers.go @@ -17 +17 @@  package matterclient    import ( - "crypto/md5" + "crypto/md5" //nolint:gosec   "crypto/tls"   "errors"   "fmt" @@ -1017 +10110 @@ func (m *MMClient) initClient(firstConnection bool, b *backoff.Backoff) error {   }   // login to mattermost   m.Client = model.NewAPIv4Client(uriScheme + m.Credentials.Server) - m.Client.HttpClient.Transport = &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}, Proxy: http.ProxyFromEnvironment} + m.Client.HttpClient.Transport = &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}, //nolint:gosec + Proxy: http.ProxyFromEnvironment, + }   m.Client.HttpClient.Timeout = time.Second * 10     // handle MMAUTHTOKEN and personal token @@ -2067 +20910 @@ func (m *MMClient) wsConnect() {     m.log.Debugf("WsClient: making connection: %s", wsurl)   for { - wsDialer := &websocket.Dialer{Proxy: http.ProxyFromEnvironment, TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}} + wsDialer := &websocket.Dialer{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}, //nolint:gosec + Proxy: http.ProxyFromEnvironment, + }   var err error   m.WsClient, _, err = wsDialer.Dial(wsurl, header)   if err != nil { @@ -2735 +2795 @@ func supportedVersion(version string) bool {  }    func digestString(s string) string { - return fmt.Sprintf("%x", md5.Sum([]byte(s))) + return fmt.Sprintf("%x", md5.Sum([]byte(s))) //nolint:gosec  } diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go index f602ed4..f513311 100644 --- a/matterhook/matterhook.go +++ b/matterhook/matterhook.go @@ -717 +717 @@ type Config struct {  func New(url string, config Config) *Client {   c := &Client{Url: url, In: make(chan IMessage), Out: make(chan OMessage), Config: config}   tr := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}, + TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}, //nolint:gosec   }   c.httpclient = &http.Client{Transport: tr}   if !c.DisableServer {