Skip to content

Commit 8aa3542

Browse files
authored
Merge pull request #15470 from github/koesie10/add-summary-neutral-ruby-supported
Ruby: Correctly report supported status of summary and neutral models
2 parents e5ba8fe + b320719 commit 8aa3542

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class MethodEndpoint extends Endpoint instanceof DataFlow::MethodNode {
104104

105105
/** Holds if this API has a supported summary. */
106106
pragma[nomagic]
107-
predicate hasSummary() { none() }
107+
predicate hasSummary() { this.getNode() instanceof SummaryCallable }
108108

109109
/** Holds if this API is a known source. */
110110
pragma[nomagic]
@@ -116,7 +116,7 @@ class MethodEndpoint extends Endpoint instanceof DataFlow::MethodNode {
116116

117117
/** Holds if this API is a known neutral. */
118118
pragma[nomagic]
119-
predicate isNeutral() { none() }
119+
predicate isNeutral() { this.getNode() instanceof NeutralCallable }
120120

121121
/**
122122
* 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 {
183183
}
184184
}
185185

186+
/**
187+
* A callable where there exists a MaD summary model that applies to it.
188+
*/
189+
class SummaryCallable extends DataFlow::CallableNode {
190+
SummaryCallable() {
191+
exists(string type, string path |
192+
Util::pathToMethod(this, type, path) and
193+
summaryModel(type, path, _, _, _)
194+
)
195+
}
196+
}
197+
198+
/**
199+
* A callable where there exists a MaD neutral model that applies to it.
200+
*/
201+
class NeutralCallable extends DataFlow::CallableNode {
202+
NeutralCallable() {
203+
exists(string type, string path |
204+
Util::pathToMethod(this, type, path) and
205+
neutralModel(type, path, _)
206+
)
207+
}
208+
}
209+
186210
/**
187211
* A module defined in source code
188212
*/

0 commit comments

Comments
 (0)