fix read-only enforcement for sql_query and add strict mode#4
Open
vim-zz wants to merge 1 commit intorbatis:mainfrom
Open
fix read-only enforcement for sql_query and add strict mode#4vim-zz wants to merge 1 commit intorbatis:mainfrom
vim-zz wants to merge 1 commit intorbatis:mainfrom
Conversation
Author
|
I have verified this version, using the following MCP configuration in Codex [mcp_servers.rdbc]
command = "rbdc-mcp"
args = ["--database-url", "sqlite://./mydb.db", "--read-only"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new "read-only" server mode to prevent write operations via SQL, improving security and operational control. The changes add a command-line flag, update documentation, and implement robust SQL validation to enforce read-only behavior at the handler and database manager levels.
Read-only mode feature:
--read-onlycommand-line flag to enable read-only mode, documented in bothREADME.mdandREADME_cn.md. [1] [2] [3]SQL validation and enforcement:
src/sql_guard.rsmodule implementingis_read_only_sql, which checks SQL statements for read-only compliance, including detection of write keywords, multi-statement queries, and edge cases. [1] [2] [3]DatabaseManager::execute_queryandRbdcDatabaseHandler::sql_query, rejecting non-compliant SQL with appropriate errors. [1] [2]sql_execentirely when the server is in read-only mode, returning an error if attempted.Handler and wiring changes:
RbdcDatabaseHandlerto accept and store theread_onlyflag, and updated instantiation inmain.rsto pass this flag. [1] [2] [3]These changes collectively ensure that when the server is started in read-only mode, all SQL execution paths are guarded against write operations, providing a safer deployment option.