-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
Prevent database connections to sqlite #9218
Conversation
It would be good to add tests for the endpoints to ensure that SQLite connection strings are rejected at the API layer. I think this deserves a partial integration test or two. |
I think this is a case to write a note on UPDATING.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's an api test failing. That should be enough to ensure the api rejects sqlite connection strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with a few nits. Would be good to add an integration test or two
Codecov Report
@@ Coverage Diff @@
## master #9218 +/- ##
==========================================
+ Coverage 58.91% 58.92% +0.01%
==========================================
Files 372 372
Lines 11996 11999 +3
Branches 2937 2940 +3
==========================================
+ Hits 7068 7071 +3
Misses 4750 4750
Partials 178 178
Continue to review full report at Codecov.
|
|
||
|
||
def check_sqlalchemy_uri(uri): | ||
if uri.startswith("sqlite"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@suddjian should this be if uri.drivername == "sqlite":
? Also could you add typing to this method so it's apparent the type of the uri
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is merged but I can add typing in a new PR.
uri
is a string so I assume you're referring to the output of make_url
from sqlalchemy. make_url(uri).drivername == "sqlite"
won't quite work in all cases because there are actually multiple drivers available for sqlite, each with their own protocol portion of the URI. We would need multiple checks, or make_url(uri).drivername.startswith("sqlite")
. Any sqlite URI will start with "sqlite"
, however, so I think this way is simpler.
CATEGORY
SUMMARY
SQLite allows users to create DBs locally on the machine running Superset. This is dangerous because it allows mapping the local filesystem and can also lead to DoS attacks. There is no good reason to be using SQLite as an analytics DB, so we've opted to prevent it from being used.
This change introduces a new flag
PREVENT_UNSAFE_DB_CONNECTIONS
which is true by default. Any other future unsafe db connections can be added to the same logic I've written here.TEST PLAN
Unit tested, smoke tested locally
ADDITIONAL INFORMATION
REVIEWERS
@willbarrett @craig-rueda @nytai