Skip to content

Commit 0e81577

Browse files
committed
Ruby: Use FlowSummaryImpl from dataflow pack
1 parent adc4455 commit 0e81577

38 files changed

+587
-2483
lines changed

config/identical-files.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll",
5858
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll",
5959
"go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll",
60-
"ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll",
6160
"python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll",
6261
"swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll"
6362
],
@@ -471,7 +470,6 @@
471470
"go/ql/lib/semmle/go/dataflow/internal/AccessPathSyntax.qll",
472471
"java/ql/lib/semmle/code/java/dataflow/internal/AccessPathSyntax.qll",
473472
"javascript/ql/lib/semmle/javascript/frameworks/data/internal/AccessPathSyntax.qll",
474-
"ruby/ql/lib/codeql/ruby/dataflow/internal/AccessPathSyntax.qll",
475473
"python/ql/lib/semmle/python/dataflow/new/internal/AccessPathSyntax.qll",
476474
"swift/ql/lib/codeql/swift/dataflow/internal/AccessPathSyntax.qll"
477475
],

ruby/ql/docs/flow_summaries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ have no source code, so we include a flow summary for it:
2222
private class ChompSummary extends SimpleSummarizedCallable {
2323
ChompSummary() { this = "chomp" }
2424
25-
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
25+
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
2626
input = "Argument[self]" and
2727
output = "ReturnValue" and
2828
preservesValue = false

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

Lines changed: 11 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -8,131 +8,32 @@ private import internal.FlowSummaryImpl as Impl
88
private import internal.DataFlowDispatch
99
private import internal.DataFlowImplCommon as DataFlowImplCommon
1010
private import internal.DataFlowPrivate
11-
private import internal.FlowSummaryImplSpecific
1211

1312
// import all instances below
1413
private module Summaries {
1514
private import codeql.ruby.Frameworks
1615
private import codeql.ruby.frameworks.data.ModelsAsData
1716
}
1817

19-
class SummaryComponent = Impl::Public::SummaryComponent;
18+
deprecated class SummaryComponent = Impl::Private::SummaryComponent;
2019

21-
/** Provides predicates for constructing summary components. */
22-
module SummaryComponent {
23-
private import Impl::Public::SummaryComponent as SC
20+
deprecated module SummaryComponent = Impl::Private::SummaryComponent;
2421

25-
predicate parameter = SC::parameter/1;
22+
deprecated class SummaryComponentStack = Impl::Private::SummaryComponentStack;
2623

27-
predicate argument = SC::argument/1;
28-
29-
predicate content = SC::content/1;
30-
31-
predicate withoutContent = SC::withoutContent/1;
32-
33-
predicate withContent = SC::withContent/1;
34-
35-
class SyntheticGlobal = SC::SyntheticGlobal;
36-
37-
/** Gets a summary component that represents a receiver. */
38-
SummaryComponent receiver() { result = argument(any(ParameterPosition pos | pos.isSelf())) }
39-
40-
/** Gets a summary component that represents a block argument. */
41-
SummaryComponent block() { result = argument(any(ParameterPosition pos | pos.isBlock())) }
42-
43-
/** Gets a summary component that represents an element in a collection at an unknown index. */
44-
SummaryComponent elementUnknown() {
45-
result = SC::content(TSingletonContent(TUnknownElementContent()))
46-
}
47-
48-
/** Gets a summary component that represents an element in a collection at a known index. */
49-
SummaryComponent elementKnown(ConstantValue cv) {
50-
result = SC::content(TSingletonContent(DataFlow::Content::getElementContent(cv)))
51-
}
52-
53-
/**
54-
* Gets a summary component that represents an element in a collection at a specific
55-
* known index `cv`, or an unknown index.
56-
*/
57-
SummaryComponent elementKnownOrUnknown(ConstantValue cv) {
58-
result = SC::content(TKnownOrUnknownElementContent(TKnownElementContent(cv)))
59-
or
60-
not exists(TKnownElementContent(cv)) and
61-
result = elementUnknown()
62-
}
63-
64-
/**
65-
* Gets a summary component that represents an element in a collection at either an unknown
66-
* index or known index. This has the same semantics as
67-
*
68-
* ```ql
69-
* elementKnown() or elementUnknown(_)
70-
* ```
71-
*
72-
* but is more efficient, because it is represented by a single value.
73-
*/
74-
SummaryComponent elementAny() { result = SC::content(TAnyElementContent()) }
75-
76-
/**
77-
* Gets a summary component that represents an element in a collection at known
78-
* integer index `lower` or above.
79-
*/
80-
SummaryComponent elementLowerBound(int lower) {
81-
result = SC::content(TElementLowerBoundContent(lower, false))
82-
}
83-
84-
/**
85-
* Gets a summary component that represents an element in a collection at known
86-
* integer index `lower` or above, or possibly at an unknown index.
87-
*/
88-
SummaryComponent elementLowerBoundOrUnknown(int lower) {
89-
result = SC::content(TElementLowerBoundContent(lower, true))
90-
}
91-
92-
/** Gets a summary component that represents the return value of a call. */
93-
SummaryComponent return() { result = SC::return(any(NormalReturnKind rk)) }
94-
}
95-
96-
class SummaryComponentStack = Impl::Public::SummaryComponentStack;
97-
98-
/** Provides predicates for constructing stacks of summary components. */
99-
module SummaryComponentStack {
100-
private import Impl::Public::SummaryComponentStack as SCS
101-
102-
predicate singleton = SCS::singleton/1;
103-
104-
predicate push = SCS::push/2;
105-
106-
predicate argument = SCS::argument/1;
107-
108-
/** Gets a singleton stack representing a receiver. */
109-
SummaryComponentStack receiver() { result = singleton(SummaryComponent::receiver()) }
110-
111-
/** Gets a singleton stack representing a block argument. */
112-
SummaryComponentStack block() { result = singleton(SummaryComponent::block()) }
113-
114-
/** Gets a singleton stack representing the return value of a call. */
115-
SummaryComponentStack return() { result = singleton(SummaryComponent::return()) }
116-
}
24+
deprecated module SummaryComponentStack = Impl::Private::SummaryComponentStack;
11725

11826
/** A callable with a flow summary, identified by a unique string. */
11927
abstract class SummarizedCallable extends LibraryCallable, Impl::Public::SummarizedCallable {
12028
bindingset[this]
12129
SummarizedCallable() { any() }
12230

12331
/**
124-
* Same as
125-
*
126-
* ```ql
127-
* propagatesFlow(
128-
* SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue
129-
* )
130-
* ```
131-
*
132-
* but uses an external (string) representation of the input and output stacks.
32+
* DEPRECATED: Use `propagatesFlow` instead.
13333
*/
134-
pragma[nomagic]
135-
predicate propagatesFlowExt(string input, string output, boolean preservesValue) { none() }
34+
deprecated predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
35+
this.propagatesFlow(input, output, preservesValue)
36+
}
13637

13738
/**
13839
* Gets the synthesized parameter that results from an input specification
@@ -141,7 +42,7 @@ abstract class SummarizedCallable extends LibraryCallable, Impl::Public::Summari
14142
DataFlow::ParameterNode getParameter(string s) {
14243
exists(ParameterPosition pos |
14344
DataFlowImplCommon::parameterNode(result, TLibraryCallable(this), pos) and
144-
s = getParameterPosition(pos)
45+
s = Impl::Input::encodeParameterPosition(pos)
14546
)
14647
}
14748
}
@@ -159,7 +60,7 @@ abstract class SimpleSummarizedCallable extends SummarizedCallable {
15960
final override MethodCall getACallSimple() { result = mc }
16061
}
16162

162-
class RequiredSummaryComponentStack = Impl::Public::RequiredSummaryComponentStack;
63+
deprecated class RequiredSummaryComponentStack = Impl::Private::RequiredSummaryComponentStack;
16364

16465
/**
16566
* Provides a set of special flow summaries to ensure that callbacks passed into
@@ -199,7 +100,7 @@ private module LibraryCallbackSummaries {
199100
libraryCallHasLambdaArg(result.getAControlFlowNode(), _)
200101
}
201102

202-
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
103+
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
203104
(
204105
input = "Argument[block]" and
205106
output = "Argument[block].Parameter[lambda-self]"

ruby/ql/lib/codeql/ruby/dataflow/internal/AccessPathSyntax.qll

Lines changed: 0 additions & 182 deletions
This file was deleted.

0 commit comments

Comments
 (0)