Skip to content

Commit 800077d

Browse files
committed
changes based on feedback
1 parent e4d4873 commit 800077d

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

ruby/ql/lib/codeql/ruby/Regexp.qll

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,15 @@ private predicate regexExecution(
177177
)
178178
or
179179
// a case-when statement
180-
exists(CfgNodes::ExprNodes::CaseExprCfgNode caseWhen |
181-
name = "case-when" and
182-
exec.asExpr() = caseWhen and
183-
input.asExpr() = caseWhen.getValue()
180+
exists(CfgNodes::ExprNodes::CaseExprCfgNode caseExpr |
181+
exec.asExpr() = caseExpr and
182+
input.asExpr() = caseExpr.getValue()
184183
|
185-
regexp.asExpr() = caseWhen.getBranch(_).(CfgNodes::ExprNodes::WhenClauseCfgNode).getPattern(_)
184+
name = "case-when" and
185+
regexp.asExpr() = caseExpr.getBranch(_).(CfgNodes::ExprNodes::WhenClauseCfgNode).getPattern(_)
186186
or
187-
regexp.asExpr() = caseWhen.getBranch(_).(CfgNodes::ExprNodes::InClauseCfgNode).getPattern()
187+
name = "case-in" and
188+
regexp.asExpr() = caseExpr.getBranch(_).(CfgNodes::ExprNodes::InClauseCfgNode).getPattern()
188189
)
189190
}
190191

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @description Used to debug the discovery of regexp literals.
3+
* @kind problem
4+
*/
5+
6+
import codeql.ruby.regexp.internal.RegExpTracking
7+
import ruby
8+
9+
from DataFlow::Node source, DataFlow::Node sink
10+
where source = regExpSource(sink)
11+
select sink, "Regexp from $@ is used.", source, "this source"

ruby/ql/lib/codeql/ruby/regexp/internal/RegExpTracking.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* 2: A precise type tracking analysis that tracks
1111
* strings and regular expressions to the places where they are used.
12-
* This phase keeps track of which strings and regular expressions ends up in which places.
12+
* This phase keeps track of which strings and regular expressions end up in which places.
1313
*/
1414

1515
private import codeql.ruby.Regexp as RE
@@ -156,7 +156,7 @@ private DataFlow::LocalSourceNode trackRegs(DataFlow::Node start, TypeTracker t)
156156
)
157157
}
158158

159-
/** Gests a node that references a regular expression. */
159+
/** Gets a node that references a regular expression. */
160160
private DataFlow::LocalSourceNode trackRegexpType(TypeTracker t) {
161161
t.start() and
162162
(
@@ -167,7 +167,7 @@ private DataFlow::LocalSourceNode trackRegexpType(TypeTracker t) {
167167
exists(TypeTracker t2 | result = trackRegexpType(t2).track(t2, t))
168168
}
169169

170-
/** Gests a node that references a regular expression. */
170+
/** Gets a node that references a regular expression. */
171171
DataFlow::Node trackRegexpType() { trackRegexpType(TypeTracker::end()).flowsTo(result) }
172172

173173
/** Gets a node holding a value for the regular expression that is evaluated at `re`. */

0 commit comments

Comments
 (0)