-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Rust: Model mysql and mysql_async query sinks #20631
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
Adds SQL injection sink models for the mysql and mysql_async Rust libraries to improve security analysis coverage.
- Introduces sink models for various query methods in both sync and async MySQL libraries
- Includes comprehensive test coverage demonstrating SQL injection detection
- Updates documentation to reflect the newly supported frameworks
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| rust/ql/test/query-tests/security/CWE-089/options.yml | Adds mysql and mysql_async dependencies for testing |
| rust/ql/test/query-tests/security/CWE-089/mysql.rs | Test file demonstrating both safe and unsafe MySQL query patterns |
| rust/ql/test/query-tests/security/CWE-089/SqlInjection.expected | Expected test results showing proper SQL injection detection |
| rust/ql/lib/codeql/rust/frameworks/mysql.model.yml | Sink models for synchronous mysql library query methods |
| rust/ql/lib/codeql/rust/frameworks/mysql-async.model.yml | Sink models for asynchronous mysql_async library query methods |
| rust/ql/lib/change-notes/2025-10-10-mysql.md | Change note documenting the new library support |
| docs/codeql/reusables/supported-frameworks.rst | Documentation update listing the new supported frameworks |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.
|
DCA LGTM. |
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.
Models look good to me. I got thrown off by some of the formatting so I'd suggest that we format the tests with rustfmt to make things more uniform and easier to read.
|
|
||
| // prepared queries (safe) | ||
| let stmt = conn.prep(prepared_query.as_str())?; // $ sql-sink | ||
| let _ : Vec<i64> = conn.exec(&stmt, (remote_string.as_str(),))?; |
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.
What are these commas here and below?
here
v
let _ : Vec<i64> = conn.exec(&stmt, (remote_string.as_str(),))?;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.
It's one of those funny corners of languages - this is required to disambiguate a tuple with one element from ordinary parenthesis in Rust. See here.
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.
Ah! Thanks.
Co-authored-by: Simon Friis Vindum <paldepind@github.com>
I'm generally against formatting tests, at least uniformly, as we should aim to have a high diversity of code in tests and auto formatting reduces it. I'm happy to address specific areas of confusion, and perhaps even format whole files in certain cases - but I don't want us to get anywhere close to this being a requirement (in tests). |
|
I have formatted just this test file. |
|
Thanks. From my point of view, I find auto-formatted code nicer to read and since formatting mostly only affect parsing, and rust_analyzer handles parsing, I'd think it wouldn't be something we'd have to test much. But that's just my preference :) |
True. It's probably fine if 90% of tests are formatted for ease of reading. |
|
@paldepind would you mind re-approving this? |
|
Thanks! |
Model
mysqlandmysql_asyncquery sinks (sources will follow in another PR).