|
| 1 | +/** |
| 2 | + * Provides default sources, sinks and sanitizers for detecting SQL injection |
| 3 | + * vulnerabilities, as well as extension points for adding your own. |
| 4 | + */ |
| 5 | + |
| 6 | +private import codeql.ruby.Concepts |
| 7 | +private import codeql.ruby.DataFlow |
| 8 | +private import codeql.ruby.dataflow.BarrierGuards |
| 9 | +private import codeql.ruby.dataflow.RemoteFlowSources |
| 10 | + |
| 11 | +/** |
| 12 | + * Provides default sources, sinks and sanitizers for detecting SQL injection |
| 13 | + * vulnerabilities, as well as extension points for adding your own. |
| 14 | + */ |
| 15 | +module SqlInjection { |
| 16 | + abstract class Source extends DataFlow::Node { } |
| 17 | + |
| 18 | + abstract class Sink extends DataFlow::Node { } |
| 19 | + |
| 20 | + abstract class Sanitizer extends DataFlow::Node { } |
| 21 | + |
| 22 | + /** |
| 23 | + * A source of remote user input, considered as a flow source. |
| 24 | + */ |
| 25 | + private class RemoteFlowSourceAsSource extends Source, RemoteFlowSource { } |
| 26 | + |
| 27 | + /** |
| 28 | + * A SQL statement of a SQL execution, considered as a flow sink. |
| 29 | + */ |
| 30 | + private class SqlExecutionAsSink extends Sink { |
| 31 | + SqlExecutionAsSink() { this = any(SqlExecution e).getSql() } |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * A comparison with a constant string, considered as a sanitizer-guard. |
| 36 | + */ |
| 37 | + private class StringConstCompareAsSanitizerGuard extends Sanitizer, StringConstCompareBarrier { } |
| 38 | + |
| 39 | + /** |
| 40 | + * An inclusion check against an array of constant strings, considered as a |
| 41 | + * sanitizer-guard. |
| 42 | + */ |
| 43 | + class StringConstArrayInclusionCallAsSanitizer extends Sanitizer, |
| 44 | + StringConstArrayInclusionCallBarrier { } |
| 45 | +} |
0 commit comments