clarus-proxy / proxy

The proxy component
Other
2 stars 3 forks source link

issue with quotes and encrypted values #17

Open tchevallier opened 6 years ago

tchevallier commented 6 years ago

when using the proxy for pgsql protocol with simple encryption data operation the query INSERT INTO "tbl" ("name","address") VALUES ('CAROMB','CAMPING COMMUNAL'); is transformed into INSERT INTO "tbl" (TVgZo6nAOf*YR4VzD4VFgw==_enc, Z20R5m5jYEeSdGiSekvAUw==_enc) VALUES ('9R3HoqGbM+i5rOryoNlTUA==', 'haINXTwvYwFgtk03bohWQFYuta7iUNumjGLBG/2gOZA=')

which raises an error in pgAdmin ERROR: syntax error at or near LINE 1: INSERT INTO "tbl" (TVgZo6nAOfYR4VzD4VFgw==_enc,

--> quotes were somewhat lost in the process

dieriver commented 6 years ago

I see three problems here. First, the SQL error is related with the "*" character in the protected table name. Second, the "/" char in the protected value. Third, the lost quotes on the table names.

The first two are solved in commit 92908a80e287e6c27e514605f46d643abeff9190 of the encryption module, where the encoding was changed from Base64 to Hex, avoiding the "/" and other non-alphanumeric chars on both table names and protected data.

The latter is a little more complicated. If you send me the concrete test case and the commits of the proxy and encryption module you are using, I will be able to figure out what is happening. However, I'm pretty sure the data to be protected is passed to the protection module without the quote chars, which will leave the problem in the protocol module. If there is an actual bug (i.e. the quote chars are being passed), it can be easily solved.

tchevallier commented 6 years ago

OK thanks I will report this commit to the branch feature/wfs-proxy on which I am working currently