mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-10-01 12:31:59 +00:00
chore(gosec): enable gosec and address findings
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user