-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add MysqlAdapter transactions support #58
Conversation
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.
We should update the README to mention that it supports MySQL too:
Line 6 in f68a534
This gem makes Rails console sessions less dangerous in specified environments by warning, color-coding, and auto-sandboxing PostgreSQL connections. In the future we'd like to extend this to make other external connections read-only too (e.g. disable job queueing, non-GET HTTP requests, etc.) |
Also, we should probably update these integration tests to include support for MySQL: https://github.com/salsify/safer_rails_console/blob/master/spec/integration/patches/sandbox_spec.rb
I'd imagine the easiest way to do this would be to add a separate database in the existing apps that has a mysql adapter: https://github.com/salsify/safer_rails_console/blob/master/spec/internal/rails_7_1/config/database.yml and then add a model that uses that MySQL database.
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 once we add some tests.
e361e8d
to
06b26bc
Compare
@gremerritt I've reverted the changes to keep backward compatibility. Converting this to draft pending resolution |
ab64683
to
9c18e79
Compare
9c18e79
to
990893c
Compare
Should be ready to review @erikkessler1 @gremerritt @erikkessler1 I had to go with different environments (per adapter) instead of adapter-specific models. |
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.
A couple last thoughts, but looking good
# Not possible to change a running transaction to read-only in MySQL | ||
# https://dev.mysql.com/doc/refman/8.4/en/set-transaction.html |
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.
Should we throw an error or provide some other indication that something has escaped the sandbox if we detect there is already an open transaction?
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.
I don't think so. I'm having a hard time thinking of scenarios where this would even be possible.
Not sure if this is different in Postgres but in Mysql, since this is a new session, there shouldn't be any transactions running for this session.
There could, however, be running transactions for other session that, even if we could, we wouldn't want to make read-only. For this reason, throwing an error or informing the user doesn't make much sense to me.
I may be missing some scenarios though.
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.
I'm not to sure either. Unfortunately, I wasn't able to glean anything from PR that originally added it for the Postgres version.
Description
This PR adds support for MySQL read-only transactions in sandbox mode.