cossacklabs / acra

Database security suite. Database proxy with field-level encryption, search through encrypted data, SQL injections prevention, intrusion detection, honeypots. Supports client-side and proxy-side ("transparent") encryption. SQL, NoSQL.
https://www.cossacklabs.com/acra/
Apache License 2.0
1.34k stars 128 forks source link

Do not abort connection after encoding error in postgresql #537

Closed G1gg1L3s closed 2 years ago

G1gg1L3s commented 2 years ago

This PR implement skipping postgres packets from database after encoding error, almost in the same way as the previous PR does for mysql. It also adds a bunch of tests for different cases:

The only issue with postgres is that a state of transaction is stored at database side, and changes in case of some errors (even parsing ones). When the state is changed, commit is basically rollback:

test=# begin;
BEGIN
test=*# select 1/0;
ERROR:  division by zero
test=!# commit;
ROLLBACK

But our error will not trigger that:

test=# begin;
BEGIN
test=*# select value_bytes from testtype;
ERROR:  encoding error in column "value_bytes"
test=# commit;
COMMIT

So, for now I will mention it in the docs. Currently there is no straight and simple solution.

P.S. test.py crossed the milestone of 10 thousands lines, so my congratulations! It takes 5 second for my formatter to proceed the file. That's what I call success.

Checklist