Skip to content

Commit 2b02a17

Browse files
committed
Ruby: canonicalize callables based on package;type;path instead of input;output;kind
1 parent d8b4bc8 commit 2b02a17

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

ruby/ql/lib/codeql/ruby/dataflow/FlowSummary.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,26 +169,26 @@ private class SummarizedCallableAdapter extends Impl::Public::SummarizedCallable
169169
class RequiredSummaryComponentStack = Impl::Public::RequiredSummaryComponentStack;
170170

171171
private class SummarizedCallableFromModel extends SummarizedCallable {
172-
string input;
173-
string output;
174-
string kind;
172+
string package;
173+
string type;
174+
string path;
175175

176176
SummarizedCallableFromModel() {
177-
ModelOutput::summaryModel(input, output, kind) and
178-
this = input + ";" + output + ";" + kind
177+
ModelOutput::relevantSummaryModel(package, type, path, _, _, _) and
178+
this = package + ";" + type + ";" + path
179179
}
180180

181181
override Call getACall() {
182182
exists(API::MethodAccessNode base |
183-
ModelOutput::resolvedSummaryBase(base, input, output, kind) and
183+
ModelOutput::resolvedSummaryBase(package, type, path, base) and
184184
result = base.getCallNode().asExpr().getExpr()
185185
)
186186
}
187187

188-
override predicate propagatesFlowExt(string input_, string output_, boolean preservesValue) {
189-
input_ = input and
190-
output_ = output and
191-
(
188+
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
189+
exists(string kind |
190+
ModelOutput::relevantSummaryModel(package, type, path, input, output, kind)
191+
|
192192
kind = "value" and
193193
preservesValue = true
194194
or

ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -436,26 +436,23 @@ module ModelOutput {
436436
}
437437

438438
/**
439-
* Holds if a relevant CSV summary row has the given `kind`, `input` and `output`.
439+
* Holds if a relevant CSV summary exists for these parameters.
440440
*/
441-
predicate summaryModel(string input, string output, string kind) {
442-
exists(string package |
443-
isRelevantPackage(package) and
444-
summaryModel(package, _, _, input, output, kind)
445-
)
441+
predicate relevantSummaryModel(
442+
string package, string type, string path, string input, string output, string kind
443+
) {
444+
isRelevantPackage(package) and
445+
summaryModel(package, type, path, input, output, kind)
446446
}
447447

448448
/**
449-
* Holds if a summary edge with the given `input, output, kind` columns have a `package, type, path` tuple
450-
* that resolves to `baseNode`.
449+
* Holds if a `baseNode` is an invocation identified by the `package,type,path` part of a summary row.
451450
*/
452451
predicate resolvedSummaryBase(
453-
Specific::InvokeNode baseNode, AccessPath input, AccessPath output, string kind
452+
string package, string type, string path, Specific::InvokeNode baseNode
454453
) {
455-
exists(string package, string type, AccessPath path |
456-
summaryModel(package, type, path, input, output, kind) and
457-
baseNode = getInvocationFromPath(package, type, path)
458-
)
454+
summaryModel(package, type, path, _, _, _) and
455+
baseNode = getInvocationFromPath(package, type, path)
459456
}
460457

461458
/**

0 commit comments

Comments
 (0)