mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-22 08:10:26 +00:00
Enable gosec linter (#645)
This commit is contained in:
parent
8a7efce941
commit
af7a00d030
@ -178,7 +178,6 @@ linters:
|
|||||||
- errcheck
|
- errcheck
|
||||||
- gochecknoglobals
|
- gochecknoglobals
|
||||||
- gocyclo
|
- gocyclo
|
||||||
- gosec
|
|
||||||
- lll
|
- lll
|
||||||
- maligned
|
- maligned
|
||||||
- prealloc
|
- prealloc
|
||||||
|
@ -2,7 +2,7 @@ package gateway
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha1"
|
"crypto/sha1" //nolint:gosec
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -466,7 +466,7 @@ func (gw *Gateway) handleFiles(msg *config.Message) {
|
|||||||
fi.Name = reg.ReplaceAllString(fi.Name, "_")
|
fi.Name = reg.ReplaceAllString(fi.Name, "_")
|
||||||
fi.Name += ext
|
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 != "" {
|
if gw.BridgeValues().General.MediaServerUpload != "" {
|
||||||
// Use MediaServerUpload. Upload using a PUT HTTP request and basicauth.
|
// Use MediaServerUpload. Upload using a PUT HTTP request and basicauth.
|
||||||
|
@ -38,7 +38,7 @@ type Config struct {
|
|||||||
func New(url string, config Config) *Client {
|
func New(url string, config Config) *Client {
|
||||||
c := &Client{In: make(chan Message), Config: config}
|
c := &Client{In: make(chan Message), Config: config}
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}, //nolint:gosec
|
||||||
}
|
}
|
||||||
c.httpclient = &http.Client{Transport: tr}
|
c.httpclient = &http.Client{Transport: tr}
|
||||||
_, _, err := net.SplitHostPort(c.BindAddress)
|
_, _, err := net.SplitHostPort(c.BindAddress)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package matterclient
|
package matterclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5" //nolint:gosec
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -101,7 +101,10 @@ func (m *MMClient) initClient(firstConnection bool, b *backoff.Backoff) error {
|
|||||||
}
|
}
|
||||||
// login to mattermost
|
// login to mattermost
|
||||||
m.Client = model.NewAPIv4Client(uriScheme + m.Credentials.Server)
|
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
|
m.Client.HttpClient.Timeout = time.Second * 10
|
||||||
|
|
||||||
// handle MMAUTHTOKEN and personal token
|
// handle MMAUTHTOKEN and personal token
|
||||||
@ -206,7 +209,10 @@ func (m *MMClient) wsConnect() {
|
|||||||
|
|
||||||
m.log.Debugf("WsClient: making connection: %s", wsurl)
|
m.log.Debugf("WsClient: making connection: %s", wsurl)
|
||||||
for {
|
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
|
var err error
|
||||||
m.WsClient, _, err = wsDialer.Dial(wsurl, header)
|
m.WsClient, _, err = wsDialer.Dial(wsurl, header)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -273,5 +279,5 @@ func supportedVersion(version string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func digestString(s string) string {
|
func digestString(s string) string {
|
||||||
return fmt.Sprintf("%x", md5.Sum([]byte(s)))
|
return fmt.Sprintf("%x", md5.Sum([]byte(s))) //nolint:gosec
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ type Config struct {
|
|||||||
func New(url string, config Config) *Client {
|
func New(url string, config Config) *Client {
|
||||||
c := &Client{Url: url, In: make(chan IMessage), Out: make(chan OMessage), Config: config}
|
c := &Client{Url: url, In: make(chan IMessage), Out: make(chan OMessage), Config: config}
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}, //nolint:gosec
|
||||||
}
|
}
|
||||||
c.httpclient = &http.Client{Transport: tr}
|
c.httpclient = &http.Client{Transport: tr}
|
||||||
if !c.DisableServer {
|
if !c.DisableServer {
|
||||||
|
Loading…
Reference in New Issue
Block a user