-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Java: Add MyBatis' Providers sinks
#8345
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e000163
Properly model `AbstractSQL` sinks and taint steps
jorgectf 447636b
Attempt to add `MyBatis`' sinks and taint steps to `SQL` and `OGNL` i…
jorgectf ded9663
Finish taint steps
jorgectf a0bf68f
Generally extend `TaintTracking::AdditionalTaintStep`
jorgectf 158366a
Apply suggestions from code review
jorgectf d47fced
Add tests
jorgectf 32f494e
Use `SummaryModelCsv` in `MyBatisAbstractSQLMethodsStep`
jorgectf 8482c01
Make `MyBatisProviderStep` an `AdditionalValueStep`
jorgectf c683b48
Add `MyBatisInjectionSink`'s QLDoc
jorgectf b62b8c8
Use `SummaryModelCsv` for the `toString` taint step
jorgectf f10dac3
Format some tests
jorgectf 9aa440e
Refactor `MyBatisAbstractSQLMethodsStep` and `MyBatisAbstractSQLMethod`
jorgectf ed19870
Refactor `MyBatisAbstractSQLMethodsStep`
jorgectf 3356bc4
Add change note
jorgectf e0952ba
Fix change note
jorgectf f6eb83f
Update `MyBatisAnnotationSqlInjection.qlref`
jorgectf 8790df7
Style fixes
atorralba 9e1b98e
Detach `MyBatisAbstractSqlMethodsStep` from `MyBatisAbstractSql`
jorgectf 834f2e8
Delete `MyBatisAbstractSql` and inline `MyBatisAbstractSqlMethodsStep`
jorgectf 50e95b5
Apply suggestions from code review
jorgectf 193ea1a
Merge branch 'main' into mybatis-new-sinks
jorgectf 548721a
Fix `MyBatisInjectionSink`
jorgectf 37b051a
Apply suggestions from code review
jorgectf 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
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 | ||
| --- | ||
| * Added modeling of MyBatis (`org.apache.ibatis`) Providers, resulting in additional sinks for the queries `java/ognl-injection`, `java/sql-injection`, `java/sql-injection-local` and `java/concatenated-sql-query`. |
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
35 changes: 35 additions & 0 deletions
35
java/ql/test/experimental/query-tests/security/CWE-089/src/main/MyBatisProvider.java
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,35 @@ | ||
| import org.apache.ibatis.annotations.Param; | ||
| import org.apache.ibatis.jdbc.SQL; | ||
|
|
||
| public class MyBatisProvider { | ||
| public String badSelect(@Param("input") final String input) { | ||
| String s = (new SQL() { | ||
| { | ||
| this.SELECT("password"); | ||
| this.FROM("users"); | ||
| this.WHERE("username = '" + input + "'"); | ||
| } | ||
| }).toString(); | ||
| return s; | ||
| } | ||
|
|
||
| public String badDelete(@Param("input") final String input) { | ||
| return "DELETE FROM users WHERE username = '" + input + "';"; | ||
| } | ||
|
|
||
| public String badUpdate(@Param("input") final String input) { | ||
| String s = (new SQL() { | ||
| { | ||
| this.UPDATE("users"); | ||
| this.SET("balance = 0"); | ||
| this.WHERE("username = '" + input + "'"); | ||
| } | ||
| }).toString(); | ||
| return s; | ||
| } | ||
|
|
||
| public String badInsert(@Param("input") final String input) { | ||
| return "INSERT INTO users VALUES (1, '" + input + "', 'hunter2');"; | ||
| } | ||
| } | ||
|
|
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
29 changes: 29 additions & 0 deletions
29
java/ql/test/stubs/org.mybatis-3.5.4/org/apache/ibatis/annotations/DeleteProvider.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
java/ql/test/stubs/org.mybatis-3.5.4/org/apache/ibatis/annotations/InsertProvider.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
java/ql/test/stubs/org.mybatis-3.5.4/org/apache/ibatis/annotations/SelectProvider.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Uh oh!
There was an error while loading. Please reload this page.