Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Define a SQL driver unwrapping method #46

Open
Julio-Guerra opened this issue Nov 12, 2020 · 2 comments
Open

Proposal: Define a SQL driver unwrapping method #46

Julio-Guerra opened this issue Nov 12, 2020 · 2 comments

Comments

@Julio-Guerra
Copy link

Hey OpenCesus :-)

I am the lead developer of Sqreen's Go agent, and some users are unfortunately experiencing integration issues when using your driver wrapper ocDriver with our SQL-injection protection.

The problem simply comes from the fact the underlying wrapped driver gets hidden and our SQL dialect detection function no longer gets the underlying driver package path.

Describe the solution you'd like

Simply define a new ocDriver method Unwrap returning the wrapped driver so that we can detect it and unwrap it:

func (d *ocDriver) Unwrap() driver.Driver {
    return d.parent
}

Additional context

As this is a very common issue, I wrote a Go proposal to try to standardize the Unwrapper interface at golang/go#42460

@basvanbeek
Copy link
Member

So yes we could do such a thing but thinking about the use case I think you should also consider allowing consumers of your Agent to force a particular dialect instead of needing to always rely on your detection algo. I have seen these problems firsthand with sqlx even without driver wrapping but using alternative drivers.

@Julio-Guerra
Copy link
Author

Julio-Guerra commented Nov 12, 2020

So yes we could do such a thing but thinking about the use case I think you should also consider allowing consumers of your Agent to force a particular dialect instead of needing to always rely on your detection algo. I have seen these problems firsthand with sqlx even without driver wrapping but using alternative drivers.

Detecting the SQL dialect based on the package path is unfortunately the only option we have today, as discussed here golang/go#12600

As of manually enforcing the dialect, we don't provide such option today and we rather made the package path list dynamic so that we can update it at run time without releasing the agent nor restarting the app. But when the driver is wrapped, there's nothing we can do about it unless we have such unwrapping method available ^^'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants