Go safe SQL implementation
In order to use this library the following steps must be taken:
- Set up your CI/tests so that you can:
- Ban imports of a specific package/function
- Create an allowlist of call sites that can use that package/function
- Create an atomic change that:
- Converts all calls to
database/sqlinto calls tosafesql. This can easily be achieved with thelegacyconversionspackage and automated patching. - Prevents new calls to
legacyconversionsfrom being added and bans import of thedatabase/sqlpackage. This should ideally be true for all transitive dependencies. - Only allows
safesqlto importdatabase/sql.
- Converts all calls to
- After submitting that change, gradually migrate
legacyconversionscalls to usesafesqlfunctions or be promoted touncheckedconversions. If you chose the latter make sure the strings that you promote are controlled by the programmer and never by the user.