From b32071999bced79460cd7de8528433f98582b1d5 Mon Sep 17 00:00:00 2001 From: Koen Vlaswinkel Date: Tue, 30 Jan 2024 15:00:13 +0100 Subject: [PATCH] Ruby: Correctly report supported status of summary and neutral models --- ruby/ql/src/utils/modeleditor/ModelEditor.qll | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/ruby/ql/src/utils/modeleditor/ModelEditor.qll b/ruby/ql/src/utils/modeleditor/ModelEditor.qll index 9175a68192f..f87ff925ae6 100644 --- a/ruby/ql/src/utils/modeleditor/ModelEditor.qll +++ b/ruby/ql/src/utils/modeleditor/ModelEditor.qll @@ -104,7 +104,7 @@ class MethodEndpoint extends Endpoint instanceof DataFlow::MethodNode { /** Holds if this API has a supported summary. */ pragma[nomagic] - predicate hasSummary() { none() } + predicate hasSummary() { this.getNode() instanceof SummaryCallable } /** Holds if this API is a known source. */ pragma[nomagic] @@ -116,7 +116,7 @@ class MethodEndpoint extends Endpoint instanceof DataFlow::MethodNode { /** Holds if this API is a known neutral. */ pragma[nomagic] - predicate isNeutral() { none() } + predicate isNeutral() { this.getNode() instanceof NeutralCallable } /** * Holds if this API is supported by existing CodeQL libraries, that is, it is either a @@ -183,6 +183,30 @@ class SourceCallable extends DataFlow::CallableNode { } } +/** + * A callable where there exists a MaD summary model that applies to it. + */ +class SummaryCallable extends DataFlow::CallableNode { + SummaryCallable() { + exists(string type, string path | + Util::pathToMethod(this, type, path) and + summaryModel(type, path, _, _, _) + ) + } +} + +/** + * A callable where there exists a MaD neutral model that applies to it. + */ +class NeutralCallable extends DataFlow::CallableNode { + NeutralCallable() { + exists(string type, string path | + Util::pathToMethod(this, type, path) and + neutralModel(type, path, _) + ) + } +} + /** * A module defined in source code */