rwnx / pynonymizer

A universal tool for translating sensitive production database dumps into anonymized copies.
https://pypi.org/project/pynonymizer/
MIT License
101 stars 38 forks source link

Improve ODBC interaction: Accept a connection string #135

Closed LDan1117 closed 5 months ago

LDan1117 commented 5 months ago

Is your feature request related to a problem? Please describe. Yes. I've been playing with this nice tool and discovered that msodbcsql18 is barely usable with SQL Server instances running in Docker locally. The thing is that version 18 brings breaking changes by switching Encrypt option to true by default. This leads to a problem with self-signed certificates not being trusted by the driver.

More information on that can be found here: https://techcommunity.microsoft.com/t5/sql-server-blog/odbc-driver-18-0-for-sql-server-released/ba-p/3169228

Describe the solution you'd like Currently, it's possible to provide db-host, db-user, and db-password via both environment variables and CLI arguments. However, it's not possible to further customize the connection string. The proposal for pynonymizer is to accept a connection string from its arguments. This will allow clients to customize the connection information and will improve forward compatibility of the tool with future releases of ODBC drivers.

Describe alternatives you've considered It looks like it's possible to inject additional connection string arguments via db-host argument by escaping the hostname with ;. Though it feels like a hack rather than a proper solution and I haven't tried that. Chances are it will not work at all. https://github.com/rwnx/pynonymizer/blob/master/pynonymizer/database/mssql/__init__.py#L127

Additional context I put together a Dockerfile that can be used to easily reproduce the issue - https://github.com/LDan1117/pynonymizer.docker/blob/main/Dockerfile#L10 Just replace msodbcsql17 with msodbcsql18.

rwnx commented 5 months ago

I totally agree, this needs to change for mssql/odbc, the abstraction doesnt fit!

What do you think about a connection string argument that would be mutually exclusive with the db host/db user/password arguments?

rwnx commented 5 months ago

Hi, this change is in the v2 milestone and will be released this week. you can customize the connection string yourself using --mssql-connection-string