-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Ruby: Accept MaD sanitizers for queries with MaD sinks and convert some existing sanitizers #21341
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
Open
owen-mc
wants to merge
16
commits into
github:main
Choose a base branch
from
owen-mc:rb/accept-mad-sanitizers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+209
−138
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3dc465f
Accept MaD sanitizers for queries with MaD sinks
owen-mc 1d7a39a
Change how sql-injection barriers are accepted
owen-mc fc429c1
Improve Mysql2 test
owen-mc 3e4f42f
Move Mysql2 flow model to MaD and remove ql sanitizer
owen-mc d4bb92b
Reinstate Mysql2 sanitizer in MaD
owen-mc 1fa183e
Improve Sqlite3 test
owen-mc 5df695b
Move SQLite3 flow model to MaD and remove ql sanitizer
owen-mc 4aee99f
Reinstate SQLite3 sanitizer in MaD
owen-mc 6294c3b
Remove Shellwords sanitizer in ql
owen-mc b3681f7
Model flow through Shellwords escape and shellescape
owen-mc de5470a
Add MaD barriers for Shellwords.escape and shellescape
owen-mc eb7f198
Reinstate ql model for `String#shellescape`
owen-mc 1bff7a3
Add change note
owen-mc f577e97
Update other test in same folder
owen-mc 05d681f
Update taintstep test for models becoming MaD
owen-mc 1d6b8c5
Use postprocessing queries for unrelated test
owen-mc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
ruby/ql/lib/change-notes/2026-02-17-flow-through-shellwords-escape-shellescape.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * We now track taint flow through `Shellwords.escape` and `Shellwords.shellescape` for all queries except command injection, for which they are sanitizers. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| extensions: | ||
| - addsTo: | ||
| pack: codeql/ruby-all | ||
| extensible: summaryModel | ||
| data: | ||
| - ['Mysql2::Client!', 'Method[escape]', 'Argument[0]', 'ReturnValue', 'taint'] | ||
| - addsTo: | ||
| pack: codeql/ruby-all | ||
| extensible: barrierModel | ||
| data: | ||
| - ['Mysql2::Client!', 'Method[escape].ReturnValue', 'sql-injection'] |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| extensions: | ||
| - addsTo: | ||
| pack: codeql/ruby-all | ||
| extensible: summaryModel | ||
| data: | ||
| - ['SQLite3::Database!', 'Method[quote]', 'Argument[0]', 'ReturnValue', 'taint'] | ||
| - addsTo: | ||
| pack: codeql/ruby-all | ||
| extensible: barrierModel | ||
| data: | ||
| - ['SQLite3::Database!', 'Method[quote].ReturnValue', 'sql-injection'] |
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
12 changes: 12 additions & 0 deletions
12
ruby/ql/lib/codeql/ruby/frameworks/stdlib/Shellwords.model.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| extensions: | ||
| - addsTo: | ||
| pack: codeql/ruby-all | ||
| extensible: summaryModel | ||
| data: | ||
| - ['Shellwords!', 'Method[escape,shellescape]', 'Argument[0]', 'ReturnValue', 'taint'] | ||
|
|
||
| - addsTo: | ||
| pack: codeql/ruby-all | ||
| extensible: barrierModel | ||
| data: | ||
| - ['Shellwords!', 'Method[escape,shellescape].ReturnValue', 'command-injection'] |
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
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
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
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
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
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
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
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
15 changes: 15 additions & 0 deletions
15
ruby/ql/test/library-tests/frameworks/mysql2/SqlInjection.expected
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #select | ||
| | Mysql2.rb:13:27:13:72 | "SELECT * FROM users WHERE use..." | Mysql2.rb:3:12:3:17 | call to params | Mysql2.rb:13:27:13:72 | "SELECT * FROM users WHERE use..." | This SQL query depends on a $@. | Mysql2.rb:3:12:3:17 | call to params | user-provided value | | ||
| | Mysql2.rb:24:31:24:93 | "SELECT * FROM users WHERE use..." | Mysql2.rb:3:12:3:17 | call to params | Mysql2.rb:24:31:24:93 | "SELECT * FROM users WHERE use..." | This SQL query depends on a $@. | Mysql2.rb:3:12:3:17 | call to params | user-provided value | | ||
| edges | ||
| | Mysql2.rb:3:5:3:8 | name | Mysql2.rb:13:27:13:72 | "SELECT * FROM users WHERE use..." | provenance | AdditionalTaintStep | | ||
| | Mysql2.rb:3:5:3:8 | name | Mysql2.rb:24:31:24:93 | "SELECT * FROM users WHERE use..." | provenance | AdditionalTaintStep | | ||
| | Mysql2.rb:3:12:3:17 | call to params | Mysql2.rb:3:12:3:29 | ...[...] | provenance | | | ||
| | Mysql2.rb:3:12:3:29 | ...[...] | Mysql2.rb:3:5:3:8 | name | provenance | | | ||
| nodes | ||
| | Mysql2.rb:3:5:3:8 | name | semmle.label | name | | ||
| | Mysql2.rb:3:12:3:17 | call to params | semmle.label | call to params | | ||
| | Mysql2.rb:3:12:3:29 | ...[...] | semmle.label | ...[...] | | ||
| | Mysql2.rb:13:27:13:72 | "SELECT * FROM users WHERE use..." | semmle.label | "SELECT * FROM users WHERE use..." | | ||
| | Mysql2.rb:24:31:24:93 | "SELECT * FROM users WHERE use..." | semmle.label | "SELECT * FROM users WHERE use..." | | ||
| subpaths |
4 changes: 4 additions & 0 deletions
4
ruby/ql/test/library-tests/frameworks/mysql2/SqlInjection.qlref
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| query: queries/security/cwe-089/SqlInjection.ql | ||
| postprocess: | ||
| - utils/test/PrettyPrintModels.ql | ||
| - utils/test/InlineExpectationsTestQuery.ql |
12 changes: 12 additions & 0 deletions
12
ruby/ql/test/library-tests/frameworks/sqlite3/SqlInjection.expected
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #select | ||
| | sqlite3.rb:29:16:29:67 | "select * from table where cat..." | sqlite3.rb:25:16:25:21 | call to params | sqlite3.rb:29:16:29:67 | "select * from table where cat..." | This SQL query depends on a $@. | sqlite3.rb:25:16:25:21 | call to params | user-provided value | | ||
| edges | ||
| | sqlite3.rb:25:5:25:12 | category | sqlite3.rb:29:16:29:67 | "select * from table where cat..." | provenance | AdditionalTaintStep | | ||
| | sqlite3.rb:25:16:25:21 | call to params | sqlite3.rb:25:16:25:32 | ...[...] | provenance | | | ||
| | sqlite3.rb:25:16:25:32 | ...[...] | sqlite3.rb:25:5:25:12 | category | provenance | | | ||
| nodes | ||
| | sqlite3.rb:25:5:25:12 | category | semmle.label | category | | ||
| | sqlite3.rb:25:16:25:21 | call to params | semmle.label | call to params | | ||
| | sqlite3.rb:25:16:25:32 | ...[...] | semmle.label | ...[...] | | ||
| | sqlite3.rb:29:16:29:67 | "select * from table where cat..." | semmle.label | "select * from table where cat..." | | ||
| subpaths |
4 changes: 4 additions & 0 deletions
4
ruby/ql/test/library-tests/frameworks/sqlite3/SqlInjection.qlref
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| query: queries/security/cwe-089/SqlInjection.ql | ||
| postprocess: | ||
| - utils/test/PrettyPrintModels.ql | ||
| - utils/test/InlineExpectationsTestQuery.ql |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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 surprised why we lose this result (and the one below), do you know why?