File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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
99private import codeql.ruby.Concepts
1010private import codeql.ruby.dataflow.RemoteFlowSources
1111private import codeql.ruby.dataflow.BarrierGuards
12+ private import codeql.ruby.dataflow.Sanitizers
1213
1314/**
1415 * Provides default sources, sinks and sanitizers for detecting
@@ -103,11 +104,7 @@ module UrlRedirect {
103104 *
104105 * We currently don't catch these cases.
105106 */
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 { }
111108
112109 /**
113110 * 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