-
Notifications
You must be signed in to change notification settings - Fork 269
Fix MySQL multiple statements validation logic #81
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
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.
Pull Request Overview
This PR fixes MySQL query validation logic that was incorrectly flagging valid queries containing semicolons as invalid. The fix updates regex patterns to properly detect dangerous SQL injection patterns and multiple statements while allowing legitimate single statements with trailing semicolons.
- Updated regex patterns to distinguish between legitimate single statements with semicolons and actual multiple statements
- Modified dangerous pattern detection to focus on semicolons followed by injection keywords rather than any semicolon
- Added comprehensive test cases covering edge cases with semicolons and comments
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| MySqlService.cs | Updated validation logic with improved regex patterns for detecting multiple statements and SQL injection attempts |
| MySqlServiceQueryValidationTests.cs | Added test cases for valid queries with semicolons and additional test coverage for multiple statement detection |
...ols.MySql/tests/Azure.Mcp.Tools.MySql.UnitTests/Services/MySqlServiceQueryValidationTests.cs
Show resolved
Hide resolved
* Adds support for Azure Database for PostgreSQL
- Adds support for Azure Database for PostgreSQL - Flexible Server.
- Implements the following PostgreSQL commands:
- Server
- List
- GetConfig
- GetParam
- Database
- List
- Query
- Table
- List
- GetSchema
- Adds service and interface for PostgreSQL.
- Adds commands and arguments for PostgreSQL
- Registers the new commands in the CommandFactory.
- Registers the new service to start during service initialization.
- Updates the ArgumentDefinitions to include PostgreSQL commands.
- Updates the AzureMcp project file to include the new dependencies.
Notes:
- Inherits from SubscriptionCommand
- Adds resource group explicitly to options and arguments.
* Adds tests for Azure Database for PostgreSQL
* Update README and azmcp docs with PostgreSQL capabilities.
* Rebase, addresses review comments & refactor base classes
- Update to work with the rebased code.
- Add PostgresJsonContext
- Remove explicit validations.
- Change the commandline arguments to give more context (pg => postgres)
- Simplify command line usage (get-schema => schema)
- Add JsonPropertyName
- Add more tests for validating missing parameters.
- Simplify logic in PG query & server config.
- Fix commmand names
- Use common BaseAzureService credential
- Refactor server and database to use common base classes.
- Update docs
- Run dotnet format.
* Remove the extra line
* Fix MySQL query validation logic * remove duplicate unit test * update logic * dotnet format * update changelog
What does this PR do?
MySQL was incorrectly flagging proper query like "SELECT * from users;" as invalid. Updated logic to detect this properly. Added extra unit tests.
GitHub issue number?
[Link to the GitHub issue this PR addresses]Pre-merge Checklist
CHANGELOG.mdfor product changes (features, bug fixes, UI/UX, updated dependencies).\eng\common\spelling\Invoke-Cspell.ps1README.mddocumentation/docs/azmcp-commands.md/docs/e2eTestPrompts.mdToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test promptscrypto mining, spam, data exfiltration, etc.)/azp run azure - mcpto run Live Test Pipeline