Skip to content

Commit

Permalink
fix gosec issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWeindel committed Oct 16, 2024
1 parent c8522d5 commit a98da07
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion pkg/controller/provider/openstack/designateclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ func createDesignateServiceClient(logger logger.LogContext, clientAuthConfig *cl
return nil, err
}

tlscfg := &tls.Config{}
tlscfg := &tls.Config{
MinVersion: tls.VersionTLS12,
}

if clientAuthConfig.CACert != "" {
caCertPool := x509.NewCertPool()
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/provider/powerdns/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func newHttpClient(insecureSkipVerify bool, trustedCaCert string) *http.Client {

if insecureSkipVerify {
httpClient.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // #nosec G402 -- InsecureSkipVerify is used to allow insecure connections
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/provider/remote/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (h *Handler) loadTLSCredentials(serverCA_PEM, clientCert_PEM, clientKey_PEM

// Create the credentials and return it
config := &tls.Config{
MinVersion: tls.VersionTLS12,
Certificates: []tls.Certificate{clientCert},
}

Expand All @@ -138,7 +139,7 @@ func (h *Handler) loadTLSCredentials(serverCA_PEM, clientCert_PEM, clientKey_PEM
func (h *Handler) Release() {
h.cache.Release()
if h.connection != nil {
h.connection.Close()
_ = h.connection.Close()
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/dns/provider/state_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (this *state) HandleUpdateEntry(logger logger.LogContext, op string, object
old := this.entries[object.ObjectName()]
if old != nil {
if !old.lock.TryLockSpinning(10 * time.Millisecond) {
millis := time.Millisecond * time.Duration(3000+rand.Int31n(3000))
millis := time.Millisecond * time.Duration(3000+rand.Int31n(3000)) // #nosec G404 -- not used for cryptographic purposes
return reconcile.RescheduleAfter(logger, millis)
}
defer old.lock.Unlock()
Expand Down
1 change: 1 addition & 0 deletions pkg/server/remote/embed/dynamictransportcreds.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (d *dynamicTransportCredentials) updateTLS(secret *corev1.Secret) {

func (d *dynamicTransportCredentials) createTLS(secret *corev1.Secret) (credentials.TransportCredentials, bool) {
config := &tls.Config{
MinVersion: tls.VersionTLS12,
Certificates: []tls.Certificate{},
ClientAuth: tls.RequireAndVerifyClientCert,
ClientCAs: d.certPool,
Expand Down
4 changes: 2 additions & 2 deletions test/functional/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func InitConfig() *Config {
}

func LoadConfig(filename string) (*Config, error) {
f, err := os.Open(filename)
f, err := os.Open(filename) // #nosec G304 -- only used during tests to read test configuration
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -175,7 +175,7 @@ func (p *ProviderConfig) TTLValue() int {

func (p *ProviderConfig) CreateTempManifest(basePath, testName string, manifestTemplate *template.Template) (string, error) {
filename := fmt.Sprintf("%s/tmp-%s-%s.yaml", basePath, p.Name, testName)
f, err := os.Create(filename)
f, err := os.Create(filename) // #nosec G304 -- only used during tests to write to a temp file
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion test/functional/config/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (u *TestUtils) AwaitLookupTXT(dnsname string, expected ...string) {
func RandStringBytes(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand.Intn(len(letterBytes))]
b[i] = letterBytes[rand.Intn(len(letterBytes))] // #nosec G404 -- not used for cryptographic purposes
}
return string(b)
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (te *TestEnv) ApplyCRDs(dir string) error {

// readDocuments reads documents from file.
func readDocuments(fp string) ([][]byte, error) {
b, err := os.ReadFile(fp)
b, err := os.ReadFile(fp) // #nosec G304 -- only used during tests to read test configuration
if err != nil {
return nil, err
}
Expand Down

0 comments on commit a98da07

Please sign in to comment.