googleapis / googleapis/ruby-cloud-env
Malformed identity JWT encoding raises instead of expiring the cached token
- Lenguaje dominante
- Ruby
- Estrellas
- 16
- Forks
- 12
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
## Summary
`ComputeMetadata#determine_identity_lifetime` rescues malformed JSON, but not malformed URL-safe Base64 in the JWT payload. A metadata response containing an invalid encoded payload therefore raises `ArgumentError` while deciding its cache lifetime instead of treating the token as immediately expired.
## Reproduction
On current `main` (`7936c72eb2c809214858f47473aafb04c6bbf469`), calling the private lifetime calculation with an identity path and a token whose middle segment is invalid URL-safe Base64 raises `ArgumentError` from `Base64.urlsafe_decode64`.
## Proposed correction
Handle `ArgumentError` alongside the existing malformed-JSON behavior and return a zero lifetime. I verified the two-line rescue against malformed padding/characters, the full current suite (91 runs / 419 assertions / 0 failures / 0 errors / 2 skips), and the normal valid-token lifetime path.
I used an AI coding assistant during investigation and verification. I am opening this issue first because this repository requires tests and a Google CLA for pull requests; I have not modified repository tests or signed a CLA as part of this audit.
Guía de contribución
Línea de trabajo
Comienza con ComputeMetadata#determine_identity_lifetime y reproduce el caso de Base64 URL-safe no válido descrito en el issue. Comprueba el manejo existente del JSON malformado y verifica que los payloads JWT malformados produzcan una duración de cero sin cambiar la ruta de duración de los tokens válidos. Confirma que la suite de pruebas relevante siga pasando.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- ruby
- Área
- cloud
- Tipo de issue
- Error
- Dificultad
- 1/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Activo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 78/100