Skip to content

Commit 367aa35

Browse files
committed
Ruby: Avoid SummarizedCallable::propagatesFlowExt being recursive
1 parent 3b9b9b3 commit 367aa35

File tree

1 file changed

+10
-11
lines changed
  • ruby/ql/lib/codeql/ruby/frameworks/core

1 file changed

+10
-11
lines changed

ruby/ql/lib/codeql/ruby/frameworks/core/Array.qll

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,9 @@ module Array {
140140
}
141141
}
142142

143-
private class SetDifferenceSummary extends SummarizedCallable {
144-
SetDifferenceSummary() { this = "-" }
145-
146-
override SubExpr getACallSimple() { any() }
143+
abstract private class DifferenceSummaryShared extends SummarizedCallable {
144+
bindingset[this]
145+
DifferenceSummaryShared() { any() }
147146

148147
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
149148
input = "Argument[self].Element[any]" and
@@ -152,6 +151,12 @@ module Array {
152151
}
153152
}
154153

154+
private class SetDifferenceSummary extends DifferenceSummaryShared {
155+
SetDifferenceSummary() { this = "-" }
156+
157+
override SubExpr getACallSimple() { any() }
158+
}
159+
155160
/** Flow summary for `Array#<<`. For `Array#append`, see `PushSummary`. */
156161
private class AppendOperatorSummary extends SummarizedCallable {
157162
AppendOperatorSummary() { this = "<<" }
@@ -687,14 +692,8 @@ module Array {
687692
}
688693
}
689694

690-
private class DifferenceSummary extends SimpleSummarizedCallable {
695+
private class DifferenceSummary extends DifferenceSummaryShared, SimpleSummarizedCallable {
691696
DifferenceSummary() { this = "difference" }
692-
693-
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
694-
// `Array#difference` and `Array#-` do not behave exactly the same way,
695-
// but we model their flow the same way.
696-
any(SetDifferenceSummary s).propagatesFlowExt(input, output, preservesValue)
697-
}
698697
}
699698

700699
private string getDigArg(MethodCall dig, int i) {

0 commit comments

Comments
 (0)