Skip to content

Commit e4e080b

Browse files
authored
Merge pull request #1494 from cyberark/gosec-fixes
Fix gosec warnings
2 parents b5ea7d2 + bad836d commit e4e080b

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

bin/juxtaposer/tester/db/db.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (manager *DriverManager) ensureWantedDbDataState() error {
7777
insertItemStatement := QueryTypes["insertItem"] +
7878
fmt.Sprintf("(%s)", manager.Tester.GetQueryMarkers(5))
7979

80+
/* #nosec */
8081
err = manager.Tester.Query(insertItemStatement,
8182
fmt.Sprintf("%s%d", NameFieldPrefix, itemIndex),
8283
itemIndex,

internal/plugin/connectors/http/generic/oauth/v1/protocol.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package oauth1protocol
33
import (
44
"bytes"
55
"crypto/hmac"
6+
"crypto/rand"
67
"crypto/sha1"
78
"encoding/base64"
89
"fmt"
910
"io/ioutil"
10-
"math/rand"
11+
"math/big"
1112
gohttp "net/http"
1213
"net/url"
1314
"sort"
@@ -71,14 +72,15 @@ var requiredConfigParams = []string{
7172
}
7273

7374
func generateNonce(length int, charset string) string {
74-
seededRand := rand.New(
75-
rand.NewSource(time.Now().UnixNano()))
76-
77-
randomChars := make([]byte, length)
78-
for index := range randomChars {
79-
randomChars[index] = charset[seededRand.Intn(len(charset))]
75+
randomBytes := make([]byte, length)
76+
for i := 0; i < length; i++ {
77+
n, err := rand.Int(rand.Reader, big.NewInt(int64(len(charset))))
78+
if err != nil {
79+
panic(err)
80+
}
81+
randomBytes[i] = charset[n.Int64()]
8082
}
81-
return string(randomChars)
83+
return string(randomBytes)
8284
}
8385

8486
// checkRequiredOAuthParams returns an error if a key from

internal/plugin/connectors/http/proxy_service.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ func NewProxyService(
9797

9898
transport := &gohttp.Transport{
9999
TLSClientConfig: &tls.Config{
100-
RootCAs: caCertPool,
100+
RootCAs: caCertPool,
101+
MinVersion: tls.VersionTLS12,
101102
},
102103
}
103104

test/connector/http/generic/http_test_server.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ func httpsServer(
8585
return nil, err
8686
}
8787

88-
config := &tls.Config{Certificates: []tls.Certificate{cert}}
88+
config := &tls.Config{
89+
Certificates: []tls.Certificate{cert},
90+
MinVersion: tls.VersionTLS12,
91+
}
8992
s.TLS = config
9093

9194
s.StartTLS()

third_party/go-mssqldb

Submodule go-mssqldb updated 1 file

0 commit comments

Comments
 (0)