Skip to content

Commit

Permalink
Merge pull request #1494 from cyberark/gosec-fixes
Browse files Browse the repository at this point in the history
Fix gosec warnings
  • Loading branch information
gl-johnson authored Apr 19, 2023
2 parents b5ea7d2 + bad836d commit e4e080b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions bin/juxtaposer/tester/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (manager *DriverManager) ensureWantedDbDataState() error {
insertItemStatement := QueryTypes["insertItem"] +
fmt.Sprintf("(%s)", manager.Tester.GetQueryMarkers(5))

/* #nosec */
err = manager.Tester.Query(insertItemStatement,
fmt.Sprintf("%s%d", NameFieldPrefix, itemIndex),
itemIndex,
Expand Down
18 changes: 10 additions & 8 deletions internal/plugin/connectors/http/generic/oauth/v1/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package oauth1protocol
import (
"bytes"
"crypto/hmac"
"crypto/rand"
"crypto/sha1"
"encoding/base64"
"fmt"
"io/ioutil"
"math/rand"
"math/big"
gohttp "net/http"
"net/url"
"sort"
Expand Down Expand Up @@ -71,14 +72,15 @@ var requiredConfigParams = []string{
}

func generateNonce(length int, charset string) string {
seededRand := rand.New(
rand.NewSource(time.Now().UnixNano()))

randomChars := make([]byte, length)
for index := range randomChars {
randomChars[index] = charset[seededRand.Intn(len(charset))]
randomBytes := make([]byte, length)
for i := 0; i < length; i++ {
n, err := rand.Int(rand.Reader, big.NewInt(int64(len(charset))))
if err != nil {
panic(err)
}
randomBytes[i] = charset[n.Int64()]
}
return string(randomChars)
return string(randomBytes)
}

// checkRequiredOAuthParams returns an error if a key from
Expand Down
3 changes: 2 additions & 1 deletion internal/plugin/connectors/http/proxy_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ func NewProxyService(

transport := &gohttp.Transport{
TLSClientConfig: &tls.Config{
RootCAs: caCertPool,
RootCAs: caCertPool,
MinVersion: tls.VersionTLS12,
},
}

Expand Down
5 changes: 4 additions & 1 deletion test/connector/http/generic/http_test_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ func httpsServer(
return nil, err
}

config := &tls.Config{Certificates: []tls.Certificate{cert}}
config := &tls.Config{
Certificates: []tls.Certificate{cert},
MinVersion: tls.VersionTLS12,
}
s.TLS = config

s.StartTLS()
Expand Down
2 changes: 1 addition & 1 deletion third_party/go-mssqldb
Submodule go-mssqldb updated 1 files
+2 −0 tds.go

0 comments on commit e4e080b

Please sign in to comment.