File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change
1
+ /** Provides commonly used dataflow sanitizers */
2
+
3
+ private import codeql.ruby.AST
4
+ private import codeql.ruby.DataFlow
5
+
6
+ /**
7
+ * A sanitizer for flow into a string interpolation component,
8
+ * provided that component does not form a prefix of the string.
9
+ *
10
+ * This is useful for URLs and paths, where the fixed prefix prevents the user from controlling the target.
11
+ */
12
+ class PrefixedStringInterpolation extends DataFlow:: Node {
13
+ PrefixedStringInterpolation ( ) {
14
+ exists ( StringlikeLiteral str , int n | str .getComponent ( n ) = this .asExpr ( ) .getExpr ( ) and n > 0 )
15
+ }
16
+ }
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ private import codeql.ruby.DataFlow
9
9
private import codeql.ruby.Concepts
10
10
private import codeql.ruby.dataflow.RemoteFlowSources
11
11
private import codeql.ruby.dataflow.BarrierGuards
12
+ private import codeql.ruby.dataflow.Sanitizers
12
13
13
14
/**
14
15
* Provides default sources, sinks and sanitizers for detecting
@@ -103,11 +104,7 @@ module UrlRedirect {
103
104
*
104
105
* We currently don't catch these cases.
105
106
*/
106
- class StringInterpolationAsSanitizer extends Sanitizer {
107
- StringInterpolationAsSanitizer ( ) {
108
- exists ( StringlikeLiteral str , int n | str .getComponent ( n ) = this .asExpr ( ) .getExpr ( ) and n > 0 )
109
- }
110
- }
107
+ class StringInterpolationAsSanitizer extends PrefixedStringInterpolation , Sanitizer { }
111
108
112
109
/**
113
110
* These methods return a new `ActionController::Parameters` or a `Hash` containing a subset of
You can’t perform that action at this time.
0 commit comments