Add error-path tests for HybridDecrypter.Decrypt in the crypto package
I maintainer di solito rispondono entro 2 giorni
@gangadhar-res ci sta già lavorando.
Dal 12/8/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
Inizia da Decrypt in hybrid.go e dal TestHybridEncryptDecrypt esistente, quindi esamina TestNewAESEncryptDecrypterInvalidKey e TestAESEncryptDecrypt per lo stile testify del package e la configurazione delle chiavi di testdata. Aggiungi la copertura per i cinque percorsi di errore elencati ed esegui i test del package crypto; il lavoro è completato quando base64 non valido, lunghezze malformate, manomissioni RSA e manomissioni AES-GCM restituiscono tutti degli errori.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What would you like to be added:
I'd like to add unit tests for the error paths in HybridDecrypter.Decrypt(). Right now the only test we have (TestHybridEncryptDecrypt) just tests the happy path — encrypt something valid, decrypt it back, make sure it matches. But the Decrypt function has around 5 different ways it can fail, and none of them are tested.
My plan is to add a table-driven test that covers:
- Passing in garbage that isn't valid base64
- Passing in data that's too short to even read the RSA length header
- Passing in data where the declared RSA length is bigger than what's actually there
- Tampering with the RSA ciphertext portion so RSA OAEP decryption fails
- Tampering with the AES-GCM ciphertext portion so the authentication check fails — this is the one that worries me most because if someone accidentally breaks that GCM auth check, tampered secrets would just pass through silently
I've already looked at how the rest of the crypto package does tests (TestNewAESEncryptDecrypterInvalidKey, TestAESEncryptDecrypt, etc.) and I'll match that same style — testify/require and testify/assert, same-package tests, reading keys from testdata/.
Why is this needed:
I was reading through hybrid.go and noticed the Decrypt function has quite a few places where it can return errors, but none of them have tests. The one that really stood out to me is the AES-GCM authentication check on line 143 (aed.Open). That's the function that verifies the ciphertext hasn't been tampered with. If someone accidentally broke that check in a refactor, we might not catch it because the only test just tests valid data.
Since this crypto code is what powers PipeCD's sealed secrets feature, I think it's worth having these tests in place. Better to catch a regression early than to have tampered secrets slip through.
If this approach aligns with what you had in mind, I can go ahead and put together the implementation. If you'd prefer a different structure or have additional cases you want covered, just let me know.... happy to adjust!
- Lingua principale
- Go
- Stelle
- 1.4k
- Fork
- 391
- Merge medio
- 4g 1h
- PR unite (30g)
- 58
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pipe-cd/pipecd
-
Applications at the repository root are not triggered by new commitsForse già presa @Daksha1611 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 2 giorni
-
pipedv1 kubernetes plugins ignore trafficRouting.istio.host in K8S_TRAFFIC_ROUTINGForse già presa @Dhirenderchoudhary l’ha presa oggi. Aperta
Difficoltà 2/5 Mezza giornata Idoneità per principianti 74/100
pipe-cd/pipecd#7626 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
pipectl transfer restore application drops backed-up labelsForse già presa @bhavishyajain545 l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
pipe-cd/pipecd#7622 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di pipe-cd/pipecd
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
docker-compose: postgres healthcheck should probe TCP (pg_isready -h localhost)Forse già presa @zezo-mohamed22 l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
OneBusAway/watchdog#305 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
self-care self-care:agent-discoverability
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
githubnext/gh-cao#20928 ·
I maintainer di solito rispondono entro 1 giorno
-
automation documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
SocialGouv/iterion#3287 ·
I maintainer di solito rispondono entro 1 giorno