Skip to content

Bound the database pool size before converting it to int32 [skip deploy] #no-deploy - #5

Merged
SebastianLopezO merged 1 commit into
mainfrom
security/codeql/incorrect-integer-conversion
Nov 1, 2026
Merged

SebastianLopezO merged 1 commit into
mainfrom
security/codeql/incorrect-integer-conversion

Conversation

@SebastianLopezO

Copy link
Copy Markdown
Member

Caso

  • Origen: CodeQL, alerta #6
    go/incorrect-integer-conversion en cmd/api/main.go:70.
  • Severidad: alta (según la regla).
  • Problema: DATABASE_MAX_CONNS se leía con strconv.Atoi (entero del tamaño de la arquitectura) y se convertía a
    int32 sin cota superior: un valor grande se desbordaba en silencio y el pool quedaba con un máximo negativo o
    arbitrario.

Cambio

  • postgres.Connect recibe int y rechaza valores mayores que MaxPoolConns (1000) con un mensaje claro antes de
    convertir.
  • Pruebas: el valor desmedido se rechaza y uno válido llega intacto a la configuración de pgxpool.

Verificación

  • gofmt, go vet y go test ./... en verde.

@SebastianLopezO
SebastianLopezO force-pushed the security/codeql/incorrect-integer-conversion branch from 0b7bc1d to bab66df Compare November 1, 2026 03:44
@SebastianLopezO
SebastianLopezO merged commit 13cfb36 into main Nov 1, 2026
6 of 7 checks passed
@SebastianLopezO
SebastianLopezO deleted the security/codeql/incorrect-integer-conversion branch November 1, 2026 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant