Ruby: add asCallable()

This commit is contained in:
Asger F
2023-06-28 11:44:29 +02:00
parent 6feda75dd6
commit dd868437ce

View File

@@ -200,6 +200,25 @@ module API {
pragma[inline_late]
DataFlow::Node asSink() { result = asSinkInline(this) }
/**
* Gets a callable that can reach this sink.
*
* For example:
* ```ruby
* Foo.bar do |x| # API::getTopLevelMember("Foo").getMethod("bar").getBlock().asCallable()
* end
*
* class Baz
* def m # API::getTopLevelMember("Foo").getMethod("bar").getArgument(0).getMethod("m").asCallable()
* end
* end
* Foo.bar(Baz.new)
* ```
*/
bindingset[this]
pragma[inline_late]
DataFlow::CallableNode asCallable() { Impl::asCallable(this.getAnEpsilonSuccessor(), result) }
/**
* Get a data-flow node that transitively flows to this value, provided that this value corresponds
* to a sink.
@@ -1196,6 +1215,11 @@ module API {
)
}
cached
predicate asCallable(Node apiNode, DataFlow::CallableNode callable) {
apiNode = getBackwardStartNode(callable)
}
cached
predicate contentEdge(Node pred, DataFlow::Content content, Node succ) {
exists(