Skip to content

Commit 5dcc3d4

Browse files
committed
Ruby: Recognise modeled source/sink methods
1 parent 766e68a commit 5dcc3d4

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

ruby/ql/src/utils/modeleditor/ModelEditor.qll

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ private import codeql.ruby.dataflow.internal.FlowSummaryImplSpecific
88
private import codeql.ruby.frameworks.core.Gem
99
private import codeql.ruby.frameworks.data.ModelsAsData
1010
private import codeql.ruby.frameworks.data.internal.ApiGraphModelsExtensions
11+
private import queries.modeling.internal.Util as Util
1112

1213
/** Holds if the given callable is not worth supporting. */
1314
private predicate isUninteresting(DataFlow::MethodNode c) {
@@ -130,12 +131,10 @@ class TestFile extends File {
130131
*/
131132
class SinkCallable extends DataFlow::MethodNode {
132133
SinkCallable() {
133-
this = ModelOutput::getASinkNode(_).asCallable() and
134-
exists(string type, string path, string kind, string method |
135-
sinkModel(type, path, kind) and
136-
path = "Method[" + method + "]" and
137-
method = this.getMethodName()
138-
// TODO: (type, path) corresponds to this method
134+
exists(string type, string path, string method |
135+
method = path.regexpCapture("(Method\\[[^\\]]+\\]).*", 1) and
136+
Util::pathToMethod(this, type, method) and
137+
sinkModel(type, path, _)
139138
)
140139
}
141140
}
@@ -144,7 +143,13 @@ class SinkCallable extends DataFlow::MethodNode {
144143
* A callable where there exists a MaD source model that applies to it.
145144
*/
146145
class SourceCallable extends DataFlow::CallableNode {
147-
SourceCallable() { sourceElement(this.asExpr().getExpr(), _, _, _) }
146+
SourceCallable() {
147+
exists(string type, string path, string method |
148+
method = path.regexpCapture("(Method\\[[^\\]]+\\]).*", 1) and
149+
Util::pathToMethod(this, type, method) and
150+
sinkModel(type, path, _)
151+
)
152+
}
148153
}
149154

150155
/**

0 commit comments

Comments
 (0)