Skip to content

Commit dc09e87

Browse files
committed
Ruby: Use SimpleSummarizedCallable in a few more places
1 parent 9744cf2 commit dc09e87

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ abstract class SummarizedCallable extends LibraryCallable {
134134
* calls to a method with the same name are considered relevant.
135135
*/
136136
abstract class SimpleSummarizedCallable extends SummarizedCallable {
137+
MethodCall mc;
138+
137139
bindingset[this]
138-
SimpleSummarizedCallable() { any() }
140+
SimpleSummarizedCallable() { mc.getMethodName() = this }
139141

140-
final override MethodCall getACall() { result.getMethodName() = this }
142+
final override MethodCall getACall() { result = mc }
141143
}
142144

143145
private class SummarizedCallableAdapter extends Impl::Public::SummarizedCallable {

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

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,10 +1095,8 @@ module Array {
10951095
}
10961096
}
10971097

1098-
private class ProductSummary extends SummarizedCallable {
1099-
MethodCall mc;
1100-
1101-
ProductSummary() { this = "product" and mc.getMethodName() = this }
1098+
private class ProductSummary extends SimpleSummarizedCallable {
1099+
ProductSummary() { this = "product" }
11021100

11031101
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
11041102
(
@@ -1111,17 +1109,11 @@ module Array {
11111109
output = "ArrayElement[?] of ArrayElement[?] of ReturnValue" and
11121110
preservesValue = true
11131111
}
1114-
1115-
override MethodCall getACall() { result = mc }
11161112
}
11171113

1118-
private class PushSummary extends SummarizedCallable {
1119-
MethodCall mc;
1120-
1114+
private class PushSummary extends SimpleSummarizedCallable {
11211115
// `append` is an alias for `push`
1122-
PushSummary() { this = ["push", "append"] and mc.getMethodName() = this }
1123-
1124-
override MethodCall getACall() { result = mc }
1116+
PushSummary() { this = ["push", "append"] }
11251117

11261118
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
11271119
(
@@ -1633,12 +1625,8 @@ module Array {
16331625
}
16341626
}
16351627

1636-
private class UnionSummary extends SummarizedCallable {
1637-
MethodCall mc;
1638-
1639-
UnionSummary() { this = "union" and mc.getMethodName() = this }
1640-
1641-
override MethodCall getACall() { result = mc }
1628+
private class UnionSummary extends SimpleSummarizedCallable {
1629+
UnionSummary() { this = "union" }
16421630

16431631
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
16441632
(

0 commit comments

Comments
 (0)