File tree Expand file tree Collapse file tree 3 files changed +48
-19
lines changed
Expand file tree Collapse file tree 3 files changed +48
-19
lines changed Original file line number Diff line number Diff line change @@ -48,4 +48,26 @@ module Mysql2 {
4848
4949 override DataFlow:: Node getSql ( ) { result = query }
5050 }
51+
52+ /**
53+ * A call to `Mysql2::Client.escape`, considered as a sanitizer for SQL statements.
54+ */
55+ private class Mysql2EscapeSanitization extends SqlSanitization:: Range {
56+ Mysql2EscapeSanitization ( ) {
57+ this = API:: getTopLevelMember ( "Mysql2" ) .getMember ( "Client" ) .getAMethodCall ( "escape" )
58+ }
59+ }
60+
61+ /**
62+ * Flow summary for `Mysql2::Client.escape()`.
63+ */
64+ private class EscapeSummary extends SummarizedCallable {
65+ EscapeSummary ( ) { this = "Mysql2::Client.escape()" }
66+
67+ override MethodCall getACall ( ) { result = any ( Mysql2EscapeSanitization c ) .asExpr ( ) .getExpr ( ) }
68+
69+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
70+ input = "Argument[0]" and output = "ReturnValue" and preservesValue = false
71+ }
72+ }
5173}
Original file line number Diff line number Diff line change @@ -77,4 +77,26 @@ module Sqlite3 {
7777
7878 override DataFlow:: Node getSql ( ) { result = this .getArgument ( 0 ) }
7979 }
80- }
80+
81+ /**
82+ * A call to `SQLite3::Database.quote`, considered as a sanitizer for SQL statements.
83+ */
84+ private class SQLite3QuoteSanitization extends SqlSanitization {
85+ SQLite3QuoteSanitization ( ) {
86+ this = API:: getTopLevelMember ( "SQLite3" ) .getMember ( "Database" ) .getAMethodCall ( "quote" )
87+ }
88+ }
89+
90+ /**
91+ * Flow summary for `SQLite3::Database.quote()`.
92+ */
93+ private class QuoteSummary extends SummarizedCallable {
94+ QuoteSummary ( ) { this = "SQLite3::Database.quote()" }
95+
96+ override MethodCall getACall ( ) { result = any ( SQLite3QuoteSanitization c ) .asExpr ( ) .getExpr ( ) }
97+
98+ override predicate propagatesFlowExt ( string input , string output , boolean preservesValue ) {
99+ input = "Argument[0]" and output = "ReturnValue" and preservesValue = false
100+ }
101+ }
102+ }
Original file line number Diff line number Diff line change @@ -52,23 +52,8 @@ module SqlInjection {
5252 * sanitizer-guard.
5353 */
5454 class StringConstArrayInclusionCallAsSanitizer extends Sanitizer ,
55- StringConstArrayInclusionCallBarrier { }
55+ StringConstArrayInclusionCallBarrier
56+ { }
5657
57- /**
58- * A call to `Mysql2::Client.escape`, considered as a sanitizer.
59- */
60- private class Mysql2EscapeSanitization extends Sanitizer {
61- Mysql2EscapeSanitization ( ) {
62- this = API:: getTopLevelMember ( "Mysql2" ) .getMember ( "Client" ) .getAMethodCall ( "escape" )
63- }
64- }
65-
66- /**
67- * A call to `SQLite3::Database.quote`, considered as a sanitizer.
68- */
69- private class SQLite3EscapeSanitization extends Sanitizer {
70- SQLite3EscapeSanitization ( ) {
71- this = API:: getTopLevelMember ( "SQLite3" ) .getMember ( "Database" ) .getAMethodCall ( "quote" )
72- }
73- }
58+ private class SqlSanitizationAsSanitizer extends Sanitizer , SqlSanitization { }
7459}
You can’t perform that action at this time.
0 commit comments