changes based on feedback

This commit is contained in:
erik-krogh
2023-01-23 14:53:05 +01:00
parent e4d4873d0d
commit 800077dabe
3 changed files with 21 additions and 9 deletions

View File

@@ -177,14 +177,15 @@ private predicate regexExecution(
)
or
// a case-when statement
exists(CfgNodes::ExprNodes::CaseExprCfgNode caseWhen |
name = "case-when" and
exec.asExpr() = caseWhen and
input.asExpr() = caseWhen.getValue()
exists(CfgNodes::ExprNodes::CaseExprCfgNode caseExpr |
exec.asExpr() = caseExpr and
input.asExpr() = caseExpr.getValue()
|
regexp.asExpr() = caseWhen.getBranch(_).(CfgNodes::ExprNodes::WhenClauseCfgNode).getPattern(_)
name = "case-when" and
regexp.asExpr() = caseExpr.getBranch(_).(CfgNodes::ExprNodes::WhenClauseCfgNode).getPattern(_)
or
regexp.asExpr() = caseWhen.getBranch(_).(CfgNodes::ExprNodes::InClauseCfgNode).getPattern()
name = "case-in" and
regexp.asExpr() = caseExpr.getBranch(_).(CfgNodes::ExprNodes::InClauseCfgNode).getPattern()
)
}

View File

@@ -0,0 +1,11 @@
/**
* @description Used to debug the discovery of regexp literals.
* @kind problem
*/
import codeql.ruby.regexp.internal.RegExpTracking
import ruby
from DataFlow::Node source, DataFlow::Node sink
where source = regExpSource(sink)
select sink, "Regexp from $@ is used.", source, "this source"

View File

@@ -9,7 +9,7 @@
*
* 2: A precise type tracking analysis that tracks
* strings and regular expressions to the places where they are used.
* This phase keeps track of which strings and regular expressions ends up in which places.
* This phase keeps track of which strings and regular expressions end up in which places.
*/
private import codeql.ruby.Regexp as RE
@@ -156,7 +156,7 @@ private DataFlow::LocalSourceNode trackRegs(DataFlow::Node start, TypeTracker t)
)
}
/** Gests a node that references a regular expression. */
/** Gets a node that references a regular expression. */
private DataFlow::LocalSourceNode trackRegexpType(TypeTracker t) {
t.start() and
(
@@ -167,7 +167,7 @@ private DataFlow::LocalSourceNode trackRegexpType(TypeTracker t) {
exists(TypeTracker t2 | result = trackRegexpType(t2).track(t2, t))
}
/** Gests a node that references a regular expression. */
/** Gets a node that references a regular expression. */
DataFlow::Node trackRegexpType() { trackRegexpType(TypeTracker::end()).flowsTo(result) }
/** Gets a node holding a value for the regular expression that is evaluated at `re`. */