chore(gosec): enable gosec and address findings

This commit is contained in:
Hein
2026-09-30 13:16:12 +02:00
parent 9533c3a0ed
commit f66930c3c9
37 changed files with 133 additions and 122 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ func (p *MongoProvider) Connect(ctx context.Context, cfg ConnectionConfig) error
// Set connection pool size
if cfg.GetMaxOpenConns() != nil {
maxPoolSize := uint64(*cfg.GetMaxOpenConns())
maxPoolSize := uint64(*cfg.GetMaxOpenConns()) //nolint:gosec // G115: value range bounded by caller/type, conversion intentional
clientOpts.SetMaxPoolSize(maxPoolSize)
}
+1 -1
View File
@@ -68,7 +68,7 @@ func (p *MSSQLProvider) Connect(ctx context.Context, cfg ConnectionConfig) error
if err != nil {
lastErr = err
db.Close()
db.Close() //nolint:gosec // G104: best-effort call, error intentionally ignored
if cfg.GetEnableLogging() {
logger.Warn("Failed to ping MSSQL database: %v", err)
}
+1 -1
View File
@@ -59,7 +59,7 @@ func (c *pgConnector) Connect(ctx context.Context) (driver.Conn, error) {
}
sc, ok := conn.(*stdlib.Conn)
if !ok {
conn.Close()
conn.Close() //nolint:gosec // G104: best-effort call, error intentionally ignored
return nil, fmt.Errorf("unexpected pgx driver connection type %T", conn)
}
return &pgConn{Conn: sc, owner: c, gen: st.gen}, nil
+2 -2
View File
@@ -55,7 +55,7 @@ func (p *PostgresProvider) Connect(ctx context.Context, cfg ConnectionConfig) er
select {
case <-time.After(delay):
case <-ctx.Done():
db.Close()
db.Close() //nolint:gosec // G104: best-effort call, error intentionally ignored
return ctx.Err()
}
}
@@ -78,7 +78,7 @@ func (p *PostgresProvider) Connect(ctx context.Context, cfg ConnectionConfig) er
}
if !connected {
db.Close()
db.Close() //nolint:gosec // G104: best-effort call, error intentionally ignored
return fmt.Errorf("failed to connect after %d attempts: %w", retryAttempts, lastErr)
}
+1 -1
View File
@@ -62,7 +62,7 @@ func (p *SQLiteProvider) Connect(ctx context.Context, cfg ConnectionConfig) erro
cancel()
if err != nil {
db.Close()
db.Close() //nolint:gosec // G104: best-effort call, error intentionally ignored
return fmt.Errorf("failed to ping SQLite database: %w", err)
}